feat(ai): add shared contentText utility (#6840)
Co-authored-by: Armin Ronacher <armin.ronacher@active-4.com>
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user