Commit Graph

295 Commits

Author SHA1 Message Date
newkirk 2e4253e0bf fix: add ModelGroup field to LLMRequest struct matching DB schema
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
2026-07-30 15:20:53 -04:00
newkirk 2562675b8b fix: set reasoning_effort=none when tools present for OpenAI reasoning models
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
2026-07-30 15:18:40 -04:00
newkirk b3dc4365a8 fix(dustins_stack): correct kimi model name kimi-2.6 → kimi-k2.6
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
2026-07-29 12:27:07 -04:00
newkirk 1200a081fc fix(dustins_stack): remove gemini-3.5-flash-lite from targets and fallbacks
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
- Removed gemini-3.5-flash-lite from dustins_stack targets (7→6 models)
- Replaced Gemini fallbacks in multimodal_tier, ultra_long_context, fast_flow_tier
- Added dustins_stack seed data to db.go for fresh deploys
- Also commits pending Gemini role=function→user fix for ChatCompletion and ChatCompletionStream
2026-07-29 12:23:33 -04:00
hobokenchicken c6329d5612 fix(gemini): resolve latency and error issues with model normalization and v1beta tool routing
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
2026-07-28 17:58:21 +00:00
newkirk c96e1d0350 mobile: off-canvas sidebar, responsive grids/charts/top-bar
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
- Sidebar becomes slide-in overlay under 768px with backdrop
- Hamburger button in top-bar for mobile nav toggle
- Grids stack single-column, charts shrink to 280px
- Tables scroll horizontally with touch momentum
- Status text hidden on mobile (dot stays visible)
- Card headers/actions stack vertically
- Period selectors scroll horizontally

also: image size validation clamp in handleImageGenerations
2026-07-27 23:47:31 -04:00
hobokenchicken ba25f5e6c8 style: optimize stat-card grid to fit on 1 line for desktop screens or 2 lines for laptops
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
2026-07-21 18:14:24 +00:00
hobokenchicken 59c38e8f8f feat: add Days Active card and total days lifetime span to dashboard overview
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
2026-07-21 18:11:22 +00:00
newkirk d23da551ab docs: update README with Xiaomi MiMo support, HTTP connection pooling, token caching, and thread safety
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
2026-07-21 13:43:57 -04:00
hobokenchicken 654f6ab6d1 perf: add HTTP connection pooling across providers and disable proxy buffering on SSE streams
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
2026-07-21 17:40:18 +00:00
hobokenchicken 0decc63e8c feat: add token caching middleware and max history messages config
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
2026-07-21 17:30:22 +00:00
hobokenchicken 9980123f97 fix: optimize Gemini stream parsing to support real-time streaming of JSON arrays 2026-07-21 17:29:57 +00:00
hobokenchicken 293cf057b9 fix: restrict tool-heavy/swe-bench tagging to software development or agent-related tasks 2026-07-21 17:29:57 +00:00
hobokenchicken eb90f949a0 fix: Gemini provider compatibility with Gemini 3 models
- Strip additionalProperties and $schema from tool parameter schemas
  (Gemini API rejects these unsupported JSON Schema fields)
- Add thoughtSignature to functionCall parts for multi-turn tool calling
  (Gemini 3 models require thought signatures on function call history)
- Ensure functionResponse.response is always a JSON object, never an
  array or primitive (wrap non-objects in {"result": ...})
- Resolve tool names from tool_call_id or positional index when the
  tool message doesn't carry a name field
- Add functionCall parsing in streaming responses (emitGeminiChunk)
  to properly relay tool calls via SSE
- Add error logging for Gemini stream failures with request body dump
- Add unit tests for schema cleaning and streaming tool call emission
2026-07-21 17:29:57 +00:00
newkirk a187d8e20e fix(phase-4): add DB error checking, mask sensitive auth tokens in API and middleware logs
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
2026-07-21 13:23:02 -04:00
newkirk 700b7cd5d6 fix(phase-3): enable circuit breaker for streaming requests 2026-07-21 13:21:39 -04:00
newkirk 4027ed4351 fix(phase-2): add thread-safety to ModelRegistry and Router reload operations 2026-07-21 13:20:29 -04:00
newkirk 42b70621a1 fix(phase-1): redact API key query params from log output and add mutex thread-safety to providers map 2026-07-21 13:18:31 -04:00
newkirk 84a18f5866 fix(classifier): add tier boundaries and signal keywords to dispatcher prompt
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
- Added tier boundary descriptions (fast/standard/heavy) to the classifier
  system prompt so gpt-5.4-nano understands what each complexity band means
- Added signal keywords for higher/lower ratings to reduce misclassification
  of simple requests as complex and vice versa
