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

Function repairAssistantMessage

demo/chat/session.ts:20–39  ·  view source on GitHub ↗
(message: ChatMessage)

Source from the content-addressed store, hash-verified

18const STORAGE_KEY = "htmlstream-chat-session-v1";
19
20function repairAssistantMessage(message: ChatMessage): ChatMessage {
21 if (message.role !== "assistant") {
22 return message;
23 }
24
25 const content = typeof message.content === "string" ? message.content : "";
26 const reasoning =
27 typeof message.reasoning === "string" ? message.reasoning : "";
28
29 if (!content.includes('"kind":"')) {
30 return { ...message, content, reasoning: reasoning || undefined };
31 }
32
33 const repaired = splitStoredStreamText(content);
34 return {
35 ...message,
36 reasoning: reasoning || repaired.reasoning || undefined,
37 content: repaired.content,
38 };
39}
40
41export function repairSession(session: ChatSession): ChatSession {
42 return {

Callers

nothing calls this directly

Calls 1

splitStoredStreamTextFunction · 0.85

Tested by

no test coverage detected