mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-20 21:04:45 +08:00
refactor: refine folder structure and rename
This commit is contained in:
1
frontend/src/core/threads/index.ts
Normal file
1
frontend/src/core/threads/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./types";
|
||||
15
frontend/src/core/threads/types.ts
Normal file
15
frontend/src/core/threads/types.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { type BaseMessage } from "@langchain/core/messages";
|
||||
import type { Thread } from "@langchain/langgraph-sdk";
|
||||
|
||||
export interface AgentThreadState extends Record<string, unknown> {
|
||||
title: string;
|
||||
messages: BaseMessage[];
|
||||
}
|
||||
|
||||
export interface AgentThread extends Thread<AgentThreadState> {}
|
||||
|
||||
export interface AgentThreadContext extends Record<string, unknown> {
|
||||
thread_id: string;
|
||||
model: string;
|
||||
thinking_enabled: boolean;
|
||||
}
|
||||
27
frontend/src/core/threads/utils.ts
Normal file
27
frontend/src/core/threads/utils.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import type { BaseMessage } from "@langchain/core/messages";
|
||||
|
||||
import type { AgentThread } from "./types";
|
||||
|
||||
export function pathOfThread(thread: AgentThread, includeAssistantId = true) {
|
||||
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) {
|
||||
if (thread.values && "title" in thread.values) {
|
||||
return thread.values.title;
|
||||
}
|
||||
return "Untitled";
|
||||
}
|
||||
Reference in New Issue
Block a user