feat(agent): 云端创作助手 - 增加创作锚点、媒体准入与结构化分镜能力

This commit is contained in:
ddCat committed 2026-09-15 13:37:21 +08:00
1 parent 40aca20f4d
commit be9b22a697
22 files changed
+1686 -60

No files matched your search

+12
View File
@@ -58,6 +58,7 @@ func runAgentToolTask(ctx context.Context, input canvasGenerationInput) (map[str
}
body["model"] = input.Config.Model
applyTextThinking(body, input, protocol)
normalizeAgentToolChoice(body, input, protocol)
result, err := postAgentRequest(ctx, input, path, body, protocol)
if protocol == "chat-completion" && isAgentToolChoiceCompatibilityError(err) {
if !isAutoAgentToolChoice(body["tool_choice"]) {
@@ -117,6 +118,7 @@ func runDeclarativeAgentTask(ctx context.Context, input canvasGenerationInput, a
return nil, errors.New("声明式 Agent 请求体必须是 JSON 对象")
}
applyTextThinking(body, input, wire)
normalizeAgentToolChoice(body, input, wire)
spec.Body = body
if input.StreamText {
body["stream"] = true
@@ -821,6 +823,16 @@ func applyTextThinking(body map[string]interface{}, input canvasGenerationInput,
}
}
// Chat Completion defaults to automatic tool selection when tools are present,
// so an explicit "auto" only reduces compatibility. Reasoning endpoints also
// disagree on forced choices. Normalize before the first network request while
// preserving required/named choices for non-reasoning structured tasks.
func normalizeAgentToolChoice(body map[string]interface{}, input canvasGenerationInput, protocol string) {
if protocol == "chat-completion" && (input.TextOptions.Thinking || isAutoAgentToolChoice(body["tool_choice"])) {
delete(body, "tool_choice")
}
}
type providerTextResult struct {
Text string
Reasoning string