guanaco/.gitignore
evangit2 4686af1a4f
release: v0.5.0 — usage tracking, ROI dashboard, multi-account, live usage-level scraping
* v0.4.3 — add kimi-k2.6 vision model, default all roles to nemotron-3-nano:30b

- KNOWN_CLOUD_MODELS: add kimi-k2.6 with [vision, tools, thinking, cloud]
- LLMConfig defaults: reranker/scraper/summary/default all set to nemotron-3-nano:30b
- available_models: add nemotron-3-nano:30b and kimi-k2.6
- dashboard.html: add kimi-k2.6 and nemotron-3-nano capability maps
- cli.py setup wizard: update all model prompts/default placeholders
- version bump: 0.4.2 → 0.4.3 in __init__.py, app.py, pyproject.toml

Update-safe: only new model registry entries + default value changes.
Existing configs preserve their saved values (pydantic).
Zero schema or API break.

* feat: cost-weighted analytics (usage_multiplier) + add deepseek-v4 models

- Add usage_multiplier column to analytics DB (auto-resolved from model name)
- Log weighted token totals (prompt*multiplier, completion*multiplier) in summary
- Show cost bars + weighted totals in dashboard analytics tab
- Add per-model multiplier column to analytics table
- Auto-compute total_tokens in analytics if not provided
- Add deepseek-v4-pro (1.0x) and deepseek-v4-flash (0.50x) to KNOWN_CLOUD_MODELS
- Add gemini-3-flash-preview to available_models and dashboard capability maps
- Add new models to config.py available_models list

* feat: auto-infer capabilities and multiplier for unknown models

Previously new Ollama Cloud models showed no capability badges and
assumed 1.00x multiplier until manually added to KNOWN_CLOUD_MODELS.
Now both backend (client.py) and frontend (dashboard.html) fall
back to name-based inference for unknown models:

- Capabilities: 'vision' from vl/gemma/gemini/kimi/deepseek, 'tools'
  from coder/minimax/glm/mistral/gpt-oss/devstral/nemotron/deepseek,
  'thinking' from deepseek/cogito/reason/think and kimi-k* families
- Multiplier: extract :XXb|:Xt from model name for size-based tier
  (<=20b=0.25, <=80b=0.50, <=400b=0.75, >400b/1t=1.00), then fall
  back to name heuristics (nano/mini/small=0.25, flash/gemma=0.50,
  pro/mistral-large=1.00)

Models explicitly in KNOWN_CLOUD_MODELS still use exact values.
This means new models like deepseek-v5-pro or kimi-k3 show up
correctly in the dashboard immediately without code changes.

* feat: experimental Subscription Value Calculator (ROI) vs OpenRouter

Adds a new experimental feature to the Status tab that compares your
total subscription cost to what you'd pay with OpenRouter's cheapest
provider pricing.

Backend:
- guanaco/roi.py: Fetches live prices from OpenRouter API, matches
  Ollama model names to OpenRouter model IDs via family inference
  (exact → family prefix → same parameter size → size window →
  global average), multiplies tokens by $/Mt cost.
- Calculates this week's cost, extrapolates to 100% weekly usage,
  then monthly. Shows ROI multiplier (monthly value / subscription).
- /dashboard/api/roi/calculate: fresh calculation
- /dashboard/api/roi/last: cached last result
- /dashboard/api/roi/reset: clear data
- /dashboard/api/roi/config: enable/disable, set price tier

Dashboard (Status tab):
- Toggle to enable/disable the feature
- Pro (0/mo) / Max (00/mo) / Custom price selector
- Shows: this-week cost, weekly @ 100%, monthly value, ROI multiplier
- Per-model table: prompt_tokens, completion_tokens, $/Mt in/out,
  total cost, % of usage
- Warnings for unmatched models and stale prices
- Reset button clears cached data

ROIConfig added to config.py (persisted in config.yaml).

* fix(config): v0.4.3 backward compat and install robustness

Changes:
- Add missing UsageConfig fields (last_plan, redirect_on_full, last_session_reset, last_weekly_reset, last_checked) to fix AttributeError crashes
- Add config migration layer in load_config() for v0.4.2 to v0.4.3+ configs
- Rename package guanaco to guanaco-llm-proxy to avoid PyPI collision
- Add Ollama API key validation during install.sh setup (fixes: use real key var, fix env file write, fix grep pattern)
- Add startup version sanity check detecting repo/venv mismatch
- Fix systemd service WorkingDirectory to repo checkout
- Add GUANACO_CONFIG_DIR env var to systemd service

* feat(v0.4.3): token estimation fallback, ROI dashboard, per-model usage breakdown

Token tracking:
- analytics.py: fall back to skimtoken estimation when API omits usage
  (~15% error, better than zero). Proper total_tokens = prompt + completion.
  Removed broken usage_multiplier column.
- router.py: unchanged — already passes usage → analytics correctly

Dashboard / ROI:
- roi.py: OpenRouter price fetcher with cache-hit discount logic
- dashboard.py: expose ROI config with cache_hit_pct slider
- dashboard.html: cost breakdown UI, per-model value scoring

Models:
- client.py: added minimax-m3, nemotron-3-ultra, kimi-k2.6 200k context
- client.py: per-model Ollama usage breakdown scraping from /settings

Config:
- config.py: backward compat for installs missing SearchConfig

* feat(usage-levels): scrape real per-tag usage tiers from ollama.com library pages

- Add _fetch_usage_level_sync() to parse ollama.com/library/{model} HTML
- Handle both top-level model badges (x-test-model-cost-slot-active)
  and per-tag listings (x-test-model-tag-cost + x-test-model-tag-usage-slot-active)
- Add async fetch_usage_levels() with 1h global cache + parallel fetching
- Wire usage_multiplier into /v1/models and /api/ollama/models responses
- Replace heuristic _get_model_multiplier fallback with real scraped levels
- Fixes gemma3:4b/12b showing 1.00x instead of 0.25x, qwen3-vl 0.25x→0.75x, etc.

---------

Co-authored-by: evangit2 <evangit2@users.norereply.github.com>
Co-authored-by: Evan Rice <evanrice@vt.edu>
2026-06-09 21:06:39 -04:00

90 lines
835 B
Text

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
*.egg
# Virtual environments
venv/
.venv/
env/
# Environment variables
.env
.env.*
!.env.example
# Databases
*.db
*.sqlite
analytics.db
# Config with secrets
config.yaml
# PyInstaller
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre
.pyre/
# IDE
.idea/
.vscode/
*.swp
*.swo
*~
# OS
.DS_Store
Thumbs.db
# Project-specific
.oct/.venv-test/