mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-10-01 08:33:14 +00:00
16 lines
487 B
TypeScript
16 lines
487 B
TypeScript
import { MessageContent } from "@langchain/core/messages";
|
|
|
|
export function getMessageContentString(content: MessageContent): string {
|
|
try {
|
|
if (typeof content === "string") return content;
|
|
|
|
return content
|
|
.filter((c): c is { type: "text"; text: string } => c.type === "text")
|
|
.map((c) => c.text)
|
|
.join(" ");
|
|
} catch (error) {
|
|
// eslint-disable-next-line no-console
|
|
console.error("Failed to get message content string", error);
|
|
return "";
|
|
}
|
|
}
|