Repository navigation
fix(sambanova): correct DeepSeek-V3.2 context window (32k -> 128k) - #32035
bhumikadangayach wants to merge 10 commits into
Conversation
…out (BerriAI#31632) * fix(prometheus): bound per-request budget metric emission with a timeout Wrap the per-request budget-metric gather in asyncio.wait_for so a slow Redis or DB lookup cannot consume the whole LoggingWorker watchdog and get the success-logging event cancelled. On timeout the emission is skipped in isolation; budget gauges are still refreshed by the periodic cron. The timeout is configurable via PROMETHEUS_BUDGET_METRICS_PER_REQUEST_TIMEOUT and defaults to 5.0 seconds, falling back to the default on an invalid value instead of raising * fix(prometheus): reject non-finite and non-positive budget-metrics timeout env float() accepts 0, negatives, nan and inf, which bypass the fallback: a value <= 0 makes asyncio.wait_for time out immediately and skip every per-request emission, and inf reintroduces the unbounded wait the timeout was meant to bound. Validate the parsed value is finite and greater than zero before using it, otherwise fall back to the default
When a guardrail blocks a post-call response, the synthetic violation response reported hard-coded zero usage, discarding the token usage the upstream call had already consumed. Fix the root cause rather than re-counting tokens: - Add an optional `original_response` field to ModifyResponseException. - The unified guardrail's post-call success hook attaches the blocked LLM response to the exception. - The /v1/messages and OpenAI-format (/v1/chat/completions, /v1/completions) block handlers report `original_response.usage` directly. Pre-call blocks never invoked the LLM, so usage is zero. Mock-based tests cover the helper (returns original usage / zero), the success hook attaching original_response, and the endpoint reporting it end-to-end. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ock (BerriAI#31389) Streaming moderation improvements for the unified guardrail post-call streaming iterator hook: - streaming_buffer_until_moderated: withhold all chunks until end-of-stream moderation passes, then release the original response (clean) or only the block message (blocked) -- the original content is never delivered on a block. Snapshot chunks with a shallow list() copy (end-of-stream builds a separate assembled response; chunks aren't mutated in place). - Clean Anthropic SSE on block: synthesize a well-formed termination sequence instead of a bare data: {"error": ...} blob that truncates the stream. Provider-specific synthesis lives in AnthropicMessagesHandler via build_block_sse_chunks (format-agnostic routing stays in the hook). - Mid-stream blocks continue the in-progress message (close open content block, append block message, terminate) rather than emitting a second message_start, which clients reject. Standalone envelope only when no chunks were sent (buffered path). - ModifyResponseException imported under TYPE_CHECKING + locally at runtime to avoid a module-level cyclic import. Adds regression tests for buffering (content withheld on block) and mid-stream continuation (single message_start). Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… content-rewriting guardrails - _standalone_block_chunks and _block_continuation_chunks now read real token usage from ModifyResponseException.original_response instead of hardcoding zero, matching the non-streaming _blocked_response_usage path. Shared helper moved to guardrail_translation/utils.py. - streaming_buffer_until_moderated is now forced off when the guardrail has mask_response_content=True, since buffered replay releases the withheld original chunks verbatim -- unsafe for a guardrail that rewrites content (e.g. PII masking). - Fix inverted streaming-flag precedence comment.
…-of-stream detection _check_streaming_has_ended assumed responses_so_far held ModelResponse objects with .choices, but for the Responses API the accumulated chunks are raw SSE event dicts, causing an AttributeError on every call
Greptile SummaryThis PR fixes the
Confidence Score: 1/5Not safe to merge — the backup JSON file is malformed and will crash litellm in any scenario that falls back to it. The backup file's JSON structure is broken: the root object closes before litellm/model_prices_and_context_window_backup.json needs to be regenerated or hand-corrected so that
|
| Filename | Overview |
|---|---|
| model_prices_and_context_window.json | Correctly updates sambanova/DeepSeek-V3.2 max_tokens, max_input_tokens, and max_output_tokens from 32768 to 131072; no other changes in this file |
| litellm/model_prices_and_context_window_backup.json | Contains the DeepSeek-V3.2 fix plus ~200+ unreferenced model additions/updates; critically, repositioning the darkbloom entries breaks the JSON structure — the root object closes before fallback_generalizations, making the file unparseable |
Comments Outside Diff (1)
-
litellm/model_prices_and_context_window_backup.json, line 1 (link)Backup file diverges significantly from the primary file
The PR description states "Backup file synced to match primary," but the diff shows the backup contains ~200+ lines of additional changes absent from
model_prices_and_context_window.json: new model entries (gemini-3-pro-image,gemini-3.1-flash-imageforvertex_ai/gemini/bare variants,openrouter/z-ai/glm-5.1,zai/glm-5.1,zai/glm-4.7-flash), updatedmax_input_tokensvalues for several OpenAI models, correctedmax_output_tokens/max_tokensforo1-provariants, and repositioneddarkbloomentries. The two files are not in sync. Any user relying on the backup will get different model data than a user relying on the primary.
Reviews (1): Last reviewed commit: "fix(sambanova): correct DeepSeek-V3.2 co..." | Re-trigger Greptile
| }, | ||
| "fallback_generalizations": { |
There was a problem hiding this comment.
Broken JSON structure — backup file is now invalid
The relocation of the darkbloom model entries introduced a malformed JSON structure. At line 44015 the root object is closed by } followed by a trailing ,, and "fallback_generalizations" appears on the next line at 0-space indentation — outside the root {}. This makes the file invalid JSON that json.loads() will reject with a JSONDecodeError.
load_local_model_cost_map() in get_model_cost_map.py has no try/except around json.loads(), so this will crash litellm in any scenario where the backup is needed: when LITELLM_LOCAL_MODEL_COST_MAP=True, when the remote fetch fails (the fallback path at lines 295–297 of get_model_cost_map.py), and during integrity validation via _get_backup_model_count(). Compare with the primary file (model_prices_and_context_window.json line 44008–44009) where gpt-oss-20b correctly closes with }, (comma included) and fallback_generalizations remains at 2-space indent inside the root object.
There was a problem hiding this comment.
Fixed in 748ddd3 — regenerated the backup directly from the primary file. Both files are now in sync and valid JSON (verified locally with json.load()). The Greptile review is based on the first commit before the fix — please re-trigger to confirm.
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
|
|
Follow-up to #30016.
Greptile flagged in that PR that DeepSeek-V3.2's 32k context window might be a repeat of the same copy-paste mistake that was just fixed for DeepSeek-V3.1 (also 32k -> 128k). Confirmed via multiple sources (OpenRouter, Artificial Analysis, DeepSeek's own technical paper) that DeepSeek-V3.2 has a 128k (131,072 token) context window, matching its V3.1 predecessor's architecture lineage.
Fixed max_tokens, max_input_tokens, and max_output_tokens for sambanova/DeepSeek-V3.2 from 32768 → 131072. Pricing and other fields unchanged.
Backup file synced to match primary.
Supersedes #31417 (rebased onto current litellm_oss_staging).