@langgraph-js/sdk
Version:
The UI SDK for LangGraph - seamlessly integrate your AI agents with frontend interfaces
98 lines (97 loc) • 4.54 kB
TypeScript
import { LangGraphClient, LangGraphClientConfig, RenderMessage, SendMessageOptions } from "../LangGraphClient.js";
import { AssistantGraph, Message, Thread } from "@langchain/langgraph-sdk";
import { UnionTool } from "../tool/createTool.js";
/**
* @zh 格式化日期对象为时间字符串。
* @en Formats a Date object into a time string.
*/
export declare const formatTime: (date: Date) => string;
/**
* @zh 格式化数字为带千位分隔符的字符串。
* @en Formats a number into a string with thousand separators.
*/
export declare const formatTokens: (tokens: number) => string;
/**
* @zh 获取消息内容的文本表示,处理不同类型的消息内容。
* @en Gets the text representation of message content, handling different types of message content.
*/
export declare const getMessageContent: (content: any) => string;
/**
* @zh 获取历史记录中 Thread 内容的文本表示。
* @en Gets the text representation of Thread content in history.
*/
export declare const getHistoryContent: (thread: Thread) => string | any[];
/**
* @zh 创建一个用于聊天界面的状态管理器 (store)。
* @en Creates a state manager (store) for the chat interface.
*/
export declare const createChatStore: (initClientName: string, config: LangGraphClientConfig, context?: {
showHistory?: boolean;
showGraph?: boolean;
onInit?: (client: LangGraphClient) => void;
}) => {
data: {
client: import("nanostores").PreinitializedWritableAtom<LangGraphClient | null> & object;
renderMessages: import("nanostores").PreinitializedWritableAtom<RenderMessage[]> & object;
userInput: import("nanostores").PreinitializedWritableAtom<string> & object;
loading: import("nanostores").PreinitializedWritableAtom<boolean> & object;
inChatError: import("nanostores").PreinitializedWritableAtom<string | null> & object;
currentAgent: import("nanostores").PreinitializedWritableAtom<string> & object;
collapsedTools: import("nanostores").PreinitializedWritableAtom<string[]> & object;
showHistory: import("nanostores").PreinitializedWritableAtom<boolean> & object;
historyList: import("nanostores").PreinitializedWritableAtom<Thread<{
messages: Message[];
}>[]> & object;
currentChatId: import("nanostores").PreinitializedWritableAtom<string | null> & object;
showGraph: import("nanostores").PreinitializedWritableAtom<boolean> & object;
graphVisualize: import("nanostores").PreinitializedWritableAtom<AssistantGraph | null> & object;
currentNodeName: import("nanostores").PreinitializedWritableAtom<string> & object;
tools: import("nanostores").PreinitializedWritableAtom<UnionTool<any, Object, any>[]> & object;
};
mutations: {
refreshTools: () => Promise<void>;
setTools(new_tools: UnionTool<any>[]): void;
isFELocking(): boolean | undefined;
initClient: () => Promise<LangGraphClient>;
sendMessage: (message?: Message[], extraData?: SendMessageOptions) => Promise<void>;
stopGeneration: () => void;
toggleToolCollapse: (toolId: string) => void;
toggleHistoryVisible: () => void;
refreshHistoryList: () => Promise<void>;
addToHistory: (thread: Thread<{
messages: Message[];
}>) => void;
/**
* @zh 设置用户输入内容。
* @en Sets the user input content.
*/
setUserInput(input: string): void;
/**
* @zh 设置当前的 Agent 并重新初始化客户端。
* @en Sets the current Agent and reinitializes the client.
*/
setCurrentAgent(agent: string): Promise<void>;
toggleGraphVisible(): void;
refreshGraph: () => Promise<void>;
/**
* @zh 创建一个新的聊天会话。
* @en Creates a new chat session.
*/
createNewChat(): void;
/**
* @zh 切换到指定的历史聊天会话。
* @en Switches to the specified historical chat session.
*/
toHistoryChat(thread: Thread<{
messages: Message[];
}>): void;
/**
* @zh 删除指定的历史聊天会话。
* @en Deletes the specified historical chat session.
*/
deleteHistoryChat(thread: Thread<{
messages: Message[];
}>): Promise<void>;
getToolUIRender: (tool_name: string) => ((message: RenderMessage) => Object) | null;
};
};