Add Anthropic Messages endpoint (/v1/messages), stream + non-stream
- api::anthropic: AnthropicRequest -> internal ChatRequest (system, text/image/ thinking/tool_use/tool_result blocks, tools input_schema->parameters, tool_choice, sampling, stop_sequences); ChatResponse -> Anthropic message (thinking/text/tool_use blocks, stop_reason end_turn/max_tokens/tool_use, usage). - AnthropicStream translator: message_start / content_block_start/delta/stop / message_delta / message_stop, with block-index state. - Refactor service.stream to yield semantic ChatChunk (+ prompt_len); SSE serialization and the terminal [DONE] moved to the OpenAI route. ChatChunk carries a #[serde(skip)] usage field for presenters (invisible on the OpenAI wire). The same engine-driving (abort/stop/disconnect) feeds both formats. - Route POST /v1/messages; the OpenAI wire is unchanged. 7 new tests (5 conversion unit + 2 HTTP end-to-end); 87 green + 2 ignored; clippy clean; cargo fmt applied. README updated. Core cases faithful; deferred: defer_loading/tool_addition/tool_reference, thinking budget_tokens, prompt-cache token accounting.
This commit is contained in:
1 parent
b6619d30de
commit
9e6d44fa1a
7 files changed
+758
-24
No files matched your search
@@ -4,6 +4,7 @@
|
||||
//! [`formatter`] the token<->text seam, [`service`] the completion logic, and
|
||||
//! [`routes`] the axum router.
|
||||
|
||||
pub mod anthropic;
|
||||
pub mod formatter;
|
||||
pub mod routes;
|
||||
pub mod service;
|
||||
|
||||
Reference in new issue
Block a user