File size: 738 Bytes
e249c6d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
export function sparseAssistant(content: unknown[]) {
  return { role: "assistant" as const, content };
}

export function textToolResult(
  toolCallId: string,
  toolName: string,
  text: string,
  fields?: { isError?: boolean },
) {
  return {
    role: "toolResult" as const,
    toolCallId,
    toolName,
    content: [{ type: "text" as const, text }],
    ...fields,
  };
}

export function textAssistant(text: string): {
  role: "assistant";
  content: { type: "text"; text: string }[];
} {
  return { role: "assistant", content: [{ type: "text", text }] };
}

export function timestampedTextAssistant(text: string, timestamp: number) {
  return {
    role: "assistant",
    content: [{ type: "text", text }],
    timestamp,
  };
}