#* DeepSeek chat-completions request body. The provider's request shape lives under base/ai/templates/<type>.html and is named by the manager's type (DeepSeekManager.getType() == "deepseek"), because the body shape is provider-specific: chat completions here, Responses-shaped for OpenAI. The body is a rendering of frame state: $recent thought rows for this framepath, oldest first (user_message/chat -> user, airesponse -> assistant, function_call -> assistant tool_calls, function_response -> tool) $prompt the turn being asked now $systemmessage, $model, $functions, $frameroot, $apphome, $gpt, $context *# { "model": "$!model", "stream": false, "messages": [ { "role": "system", "content": #jesc($systemmessage) } #foreach($entry in $recent) #set($emit = true) ## Frame logs are diagnostics, not conversation. loadFrameResponse writes one per ## action, so a log row can land between an assistant tool_calls and its tool ## response - emitting it there makes the API reject the whole request ## ("tool_calls must be followed by tool messages"). #if($entry.messagetype == "log") #set($emit = false) #end #if($entry.user == "agent" && $entry.messagetype != "function_call" && $entry.messagetype != "function_response" && (!$entry.message || $entry.message.trim() == "")) #set($emit = false) #end #if($emit) ,#if($entry.messagetype == "function_call") { "role": "assistant", "content": null, "tool_calls": [ { "id": "$entry.id", "type": "function", "function": { "name": "$entry.function", "arguments": #jesc($entry.arguments) } } ] } #elseif($entry.messagetype == "function_response") { "role": "tool", "tool_call_id": "$entry.command", "content": #jesc($entry.function_response) } #elseif($entry.user == "agent") { "role": "assistant", "content": #jesc($entry.message) } #else { "role": "user", "content": #jesc($entry.message) } #end #end #end #if($prompt) ,{ "role": "user", "content": #jesc($prompt) } #end ], "tools": [ #foreach($func in $functions) #if($foreach.count != 1),#end { "type": "function", "function": $gpt.loadInputFromTemplate($context, "$apphome/frames/$frameroot/functions/${func}.json") } #end ], "tool_choice": "auto" }