Commit graph

16 commits

Author SHA1 Message Date
alex
8687fb3cbb
fix: accept betas body field from Claude Code clients (#360)
Claude Code newer versions send a `betas` list in the request body (e.g.
"interleaved-thinking-2025-05-14"). This landed in `__pydantic_extra__`
and triggered `_openai_reject_native_only_top_level_fields`, surfacing
as "Invalid request sent to provider." for all OpenAI Chat upstreams
(kimi, nvidia_nim).

Declare `betas` on both `MessagesRequest` and `TokenCountRequest` with
`exclude=True` so it is accepted from clients but never forwarded to any
provider body.
2026-05-05 21:45:15 -07:00
Leung Ka Chun
19e08f2da1
fix(deepseek): accept document blocks and normalize tool_result content (#358)
## What
Fixes the 422 error returned by the proxy when Claude Code v2.1.128+
sends PDF context as Anthropic `document` blocks, plus two related
DeepSeek-only issues uncovered while debugging.

Closes #357.

## Why
Claude Code now attaches PDFs/files as `document` content blocks. The
`Message.content` union didn't include that variant, so every follow-up
turn after a PDF read returned `422 Unprocessable Content` from the
proxy itself (before the request ever reached DeepSeek).

## Changes
- `api/models/anthropic.py`: new `ContentBlockDocument`, added to
`Message.content` union.
- `providers/deepseek/request.py`:
- `_strip_unsupported_attachment_blocks` — silently drops
`image`/`document` blocks for DeepSeek.
- `_serialize_tool_result_content` + `_normalize_tool_result_content` —
coerces `tool_result.content` to a string per DeepSeek's API contract.
- Hooked into `build_request_body` (strip before validation, normalize
before send).
- `tests/providers/test_deepseek.py`: +4 tests, 1 legacy test updated.

## Verification
- `uv run ruff format` 
- `uv run ruff check` 
- `uv run ty check` 
- `uv run pytest`  (1194 passed)
- Manual: `claude-deepseek` against a PDF no longer 422s.

## Scope / non-goals
- No README change (per CONTRIBUTING).
- Image/document blocks for DeepSeek are stripped, not converted to text
— Claude Code already ships the extracted text in the paired
tool_result.
- No changes to other providers.

---------

Co-authored-by: Alishahryar1 <alishahryar2@gmail.com>
2026-05-05 21:36:38 -07:00
Alishahryar1
f3a7528d49 Major refactor: API, providers, messaging, and Anthropic protocol
Some checks are pending
CI / checks (push) Waiting to run
Consolidates the incremental refactor work into a single change set: modular web tools (api/web_tools), native Anthropic request building and SSE block policy, OpenAI conversion and error handling, provider transports and rate limiting, messaging handler and tree queue, safe logging, smoke tests, and broad test coverage.
2026-04-26 03:01:14 -07:00
Alishahryar1
b926f60f64 feat: Anthropic web server tools, provider metadata, messaging hardening
- Add local web_search/web_fetch SSE handling and optional tool schemas
- Extend HeuristicToolParser for JSON-style WebFetch/WebSearch text
- Consolidate provider defaults, ids, and exception typing; stream contracts
- Messaging: typed options, voice config injection, platform contract cleanup
- Tests for web server tools, converters, parsers, contracts; ignore debug-*.log
2026-04-24 23:01:14 -07:00
Alishahryar1
26b8a29537 Architecture refactor: core anthropic, runtime, smoke tiers, remove providers.common 2026-04-24 20:03:14 -07:00
Alishahryar1
66ef23072c Refactor provider routing and smoke coverage 2026-04-24 19:34:34 -07:00
Alishahryar1
835d0454e8 Fixes for issue 113 and 116 2026-04-18 16:32:31 -07:00
Alishahryar1
a7d88d5cbd Updated README with per-model mapping, fixed test .env isolation 2026-03-01 21:52:35 -08:00
Ali Khokhar
0b324e0421
Per claude model mapping (#66) 2026-03-01 21:32:23 -08:00
Alishahryar1
744eec2772 Major cleanup with GLM-5 2026-02-28 09:10:21 -08:00
Ali Khokhar
c4d8681000
Backup/before cleanup 20260222 230402 (#58) 2026-02-27 19:50:21 -08:00
Alishahryar1
d6a0e1a401 Provider inferred from model name using prefix 2026-02-19 20:53:02 -08:00
Alishahryar1
b05d0d2703 new linter rules and fixes 2026-02-18 04:13:41 -08:00
Alishahryar1
539854fe7b Refactor done using GLM-5 2026-02-15 21:58:03 -08:00
Alishahryar1
96747f2216 Updated token counting and removed non streaming support 2026-02-14 19:10:09 -08:00
Alishahryar1
6102583026 Major Refactor Part 2 with kimi-k2.5 in claude code 2026-02-05 16:09:16 -08:00