UNPKG

@langgraph-js/pro

Version:

The Pro SDK for LangGraph - seamlessly integrate your AI agents with frontend interfaces and build complex AI workflows

32 lines (31 loc) 1.47 kB
import { AnnotationRoot, StateDefinition } from "@langchain/langgraph"; /** * create state for langgraph, like python version * @example * export const GraphState = createState(createReactAgentAnnotation(), ModelState, SwarmState).build({ * current_plan: createDefaultAnnotation<Plan | null>(() => null), * title: createDefaultAnnotation<string>(() => ""), *}); */ export declare const createState: <T extends readonly AnnotationRoot<any>[]>(...parents: T) => { build: <D extends StateDefinition>(state?: D) => AnnotationRoot<UnionToIntersection<{ [K in keyof T]: T[K] extends AnnotationRoot<infer D_1 extends StateDefinition> ? D_1 : never; }[number]> & D>; }; type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never; /** * 创建一个默认值注解 * @example * const state = createState().build({ * current_plan: createDefaultAnnotation<Plan | null>(() => null), * }); */ export declare const createDefaultAnnotation: <T>(defaultValue: () => T) => import("@langchain/langgraph").BinaryOperatorAggregate<T, T>; /** * 创建一个数组注解 * @example * const state = createState().build({ * current_plan: createArrayAnnotation<Plan>(), * current_tags: createArrayAnnotation<Plan>(() => ['tag1', 'tag2']), * }); */ export declare const createArrayAnnotation: <T>(defaultValue?: T[] | (() => T[])) => import("@langchain/langgraph").BinaryOperatorAggregate<T[], T[]>; export {};