只需要一份代码
import { AutoLLMClient } from "@prismshadow/mmsp";
const client = new AutoLLMClient({ model: "claude-opus-5-5" });
for await (const event of client.streamingResponseStateful({
message: {
role: "user",
content_items: [{ type: "text.done", text: "What's the weather in Paris?" }],
},
config: { tools: [getWeather] },
})) {
console.log(event);
}import { AutoLLMClient } from "@prismshadow/mmsp";
const client = new AutoLLMClient({ model: "gpt-6.1-sol" });
for await (const event of client.streamingResponseStateful({
message: {
role: "user",
content_items: [{ type: "text.done", text: "What's the weather in Paris?" }],
},
config: { tools: [getWeather] },
})) {
console.log(event);
}import { AutoLLMClient } from "@prismshadow/mmsp";
const client = new AutoLLMClient({ model: "gemini-3.8-flash" });
for await (const event of client.streamingResponseStateful({
message: {
role: "user",
content_items: [{ type: "text.done", text: "What's the weather in Paris?" }],
},
config: { tools: [getWeather] },
})) {
console.log(event);
}流式事件传输
- deltathinking.delta"The user wants"
- deltathinking.delta" the weather in Paris."
- deltathinking.deltafidelity {"signature":"EuYBCkYIBxgC…"}
- deltathinking.done"The user wants the weather in Paris." fidelity {"signature":"EuYBCkYIBxgC…"}
- deltatool_call.deltaget_weather toolu_01A3
- deltatool_call.delta"{\"location\": "
- deltatool_call.delta"\"Paris\"}"
- deltatool_call.doneget_weather toolu_01A3 {"location":"Paris"}
- stoptool_callusage_metadata {"cached_tokens":0,"prompt_tokens":412,"thoughts_tokens":31,"response_tokens":27}
消息解析结果
- thinking.done"The user wants the weather in Paris." fidelity {"signature":"EuYBCkYIBxgC…"}
- tool_call.doneget_weather toolu_01A3 {"location":"Paris"}
finish_reasontool_call
usage_metadata470 tokens
缓存0
提示词412
思考31
回复27