feat(model): 双协议 LLM Provider(AnthropicChNativeAdapter /v1/messages + tool_use.input→Args 直接映射 + 流式重组)+ Provider 感知工厂/路由 + LLM_PROVIDER/anthropic 配置(OpenAI 兼容保留)
This commit is contained in:
1 parent
f9650185f1
commit
3632e04733
11 files changed
+1452
-18
No files matched your search
@@ -87,6 +87,18 @@ type ToolSpec struct {
|
||||
Parameters any
|
||||
}
|
||||
|
||||
// ToolCall is a single assistant-originated tool invocation parsed from a
|
||||
// provider's tool_use content block. Args is the structured argument object
|
||||
// (never a serialized JSON string), so a tool loop can bind it directly without
|
||||
// re-parsing.
|
||||
type ToolCall struct {
|
||||
// Name is the tool being invoked.
|
||||
Name string
|
||||
// Args are the tool arguments, decoded from the provider's structured
|
||||
// tool_use.input object. It is never a JSON-encoded string.
|
||||
Args map[string]any
|
||||
}
|
||||
|
||||
// Request is a completion request, normalized across providers.
|
||||
type Request struct {
|
||||
// Model overrides the adapter's configured default model. Empty means the
|
||||
@@ -101,6 +113,11 @@ type Request struct {
|
||||
Purpose string
|
||||
// Tools is the interface-level placeholder for M2 function calling.
|
||||
Tools []ToolSpec
|
||||
// ToolChoice optionally directs how the provider selects a tool. It is an
|
||||
// opaque provider-agnostic directive (e.g. {"type":"auto"} or {"type":"tool",
|
||||
// "name":"x"}); empty means the provider default. Passed through verbatim to
|
||||
// protocols that support it (Anthropic's tool_choice).
|
||||
ToolChoice any
|
||||
}
|
||||
|
||||
// Response is a normalized completion result.
|
||||
@@ -110,6 +127,9 @@ type Response struct {
|
||||
Content string
|
||||
// Message is the normalized assistant message.
|
||||
Message Message
|
||||
// ToolCalls carries any tool_use blocks the assistant emitted. Empty when the
|
||||
// response is pure text.
|
||||
ToolCalls []ToolCall
|
||||
// PromptTokens, CompletionTokens and TotalTokens report provider usage when
|
||||
// available; zero when the provider does not return it.
|
||||
PromptTokens int
|
||||
|
||||
Reference in new issue
Block a user