Files
deer-flow/frontend/src/core/threads/utils.ts

28 lines
781 B
TypeScript
Raw Normal View History

2026-01-15 23:40:21 +08:00
import type { BaseMessage } from "@langchain/core/messages";
import type { AgentThread } from "./types";
2026-01-15 23:40:21 +08:00
export function pathOfThread(thread: AgentThread, includeAssistantId = true) {
2026-01-15 23:40:21 +08:00
if (includeAssistantId) {
return `/workspace/chats/${thread.thread_id}`;
}
return `/workspace/chats/${thread.thread_id}`;
}
export function textOfMessage(message: BaseMessage) {
if (typeof message.content === "string") {
return message.content;
} else if (Array.isArray(message.content)) {
return message.content.find((part) => part.type === "text" && part.text)
?.text as string;
}
return null;
}
export function titleOfThread(thread: AgentThread) {
2026-01-15 23:40:21 +08:00
if (thread.values && "title" in thread.values) {
return thread.values.title;
2026-01-15 23:40:21 +08:00
}
return "Untitled";
}