2026-07-09 15:46:35 -04:00
hobokenchicken 25e246061f fix: resolve retired/preview gemini model routing and test configuration errors
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
2026-06-18 13:32:34 +00:00
hobokenchicken 73a82e6175 feat: implement advanced condition-based heuristic model routing
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
Upgrades the routing engine to support tag, token limit, multimodal, reasoning, and tool calling conditions. Adds unit tests for the new routing features.
2026-06-05 15:05:13 +00:00
newkirk b3354a1bbc Add Xiaomi MiMo provider (mimo-v2.5) support
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
2026-05-29 12:19:24 -04:00
newkirk 1dc5f586b9 fix: improve OpenAI error body capture and log request body on 400
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
- Use resp.Body() instead of resp.RawBody() for non-streaming error responses
- Fall back to RawBody() for streaming responses
- Log the full request body on API errors for debugging
2026-05-17 19:57:59 -04:00
newkirk 40f055cb57 fix: correct deepseek pricing, gemini streaming tokens, and group-name logging
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
- Add promo discount system for deepseek-v4-pro (75% off until 2026-05-31)
- Rewrite StreamGemini to handle both SSE and JSON array response formats,
  fixing 0-token logging for gemini-3-flash and gemini-3-flash-preview
- Fall back to model group name for cost lookup when concrete model
  isnt in the registry (fixes $0 cost on deepseek-auto entries)
- Move registry lock before FindModel call to fix data race
2026-05-17 19:49:37 -04:00
hobokenchicken 970e778703 chore: update .gitignore to ignore nohup.out and bak files
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
2026-05-11 03:13:54 +00:00
hobokenchicken 477a811999 fix: remove tool call ID truncation and improve DeepSeek reasoning handling
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
The 40-character truncation of tool call IDs in helper.go caused collisions
when models (like deepseek-v4-flash) generated longer IDs, leading to
"Duplicate value for 'tool_call_id'" errors. Removed the limit to allow
full unique IDs.

DeepSeek: updated reasoning_content injection to use an empty string
instead of a space, better matching provider expectations for history.

Improved API error reporting across all providers by capturing raw body
content when response parsing fails or returns empty strings.
2026-05-11 03:13:33 +00:00
hobokenchicken d2b9da89d9 fix FindModel: prioritize canonical providers to prevent reseller limit overrides
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
FindModel iterates providers in random map order, so when deepseek-v4-pro
exists in both 'deepseek' (output=384000) and 'ollama-cloud' (output=1048576),
it sometimes returned the wrong metadata. The proxy then injected
max_tokens=1048576 into DeepSeek's API, which rejected it with 400
(valid range is [1, 393216]).

Fix: define CanonicalProviders list (deepseek, openai, google, xai, etc.)
and search them in priority order before falling back to all providers.
Each of the four lookup strategies (exact key, metadata ID, reverse fuzzy,
forward fuzzy) checks canonical providers first.
2026-05-07 14:47:17 -04:00
hobokenchicken b7df3108fa docs: update README, TODO, and deployment docs
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
README: Added hierarchical routing, classifier bucket mapping, two-level
dispatch, model groups table, DeepSeek language note, deploy script, and
updated model names to match current models.dev registry.

TODO: Added 15 completed items covering model groups, routing, dispatch,
and provider fixes from May 7 session.

deployment.md: Added deploy.sh instructions.
2026-05-07 14:07:52 -04:00
hobokenchicken 28b8271c1d fix: inject English system prompt for DeepSeek provider
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
DeepSeek models default to Chinese for some prompts. The ensureEnglish()
function prepends 'Always respond in English' as a system message when
no system prompt is already set. Applied to both ChatCompletion and
ChatCompletionStream paths.
2026-05-07 14:03:39 -04:00
hobokenchicken eb585c0001 fix: switch dispatcher classifier to gpt-5.4-nano
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
gpt-5.4-nano correctly discriminates complexity (1 vs 10)
while deepseek-v4-flash rated everything as 1/10.
2026-05-07 14:00:19 -04:00
hobokenchicken 4aea7a3b4c fix: select provider AFTER routing resolves model groups
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
Previously, provider selection happened on the raw client-requested model
name (e.g. 'dispatcher') which defaulted to OpenAI. After routing resolved
it to 'deepseek-v4-flash', the provider was never re-selected.

Now prefix-stripping + routing runs first, then selectProvider() picks
the correct provider based on the resolved concrete model.
2026-05-07 13:54:42 -04:00
hobokenchicken 330eaa57d1 fix: update model names to match current models.dev registry
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
heavy-logic: kimi-k2.5 -> kimi-k2.6
standard-pro: gemini-3-flash -> gemini-3-flash-preview
2026-05-07 13:48:33 -04:00
hobokenchicken 0ae30036f0 fix: classifier selector model now routes to correct provider
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
Extracted selectProvider() method from handleChatCompletions' inline
logic. The classifier callback now calls selectProvider(selectorModel)
instead of hardcoding openaiProvider.

This fixes the 'circuit breaker is open' error when dispatcher tries
to use deepseek-v4-flash as its selector model.
2026-05-07 13:37:19 -04:00
hobokenchicken 3c0b59622e feat: classifier bucket mapping + dispatcher seed group
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
Classifier: When complexity_threshold is set (e.g. 10), uses it as the
rating scale and maps ratings proportionally to target buckets instead
of 1:1. Formula: idx = rating * len(targets) / (threshold + 1).

With threshold=10 and 3 targets: 1-3→target[0], 4-7→target[1], 8-10→target[2].

