fix(scriberr): patch 0004 — chat context window for gateway model names (LLM_DEFAULT_CONTEXT_WINDOW=131072); image ctxwin1 live, idle-gated deploy; svos v0.0.20 staged

This commit is contained in:
vh
2026-10-19 00:55:37 -07:00
parent 94ba3c659c
commit 5be01a8744
7 changed files with 139 additions and 1 deletions
+3
View File
@@ -54,3 +54,6 @@ SCRIBERR_SECURE_COOKIES=false
# when unset; override only with a re-measured peak.
# SCRIBERR_PARAKEET_CHUNK_SECS=120
# SCRIBERR_PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True
# Chat context window for gateway model names (patch 0004; needs an image built with it).
# SCRIBERR_LLM_DEFAULT_CONTEXT_WINDOW=131072
+4
View File
@@ -65,6 +65,10 @@ services:
# reached by host IP. Keep this in sync with how the app is reached.
- ALLOWED_ORIGINS=${SCRIBERR_ALLOWED_ORIGINS}
- NVIDIA_DRIVER_CAPABILITIES=compute,utility
# Chat's context window for a model name Scriberr's OpenAI table does not know (patch 0004, 2026-10-19).
# Upstream returns 4096 for every non-OpenAI name, so chat refused any transcript over ~3.6k estimated
# tokens even on 262k-context gateway models (summarizer, gen-large). Half their real context.
- LLM_DEFAULT_CONTEXT_WINDOW=${SCRIBERR_LLM_DEFAULT_CONTEXT_WINDOW:-131072}
# Scriberr builds each model backend's Python env with `uv` at runtime.
# uv's default link mode reflink/hardlinks out of its cache, which fails
# on this overlayfs+ZFS combination with a misleading
@@ -0,0 +1,35 @@
Subject: [PATCH 0004] chat: LLM_DEFAULT_CONTEXT_WINDOW for model names the OpenAI table does not know
OpenAIService.GetContextWindow knows only OpenAI's own names (gpt-4o, gpt-4, gpt-3.5)
and returns 4096 for anything else. Behind an OpenAI-compatible gateway every model is
"anything else" (here LiteLLM's summarizer and gen-large, 262k-context vLLM seats), so
chat refuses any transcript the handler estimates above 3,596 tokens (chars/4, minus 500
kept for the reply): a 22k-character meeting was refused on 2026-10-19 with "limit 4096".
The default branch now reads LLM_DEFAULT_CONTEXT_WINDOW (a positive integer) and keeps
4096 when it is unset or invalid; the known OpenAI names are unchanged.
---
--- a/internal/llm/openai.go
+++ b/internal/llm/openai.go
@@ -9,6 +9,8 @@
"io"
"log"
"net/http"
+ "os"
+ "strconv"
"strings"
"time"
)
@@ -337,7 +339,11 @@
case strings.HasPrefix(model, "gpt-3.5-turbo"):
return 16385, nil // Most recent gpt-3.5-turbo is 16k
default:
- // Default fallback
+ // Not an OpenAI model name (a LiteLLM alias, a vLLM served name): the operator's
+ // LLM_DEFAULT_CONTEXT_WINDOW when set to a positive integer, else upstream's 4096.
+ if v, err := strconv.Atoi(strings.TrimSpace(os.Getenv("LLM_DEFAULT_CONTEXT_WINDOW"))); err == nil && v > 0 {
+ return v, nil
+ }
return 4096, nil
}
}