Download packages/ai/src/utils/text.ts from SaylorTwift/pi: direct link, hf CLI and curl.
- Browser
- Download file 470 Bytes
-
https://huggingface.co/SaylorTwift/pi/resolve/main/packages/ai/src/utils/text.ts
- Command line
-
hf download hf://SaylorTwift/pi/packages/ai/src/utils/text.ts
-
curl -L -o text.ts https://huggingface.co/SaylorTwift/pi/resolve/main/packages/ai/src/utils/text.ts
470 Bytes
| import type { ImageContent, TextContent, ThinkingContent, ToolCall } from "../types.ts"; | |
| type Content = TextContent | ImageContent | ThinkingContent | ToolCall; | |
| /** Extract and join text from message content. */ | |
| export function contentText(content: string | readonly Content[], separator = "\n"): string { | |
| if (typeof content === "string") return content; | |
| return content | |
| .filter((block) => block.type === "text") | |
| .map((block) => block.text) | |
| .join(separator); | |
| } | |