fix: tool call anchor & wire format, streaming chunk passthrough, WebUI narrow-screen, docs bilingual

This commit is contained in:
root
2026-08-08 11:26:58 +08:00
parent 8e9de95274
commit 5d50b69153
18 changed files with 1119 additions and 42 deletions

View File

@ -93,16 +93,31 @@ function adapter.transform_stream_chunk(raw_chunk)
if not chunk.candidates or #chunk.candidates == 0 then return "" end
local cand = chunk.candidates[1]
local content = ""
local unified = { content = "", done = (cand.finishReason ~= nil) }
local reasoning = ""
local tools = {}
if cand.content and cand.content.parts then
for _, part in ipairs(cand.content.parts) do
content = content .. (part.text or "")
if part.text then
unified.content = (unified.content or "") .. part.text
elseif part.reasoning_content then
reasoning = reasoning .. part.reasoning_content
elseif part.functionCall then
table.insert(tools, {
index = #tools,
id = part.functionCall.id or ("call_" .. #tools),
type = "function",
["function"] = {
name = part.functionCall.name or "",
arguments = part.functionCall.args or "{}"
}
})
end
end
end
return json.encode({
content = content,
done = (cand.finishReason ~= nil)
})
if reasoning ~= "" then unified.reasoning_content = reasoning end
if #tools > 0 then unified.tool_calls = tools end
return json.encode(unified)
end
return adapter