MCPcopy Create free account
hub / github.com/Alphanimble/htmlstream / extractDeltaContent

Function extractDeltaContent

demo/server/openrouter-chat.ts:64–94  ·  view source on GitHub ↗
(delta: Record<string, unknown> | undefined)

Source from the content-addressed store, hash-verified

62}
63
64function extractDeltaContent(delta: Record<string, unknown> | undefined): string {
65 if (!delta) {
66 return "";
67 }
68
69 const { content, text } = delta;
70
71 if (typeof content === "string") {
72 return content;
73 }
74
75 if (Array.isArray(content)) {
76 return content
77 .map((part) => {
78 if (typeof part === "string") {
79 return part;
80 }
81 if (part && typeof part === "object" && "text" in part) {
82 return String((part as { text?: string }).text ?? "");
83 }
84 return "";
85 })
86 .join("");
87 }
88
89 if (typeof text === "string") {
90 return text;
91 }
92
93 return "";
94}
95
96function extractDeltaReasoning(delta: Record<string, unknown> | undefined): string {
97 if (!delta) {

Callers 1

extractDeltaPartsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected