@langgraph-js/sdk
Version:
The UI SDK for LangGraph - seamlessly integrate your AI agents with frontend interfaces
103 lines (102 loc) • 6.04 kB
TypeScript
import { type JSX, Accessor } from "solid-js";
import { ILangGraphClient } from "@langgraph-js/pure-graph/dist/types.js";
import { PreinitializedWritableAtom, StoreValue } from "nanostores";
export declare const useChat: () => UnionStoreSolid<{
data: {
artifacts: PreinitializedWritableAtom<import("../index.js").ComposedArtifact[]> & object;
currentArtifactId: PreinitializedWritableAtom<[string, string] | null> & object;
showArtifact: PreinitializedWritableAtom<boolean> & object;
client: PreinitializedWritableAtom<import("../LangGraphClient.js").LangGraphClient<unknown> | null> & object;
history: PreinitializedWritableAtom<import("../History.js").History | null> & object;
sessions: PreinitializedWritableAtom<import("../History.js").SessionInfo[]> & object;
renderMessages: PreinitializedWritableAtom<import("../LangGraphClient.js").RenderMessage[]> & object;
userInput: PreinitializedWritableAtom<string> & object;
loading: PreinitializedWritableAtom<boolean> & object;
inChatError: PreinitializedWritableAtom<string | null> & object;
currentAgent: PreinitializedWritableAtom<string> & object;
currentChatId: PreinitializedWritableAtom<string | null> & object;
currentNodeName: PreinitializedWritableAtom<string> & object;
currentStatus: PreinitializedWritableAtom<string> & object;
interruptData: PreinitializedWritableAtom<import("../humanInTheLoop.js").InterruptData | null> & object;
isInterrupted: PreinitializedWritableAtom<boolean> & object;
tools: PreinitializedWritableAtom<import("../index.js").UnionTool<any, Object, any>[]> & object;
collapsedTools: PreinitializedWritableAtom<string[]> & object;
showGraph: PreinitializedWritableAtom<boolean> & object;
graphVisualize: PreinitializedWritableAtom<import("@langchain/langgraph-sdk").AssistantGraph | null> & object;
showHistory: PreinitializedWritableAtom<boolean> & object;
historyList: PreinitializedWritableAtom<import("@langchain/langgraph-sdk").Thread<{
messages: import("@langchain/langgraph-sdk").Message[];
}>[]> & object;
};
mutations: {
setCurrentArtifactById: (id: string, tool_id: string) => void;
setShowArtifact: (show: boolean) => void;
initClient: () => Promise<import("../History.js").History>;
getClient: () => import("../LangGraphClient.js").LangGraphClient<unknown> | null;
getHistory: () => import("../History.js").History | null;
activateSession: (sessionId: string, mustResetStream?: boolean) => Promise<void>;
createNewSession: () => Promise<void>;
refreshSessionList: () => Promise<void>;
refreshHistoryList: () => Promise<void>;
sendMessage: (message?: import("@langchain/langgraph-sdk").Message[], extraData?: import("../LangGraphClient.js").SendMessageOptions, withoutCheck?: boolean, isResume?: boolean) => Promise<void>;
stopGeneration: () => void;
setUserInput: (input: string) => void;
revertChatTo(messageId: string, resend?: boolean, sendOptions?: import("../LangGraphClient.js").SendMessageOptions & import("../time-travel/index.js").RevertChatToOptions): Promise<void>;
refreshTools: () => Promise<void>;
setTools(new_tools: import("../index.js").UnionTool<any>[]): void;
toggleToolCollapse: (toolId: string) => void;
getToolUIRender: (tool_name: string) => ((message: import("../LangGraphClient.js").RenderMessage) => Object) | null;
isFELocking: () => boolean | undefined;
toggleHistoryVisible: () => void;
toggleGraphVisible(): void;
refreshGraph: () => Promise<void>;
setCurrentAgent(agent: string): Promise<import("../History.js").History>;
resumeFromInterrupt(data: any): Promise<void>;
addToHistory: (thread: import("@langchain/langgraph-sdk").Thread<{
messages: import("@langchain/langgraph-sdk").Message[];
}>) => void;
createNewChat: () => Promise<void>;
toHistoryChat: (thread: import("@langchain/langgraph-sdk").Thread<{
messages: import("@langchain/langgraph-sdk").Message[];
}>) => Promise<void>;
deleteHistoryChat(thread: import("@langchain/langgraph-sdk").Thread<{
messages: import("@langchain/langgraph-sdk").Message[];
}>): Promise<void>;
};
}>;
interface ChatProviderProps {
children: JSX.Element;
defaultAgent?: string;
apiUrl?: string;
defaultHeaders?: Record<string, string>;
withCredentials?: boolean;
fetch?: typeof fetch;
showHistory?: boolean;
showGraph?: boolean;
fallbackToAvailableAssistants?: boolean;
/** 初始化时是否自动激活最近的历史会话(默认 false,创建新会话) */
autoRestoreLastSession?: boolean;
onInitError?: (error: any, currentAgent: string) => void;
client?: ILangGraphClient;
legacyMode?: boolean;
}
/**
* @zh UnionStore 类型用于合并 store 的 data 和 mutations,使其可以直接访问。
* @en The UnionStore type is used to merge the data and mutations of a store, allowing direct access.
*/
export type UnionStoreSolid<T extends {
data: Record<string, PreinitializedWritableAtom<any>>;
mutations: Record<string, any>;
}> = {
[k in keyof T["data"]]: Accessor<StoreValue<T["data"][k]>>;
} & T["mutations"];
/**
* @zh useUnionStore Hook 用于将 nanostores 的 store 结构转换为更易于在 UI 组件中使用的扁平结构。
* @en The useUnionStore Hook is used to transform the nanostores store structure into a flatter structure that is easier to use in UI components.
*/
export declare const useUnionStoreSolid: <T extends {
data: Record<string, any>;
mutations: Record<string, any>;
}>(store: T, useStore: (store: PreinitializedWritableAtom<any>) => Accessor<any>) => UnionStoreSolid<T>;
export declare const ChatProvider: (props: ChatProviderProps) => JSX.Element;
export {};