UNPKG

@langgraph-js/sdk

Version:

The UI SDK for LangGraph - seamlessly integrate your AI agents with frontend interfaces

57 lines (56 loc) 1.9 kB
import { RenderMessage } from "../LangGraphClient.js"; import { LangGraphClient } from "../LangGraphClient.js"; import { HumanInTheLoopDecision } from "../humanInTheLoop.js"; export type DeepPartial<T> = { [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P]; }; export declare class ToolRenderData<I, D> { message: RenderMessage; client: LangGraphClient; constructor(message: RenderMessage, client: LangGraphClient); private getToolActionRequestID; /** * 获取人机交互数据 * 直接使用 reviewConfig 获取可以显示的按钮 * actionRequest 获取当前工具的入参 */ getHumanInTheLoopData(): { actionRequestIndex: number; config: { id: string; value: { actionRequests: { id?: string; name: string; description: string; args: any; }[]; reviewConfigs: { actionName: string; allowedDecisions: ("approve" | "edit" | "reject" | "respond")[]; }[]; }; }; reviewConfig: { actionName: string; allowedDecisions: ("approve" | "edit" | "reject" | "respond")[]; }; actionRequest: { id?: string; name: string; description: string; args: any; }; result: HumanInTheLoopDecision; } | null; /** 发送恢复状态的数据 */ sendResumeData(response: HumanInTheLoopDecision): void; get state(): "idle" | "interrupted" | "done" | "loading"; get input(): I | null; get output(): string; getJSONOutput(): D; /** 如果解析失败,则返回 null */ getJSONOutputSafe(): D | null; getInputRepaired(): DeepPartial<I>; response(data: D): void; }