feat(ai): add shared contentText utility (#6840)

Co-authored-by: Armin Ronacher <armin.ronacher@active-4.com>
This commit is contained in:
Alexey Zaytsev
2026-07-19 20:50:36 -03:00
committed by GitHub
parent 75cb0b873a
commit 94373d815d
12 changed files with 92 additions and 111 deletions
@@ -1,4 +1,12 @@
import type { AssistantMessage, ImageContent, Model, Models, TextContent, Usage } from "@earendil-works/pi-ai";
import {
type AssistantMessage,
contentText,
type ImageContent,
type Model,
type Models,
type TextContent,
type Usage,
} from "@earendil-works/pi-ai";
import type { AgentMessage, ThinkingLevel } from "../../types.ts";
import {
convertToLlm,
@@ -513,10 +521,7 @@ export async function generateSummary(
);
}
const textContent = response.content
.filter((c): c is { type: "text"; text: string } => c.type === "text")
.map((c) => c.text)
.join("\n");
const textContent = contentText(response.content);
return ok(textContent);
}
@@ -744,10 +749,5 @@ async function generateTurnPrefixSummary(
);
}
return ok(
response.content
.filter((c): c is { type: "text"; text: string } => c.type === "text")
.map((c) => c.text)
.join("\n"),
);
return ok(contentText(response.content));
}