mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-26 20:45:37 +02:00
feat(sdk): add thinking content extraction for stream events
Update StreamMessageEvent content type to include thinking blocks. Add extractThinkingFromEvent() helper and export it, enabling clients to access reasoning content from streamed agent responses. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -37,4 +37,5 @@ export {
|
||||
type StreamMessageEvent,
|
||||
type StreamToolEvent,
|
||||
extractTextFromEvent,
|
||||
extractThinkingFromEvent,
|
||||
} from "./stream";
|
||||
|
||||
@@ -12,7 +12,7 @@ export interface StreamMessageEvent {
|
||||
message: {
|
||||
id?: string;
|
||||
role: string;
|
||||
content?: Array<{ type: string; text?: string }>;
|
||||
content?: Array<{ type: string; text?: string; thinking?: string }>;
|
||||
};
|
||||
assistantMessageEvent?: unknown;
|
||||
}
|
||||
@@ -47,3 +47,13 @@ export function extractTextFromEvent(event: StreamMessageEvent): string {
|
||||
.map((c) => c.text ?? "")
|
||||
.join("");
|
||||
}
|
||||
|
||||
/** Extract thinking/reasoning content from an AgentMessage content array */
|
||||
export function extractThinkingFromEvent(event: StreamMessageEvent): string {
|
||||
const content = event.message?.content;
|
||||
if (!Array.isArray(content)) return "";
|
||||
return content
|
||||
.filter((c) => c.type === "thinking")
|
||||
.map((c) => c.thinking ?? "")
|
||||
.join("");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user