Seed: Added 'dispatcher' group (classifier, threshold=10, selector=deepseek-v4-flash)
that auto-routes to fast-flow/standard-pro/heavy-logic by complexity score.

Combined with hierarchical routing, this enables two-level dispatch:
  dispatcher scores 1-10 → routes to tier group → tier picks concrete model.
2026-05-07 13:18:35 -04:00
hobokenchicken 7517307c11 feat: add hierarchical routing — groups can target other groups
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
RouteToConcrete() recursively resolves group chains until a concrete
model is reached, with cycle detection and max depth (10) guard.

Example: all-purpose -> fast-flow -> deepseek-v4-flash
The dashboard log shows the full chain: 'deepseek-v4-flash (hierarchical:
fast-flow (default (first target)) -> deepseek-v4-flash (default (first target)))'
2026-05-07 12:28:31 -04:00
hobokenchicken 19517b0847 chore: add deploy.sh for prod restarts
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
2026-05-07 12:02:28 -04:00
hobokenchicken a3a6f765e7 feat: add logic_level and primary_use metadata to model groups
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
Schema: Added logic_level (INTEGER) and primary_use (TEXT) columns
to model_groups table with auto-migration for existing databases.

Seed: Three new default groups:
  heavy-logic  (level 9) — Complex Coding, Logic, Agents
  standard-pro (level 5) — General Assistant, Long Docs
  fast-flow    (level 2) — Classification, JSON, Basic Q&A

Admin API: INSERT/UPDATE handlers now accept and persist the new fields.
Dashboard: Table shows Level and Primary Use columns; form includes
both fields with appropriate inputs and placeholders.
2026-05-07 12:01:28 -04:00
hobokenchicken 79dd122b56 feat: expose model groups in /v1/models endpoint
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
Add Groups() method to Router so handleListModels can append model
group IDs (e.g. 'deepseek-auto', 'openai-auto') to the model list,
marked with owned_by: 'gophergate'. This lets clients discover and
use groups via the standard OpenAI /v1/models endpoint.
2026-05-07 11:26:05 -04:00
hobokenchicken 3021e4b2b4 fix: log resolved model name instead of group name in Recent Activity
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
When using model groups (e.g. 'deepseek-auto'), the dashboard logged the
group name instead of the concrete resolved model (e.g. 'deepseek-reasoner').

Now:
- logRequest passes the resolved modelID (concrete) + modelGroup (group name)
- RequestLog struct has a new ModelGroup field (omitempty)
- Dashboard displays resolved model (via group) when a group was used

Files changed:
  internal/server/logging.go  - add ModelGroup field
  internal/server/server.go   - pass resolved modelID, capture modelGroup
  static/js/websocket.js      - show group annotation in Recent Activity
  static/js/pages/overview.js - show group annotation in overview table
  static/js/pages/monitoring.js - show group annotation in stream
2026-05-07 11:16:36 -04:00
hobokenchicken 14de7e9ebf fix: wrap model-groups API responses in SuccessResponse for api.js client
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
2026-05-05 11:41:23 -04:00
hobokenchicken 4fef201e95 fix: remove /api prefix from model-groups API calls (api.js already prepends it)
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
2026-05-05 11:33:05 -04:00
hobokenchicken bac03de051 docs: add automatic model routing to README
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
2026-05-05 11:28:59 -04:00
hobokenchicken 37949e560b feat: add model groups dashboard page with CRUD UI
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
2026-05-05 10:55:25 -04:00
hobokenchicken f04cb6b8f2 feat: add model groups CRUD admin API endpoints 2026-05-05 10:50:33 -04:00
hobokenchicken 10262c0e5a feat: wire model group router into chat completions handler 2026-05-05 10:47:32 -04:00
hobokenchicken d345f8c41d feat: add classifier routing strategy with LLM complexity rating 2026-05-05 10:40:26 -04:00
hobokenchicken d1f7a57f58 feat: add router package with heuristic strategy 2026-05-05 10:37:36 -04:00
hobokenchicken dc9af4d79c feat: add model_groups table and default seed data 2026-05-05 10:33:35 -04:00
hobokenchicken c009d401fb docs: add Responses API endpoint to README
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
2026-05-05 09:36:51 -04:00
hobokenchicken e5ef39f327 feat: add OpenAI Responses API support (POST /v1/responses)
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
Add full Responses API endpoint alongside existing Chat Completions,
with identical logging/tracking/cost pipeline.

New:
- internal/models/responses.go — request/response/stream types + ToUsage() bridge
- internal/providers/openai_responses.go — OpenAI Responses/ResponsesStream

Modified:
- provider.go — Responses()+ResponsesStream() added to Provider interface
- helpers.go — BuildOpenAIResponsesBody, parsers, SSE stream reader
- circuit_breaker.go — CB wraps Responses, passthrough for stream
- server.go — POST /v1/responses route + handleResponses handler
- all non-OpenAI providers — stub methods with clear error messages

Logging: ResponsesUsage.ToUsage() bridges to models.Usage, feeding same
logRequest() -> DB insert -> dashboard WS -> client stats -> cost calc
pipeline. No schema or logger changes needed.
2026-05-02 16:38:17 -04:00