mirror of
https://gitcode.com/JianFeeeee/ModelRouter.git
synced 2026-09-20 08:57:57 +00:00
fix: tool call anchor & wire format, streaming chunk passthrough, WebUI narrow-screen, docs bilingual
This commit is contained in:
@ -72,10 +72,29 @@ function adapter.transform_stream_chunk(raw_chunk)
|
||||
if not ok then return "" end
|
||||
if not chunk.message then return "" end
|
||||
|
||||
return json.encode({
|
||||
local unified = {
|
||||
content = chunk.message.content or "",
|
||||
done = chunk.done or false
|
||||
})
|
||||
}
|
||||
if chunk.message.reasoning_content then
|
||||
unified.reasoning_content = chunk.message.reasoning_content
|
||||
end
|
||||
if chunk.message.tool_calls then
|
||||
local tools = {}
|
||||
for _, tc in ipairs(chunk.message.tool_calls) do
|
||||
table.insert(tools, {
|
||||
index = #tools,
|
||||
id = tc.id or ("call_" .. #tools),
|
||||
type = "function",
|
||||
["function"] = {
|
||||
name = tc["function"] and tc["function"].name or "",
|
||||
arguments = tc["function"] and (tc["function"].arguments or "{}") or "{}"
|
||||
}
|
||||
})
|
||||
end
|
||||
unified.tool_calls = tools
|
||||
end
|
||||
return json.encode(unified)
|
||||
end
|
||||
|
||||
return adapter
|
||||
|
||||
Reference in New Issue
Block a user