Artifact f445f565bf8deb5c87ea06a718e5b8c1896890b007aa45841f4c864f732ec473:
- File
test/pic/chat-streams/tools.sse
— part of check-in
[55cff08c2c]
at
2026-11-19 00:56:53
on branch stage-4
— Add the Chat Completions adapter for OpenAI, OpenRouter and compatibles
A chunk decoder following Pi: text, reasoning from reasoning_content, reasoning or reasoning_text kept under its field, OpenRouter reasoning_details verbatim, tool calls by index, usage, finish_reason, and in-stream errors. Requests follow Pi too: system or developer role, tools as functions, tool messages, stream_options, store and reasoning by dialect. The retry loop and header assembly move into a shared module both adapters use. Recorded streams, a fuzz target and fake server cases cover it, including a conversation moving between the two APIs in both directions. (user: dmestas, size: 994) [annotate] [blame] [check-ins using] [more...]
data: {"id":"c2","choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"call_a","type":"function","function":{"name":"write","arguments":""}}]},"finish_reason":null}]} data: {"id":"c2","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\"path\":\"no"}}]},"finish_reason":null}]} data: {"id":"c2","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"tes.txt\",\"content\":\"hi\"}"}}]},"finish_reason":null}]} data: {"id":"c2","choices":[{"index":0,"delta":{"tool_calls":[{"index":1,"id":"call_b","type":"function","function":{"name":"bash","arguments":"{\"command\":\"pwd\"}"}}]},"finish_reason":null}]} data: {"id":"c2","choices":[{"index":0,"delta":{},"finish_reason":"tool_calls"}]} data: {"id":"c1","object":"chat.completion.chunk","model":"m","choices":[],"usage":{"prompt_tokens":20,"completion_tokens":5,"total_tokens":25,"prompt_tokens_details":{"cached_tokens":4}}} data: [DONE]