fix: claude extended thinking (#1419)

This commit is contained in:
yetone
2025-02-27 15:21:00 +08:00
committed by GitHub
parent 77c5ffeb78
commit ebadba7420
5 changed files with 126 additions and 51 deletions

View File

@@ -39,11 +39,22 @@ function M.parse_messages(opts)
role = "assistant",
content = {},
}
if tool_history.tool_use.response_content then
msg.content[#msg.content + 1] = {
type = "text",
text = tool_history.tool_use.response_content,
}
if tool_history.tool_use.thinking_contents then
for _, thinking_content in ipairs(tool_history.tool_use.thinking_contents) do
msg.content[#msg.content + 1] = {
type = "thinking",
thinking = thinking_content.content,
signature = thinking_content.signature,
}
end
end
if tool_history.tool_use.response_contents then
for _, response_content in ipairs(tool_history.tool_use.response_contents) do
msg.content[#msg.content + 1] = {
type = "text",
text = response_content,
}
end
end
msg.content[#msg.content + 1] = {
type = "tool_use",