fix(agent): 修复流式推理与工具参数重试
This commit is contained in:
@@ -11,10 +11,11 @@ import (
|
||||
// The browser sends one protocol-neutral conversation. Only the selected
|
||||
// provider body is materialized; declarative plugins retain their request paths.
|
||||
type canonicalAgentRequest struct {
|
||||
Messages []map[string]interface{} `json:"messages"`
|
||||
Tools []map[string]interface{} `json:"tools"`
|
||||
ToolChoice interface{} `json:"toolChoice"`
|
||||
SystemPrompt string `json:"systemPrompt"`
|
||||
Messages []map[string]interface{} `json:"messages"`
|
||||
Tools []map[string]interface{} `json:"tools"`
|
||||
ToolChoice interface{} `json:"toolChoice"`
|
||||
SystemPrompt string `json:"systemPrompt"`
|
||||
PromptCacheKey string `json:"promptCacheKey,omitempty"`
|
||||
}
|
||||
|
||||
func expandCanonicalAgentRequest(source *canonicalAgentRequest, config providerConfig, declarative bool) (*agentToolRequests, error) {
|
||||
@@ -155,7 +156,11 @@ func canonicalAgentChatBody(source *canonicalAgentRequest, claude bool) map[stri
|
||||
if named, ok := choice.(map[string]interface{}); ok {
|
||||
choice = map[string]interface{}{"type": "function", "function": map[string]interface{}{"name": named["name"]}}
|
||||
}
|
||||
return map[string]interface{}{"messages": messages, "tools": tools, "tool_choice": choice, "parallel_tool_calls": false}
|
||||
body := map[string]interface{}{"messages": messages, "tools": tools, "tool_choice": choice, "parallel_tool_calls": false}
|
||||
if !claude && source.PromptCacheKey != "" {
|
||||
body["prompt_cache_key"] = source.PromptCacheKey
|
||||
}
|
||||
return body
|
||||
}
|
||||
|
||||
func canonicalAgentResponsesBody(source *canonicalAgentRequest) map[string]interface{} {
|
||||
@@ -183,7 +188,11 @@ func canonicalAgentResponsesBody(source *canonicalAgentRequest) map[string]inter
|
||||
converted["type"] = "function"
|
||||
tools = append(tools, converted)
|
||||
}
|
||||
return map[string]interface{}{"input": messages, "tools": tools, "tool_choice": source.ToolChoice, "parallel_tool_calls": false}
|
||||
body := map[string]interface{}{"input": messages, "tools": tools, "tool_choice": source.ToolChoice, "parallel_tool_calls": false}
|
||||
if source.PromptCacheKey != "" {
|
||||
body["prompt_cache_key"] = source.PromptCacheKey
|
||||
}
|
||||
return body
|
||||
}
|
||||
|
||||
func canonicalAgentGeminiBody(source *canonicalAgentRequest) map[string]interface{} {
|
||||
|
||||
Reference in New Issue
Block a user