langchain 1.0.0-alpha.4 → 1.0.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/RunnableCallable.cjs +5 -0
- package/dist/agents/RunnableCallable.cjs.map +1 -1
- package/dist/agents/RunnableCallable.d.cts +2 -0
- package/dist/agents/RunnableCallable.d.cts.map +1 -1
- package/dist/agents/RunnableCallable.d.ts +2 -0
- package/dist/agents/RunnableCallable.d.ts.map +1 -1
- package/dist/agents/RunnableCallable.js +5 -0
- package/dist/agents/RunnableCallable.js.map +1 -1
- package/dist/agents/annotation.d.cts +1 -1
- package/dist/agents/createAgent.cjs +10 -0
- package/dist/agents/createAgent.cjs.map +1 -0
- package/dist/agents/createAgent.js +10 -0
- package/dist/agents/createAgent.js.map +1 -0
- package/dist/agents/index.cjs +23 -4
- package/dist/agents/index.cjs.map +1 -1
- package/dist/agents/index.d.cts +83 -20
- package/dist/agents/index.d.cts.map +1 -1
- package/dist/agents/index.d.ts +83 -20
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +23 -4
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/middlewareAgent/ReactAgent.cjs +255 -0
- package/dist/agents/middlewareAgent/ReactAgent.cjs.map +1 -0
- package/dist/agents/middlewareAgent/ReactAgent.d.cts +68 -0
- package/dist/agents/middlewareAgent/ReactAgent.d.cts.map +1 -0
- package/dist/agents/middlewareAgent/ReactAgent.d.ts +68 -0
- package/dist/agents/middlewareAgent/ReactAgent.d.ts.map +1 -0
- package/dist/agents/middlewareAgent/ReactAgent.js +254 -0
- package/dist/agents/middlewareAgent/ReactAgent.js.map +1 -0
- package/dist/agents/middlewareAgent/annotation.cjs +39 -0
- package/dist/agents/middlewareAgent/annotation.cjs.map +1 -0
- package/dist/agents/middlewareAgent/annotation.js +38 -0
- package/dist/agents/middlewareAgent/annotation.js.map +1 -0
- package/dist/agents/middlewareAgent/index.cjs +11 -0
- package/dist/agents/middlewareAgent/index.cjs.map +1 -0
- package/dist/agents/middlewareAgent/index.js +11 -0
- package/dist/agents/middlewareAgent/index.js.map +1 -0
- package/dist/agents/middlewareAgent/middleware.cjs +47 -0
- package/dist/agents/middlewareAgent/middleware.cjs.map +1 -0
- package/dist/agents/middlewareAgent/middleware.d.cts +46 -0
- package/dist/agents/middlewareAgent/middleware.d.cts.map +1 -0
- package/dist/agents/middlewareAgent/middleware.d.ts +46 -0
- package/dist/agents/middlewareAgent/middleware.d.ts.map +1 -0
- package/dist/agents/middlewareAgent/middleware.js +46 -0
- package/dist/agents/middlewareAgent/middleware.js.map +1 -0
- package/dist/agents/middlewareAgent/middlewares/hitl.cjs +235 -0
- package/dist/agents/middlewareAgent/middlewares/hitl.cjs.map +1 -0
- package/dist/agents/middlewareAgent/middlewares/hitl.d.cts +199 -0
- package/dist/agents/middlewareAgent/middlewares/hitl.d.cts.map +1 -0
- package/dist/agents/middlewareAgent/middlewares/hitl.d.ts +199 -0
- package/dist/agents/middlewareAgent/middlewares/hitl.d.ts.map +1 -0
- package/dist/agents/middlewareAgent/middlewares/hitl.js +234 -0
- package/dist/agents/middlewareAgent/middlewares/hitl.js.map +1 -0
- package/dist/agents/middlewareAgent/middlewares/index.cjs +8 -0
- package/dist/agents/middlewareAgent/middlewares/index.d.cts +4 -0
- package/dist/agents/middlewareAgent/middlewares/index.d.ts +4 -0
- package/dist/agents/middlewareAgent/middlewares/index.js +5 -0
- package/dist/agents/middlewareAgent/middlewares/promptCaching.cjs +153 -0
- package/dist/agents/middlewareAgent/middlewares/promptCaching.cjs.map +1 -0
- package/dist/agents/middlewareAgent/middlewares/promptCaching.d.cts +152 -0
- package/dist/agents/middlewareAgent/middlewares/promptCaching.d.cts.map +1 -0
- package/dist/agents/middlewareAgent/middlewares/promptCaching.d.ts +152 -0
- package/dist/agents/middlewareAgent/middlewares/promptCaching.d.ts.map +1 -0
- package/dist/agents/middlewareAgent/middlewares/promptCaching.js +152 -0
- package/dist/agents/middlewareAgent/middlewares/promptCaching.js.map +1 -0
- package/dist/agents/middlewareAgent/middlewares/summarization.cjs +262 -0
- package/dist/agents/middlewareAgent/middlewares/summarization.cjs.map +1 -0
- package/dist/agents/middlewareAgent/middlewares/summarization.d.cts +89 -0
- package/dist/agents/middlewareAgent/middlewares/summarization.d.cts.map +1 -0
- package/dist/agents/middlewareAgent/middlewares/summarization.d.ts +89 -0
- package/dist/agents/middlewareAgent/middlewares/summarization.d.ts.map +1 -0
- package/dist/agents/middlewareAgent/middlewares/summarization.js +260 -0
- package/dist/agents/middlewareAgent/middlewares/summarization.js.map +1 -0
- package/dist/agents/middlewareAgent/nodes/AfterModalNode.cjs +29 -0
- package/dist/agents/middlewareAgent/nodes/AfterModalNode.cjs.map +1 -0
- package/dist/agents/middlewareAgent/nodes/AfterModalNode.js +29 -0
- package/dist/agents/middlewareAgent/nodes/AfterModalNode.js.map +1 -0
- package/dist/agents/middlewareAgent/nodes/AgentNode.cjs +332 -0
- package/dist/agents/middlewareAgent/nodes/AgentNode.cjs.map +1 -0
- package/dist/agents/middlewareAgent/nodes/AgentNode.js +331 -0
- package/dist/agents/middlewareAgent/nodes/AgentNode.js.map +1 -0
- package/dist/agents/middlewareAgent/nodes/BeforeModalNode.cjs +27 -0
- package/dist/agents/middlewareAgent/nodes/BeforeModalNode.cjs.map +1 -0
- package/dist/agents/middlewareAgent/nodes/BeforeModalNode.js +27 -0
- package/dist/agents/middlewareAgent/nodes/BeforeModalNode.js.map +1 -0
- package/dist/agents/middlewareAgent/nodes/middleware.cjs +73 -0
- package/dist/agents/middlewareAgent/nodes/middleware.cjs.map +1 -0
- package/dist/agents/middlewareAgent/nodes/middleware.js +73 -0
- package/dist/agents/middlewareAgent/nodes/middleware.js.map +1 -0
- package/dist/agents/middlewareAgent/nodes/utils.cjs +74 -0
- package/dist/agents/middlewareAgent/nodes/utils.cjs.map +1 -0
- package/dist/agents/middlewareAgent/nodes/utils.js +70 -0
- package/dist/agents/middlewareAgent/nodes/utils.js.map +1 -0
- package/dist/agents/middlewareAgent/types.d.cts +393 -0
- package/dist/agents/middlewareAgent/types.d.cts.map +1 -0
- package/dist/agents/middlewareAgent/types.d.ts +393 -0
- package/dist/agents/middlewareAgent/types.d.ts.map +1 -0
- package/dist/agents/nodes/ToolNode.d.cts +3 -3
- package/dist/agents/types.d.cts +4 -4
- package/dist/chains/api/api_chain.d.cts +1 -1
- package/dist/chains/base.d.cts +1 -1
- package/dist/chains/combine_docs_chain.d.cts +1 -1
- package/dist/chains/combine_documents/stuff.d.cts +1 -1
- package/dist/chains/conversational_retrieval_chain.d.cts +1 -1
- package/dist/chains/graph_qa/cypher.d.cts +1 -1
- package/dist/chains/history_aware_retriever.d.cts +2 -2
- package/dist/chains/llm_chain.d.cts +3 -3
- package/dist/chains/openai_functions/base.d.cts +3 -3
- package/dist/chains/openai_functions/openapi.d.cts +1 -1
- package/dist/chains/openai_functions/structured_output.d.cts +3 -3
- package/dist/chains/openai_functions/tagging.d.cts +1 -1
- package/dist/chains/query_constructor/index.cjs +1 -1
- package/dist/chains/query_constructor/index.d.cts +2 -2
- package/dist/chains/query_constructor/index.d.ts +1 -1
- package/dist/chains/query_constructor/index.js +1 -1
- package/dist/chains/question_answering/load.d.ts +2 -2
- package/dist/chains/question_answering/load.d.ts.map +1 -1
- package/dist/chains/retrieval.d.cts +1 -1
- package/dist/chains/router/llm_router.d.cts +1 -1
- package/dist/chains/router/multi_prompt.cjs +1 -1
- package/dist/chains/router/multi_prompt.js +1 -1
- package/dist/chains/router/multi_retrieval_qa.cjs +1 -1
- package/dist/chains/router/multi_retrieval_qa.js +1 -1
- package/dist/chains/sql_db/sql_db_chain.d.cts +2 -2
- package/dist/chains/summarization/load.d.ts +2 -2
- package/dist/chains/summarization/load.d.ts.map +1 -1
- package/dist/chat_models/universal.d.cts +3 -3
- package/dist/evaluation/agents/trajectory.d.cts +3 -3
- package/dist/evaluation/agents/trajectory.d.ts.map +1 -1
- package/dist/evaluation/comparison/pairwise.d.cts +1 -1
- package/dist/evaluation/comparison/pairwise.d.cts.map +1 -1
- package/dist/evaluation/comparison/pairwise.d.ts.map +1 -1
- package/dist/evaluation/criteria/criteria.d.cts +1 -1
- package/dist/evaluation/criteria/criteria.d.cts.map +1 -1
- package/dist/evaluation/criteria/criteria.d.ts.map +1 -1
- package/dist/evaluation/qa/eval_chain.d.cts +1 -1
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -4
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/load/import_map.cjs +1 -1
- package/dist/load/import_map.js +1 -1
- package/dist/memory/summary.d.cts +1 -1
- package/dist/output_parsers/fix.d.cts +1 -1
- package/dist/output_parsers/http_response.d.cts +1 -1
- package/dist/output_parsers/structured.cjs +1 -1
- package/dist/output_parsers/structured.d.cts +2 -2
- package/dist/output_parsers/structured.d.ts +1 -1
- package/dist/output_parsers/structured.js +1 -1
- package/dist/tools/fs.d.cts +1 -1
- package/dist/tools/json.d.cts +1 -1
- package/dist/tools/retriever.d.cts +1 -1
- package/dist/tools/vectorstore.d.cts +1 -1
- package/dist/tools/webbrowser.d.cts +1 -1
- package/package.json +17 -6
|
@@ -10,6 +10,7 @@ var RunnableCallable = class extends __langchain_core_runnables.Runnable {
|
|
|
10
10
|
config;
|
|
11
11
|
trace = true;
|
|
12
12
|
recurse = true;
|
|
13
|
+
#state;
|
|
13
14
|
constructor(fields) {
|
|
14
15
|
super();
|
|
15
16
|
this.name = fields.name ?? fields.func.name;
|
|
@@ -17,10 +18,14 @@ var RunnableCallable = class extends __langchain_core_runnables.Runnable {
|
|
|
17
18
|
this.config = fields.tags ? { tags: fields.tags } : void 0;
|
|
18
19
|
this.recurse = fields.recurse ?? this.recurse;
|
|
19
20
|
}
|
|
21
|
+
getState() {
|
|
22
|
+
return this.#state;
|
|
23
|
+
}
|
|
20
24
|
async invoke(input, options) {
|
|
21
25
|
const mergedConfig = (0, __langchain_core_runnables.mergeConfigs)(this.config, options);
|
|
22
26
|
const returnValue = await __langchain_core_singletons.AsyncLocalStorageProviderSingleton.runWithConfig(mergedConfig, async () => this.func(input, mergedConfig));
|
|
23
27
|
if (__langchain_core_runnables.Runnable.isRunnable(returnValue) && this.recurse) return await __langchain_core_singletons.AsyncLocalStorageProviderSingleton.runWithConfig(mergedConfig, async () => returnValue.invoke(input, mergedConfig));
|
|
28
|
+
this.#state = returnValue;
|
|
24
29
|
return returnValue;
|
|
25
30
|
}
|
|
26
31
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RunnableCallable.cjs","names":["Runnable","fields: RunnableCallableArgs<I, O>","input: I","options?: Partial<RunnableConfig> | undefined","AsyncLocalStorageProviderSingleton"],"sources":["../../src/agents/RunnableCallable.ts"],"sourcesContent":["import {\n mergeConfigs,\n Runnable,\n RunnableConfig,\n} from \"@langchain/core/runnables\";\nimport { AsyncLocalStorageProviderSingleton } from \"@langchain/core/singletons\";\n\nexport interface RunnableCallableArgs<I, O> {\n /**\n * The name of the runnable.\n */\n name?: string;\n /**\n * The function to call.\n */\n func: (...args: I[]) => O | Promise<O>;\n /**\n * The tags to add to the runnable.\n */\n tags?: string[];\n /**\n * Whether to recurse the runnable.\n */\n recurse?: boolean;\n}\n\nexport class RunnableCallable<I = unknown, O = unknown> extends Runnable<I, O> {\n lc_namespace: string[] = [\"langgraph\"];\n\n func: RunnableCallableArgs<I, O>[\"func\"];\n\n tags?: RunnableCallableArgs<I, O>[\"tags\"];\n\n config?: RunnableConfig;\n\n trace = true;\n\n recurse = true;\n\n constructor(fields: RunnableCallableArgs<I, O>) {\n super();\n this.name = fields.name ?? fields.func.name;\n this.func = fields.func;\n this.config = fields.tags ? { tags: fields.tags } : undefined;\n this.recurse = fields.recurse ?? this.recurse;\n }\n\n async invoke(\n input: I,\n options?: Partial<RunnableConfig> | undefined\n ): Promise<O> {\n const mergedConfig = mergeConfigs(this.config, options);\n\n const returnValue = await AsyncLocalStorageProviderSingleton.runWithConfig(\n mergedConfig,\n async () => this.func(input, mergedConfig as I)\n );\n\n if (Runnable.isRunnable(returnValue) && this.recurse) {\n return await AsyncLocalStorageProviderSingleton.runWithConfig(\n mergedConfig,\n async () => (returnValue as Runnable<I, O>).invoke(input, mergedConfig)\n );\n }\n\n return returnValue;\n }\n}\n"],"mappings":";;;;;AA0BA,IAAa,mBAAb,cAAgEA,oCAAe;CAC7E,eAAyB,CAAC,WAAY;CAEtC;CAEA;CAEA;CAEA,QAAQ;CAER,UAAU;CAEV,YAAYC,QAAoC;EAC9C,OAAO;EACP,KAAK,OAAO,OAAO,QAAQ,OAAO,KAAK;EACvC,KAAK,OAAO,OAAO;EACnB,KAAK,SAAS,OAAO,OAAO,EAAE,MAAM,OAAO,KAAM,IAAG;EACpD,KAAK,UAAU,OAAO,WAAW,KAAK;CACvC;CAED,MAAM,OACJC,OACAC,SACY;EACZ,MAAM,4DAA4B,KAAK,QAAQ,QAAQ;EAEvD,MAAM,cAAc,MAAMC,+DAAmC,cAC3D,cACA,YAAY,KAAK,KAAK,OAAO,aAAkB,CAChD;AAED,
|
|
1
|
+
{"version":3,"file":"RunnableCallable.cjs","names":["Runnable","fields: RunnableCallableArgs<I, O>","#state","input: I","options?: Partial<RunnableConfig> | undefined","AsyncLocalStorageProviderSingleton"],"sources":["../../src/agents/RunnableCallable.ts"],"sourcesContent":["import {\n mergeConfigs,\n Runnable,\n RunnableConfig,\n} from \"@langchain/core/runnables\";\nimport { AsyncLocalStorageProviderSingleton } from \"@langchain/core/singletons\";\n\nexport interface RunnableCallableArgs<I, O> {\n /**\n * The name of the runnable.\n */\n name?: string;\n /**\n * The function to call.\n */\n func: (...args: I[]) => O | Promise<O>;\n /**\n * The tags to add to the runnable.\n */\n tags?: string[];\n /**\n * Whether to recurse the runnable.\n */\n recurse?: boolean;\n}\n\nexport class RunnableCallable<I = unknown, O = unknown> extends Runnable<I, O> {\n lc_namespace: string[] = [\"langgraph\"];\n\n func: RunnableCallableArgs<I, O>[\"func\"];\n\n tags?: RunnableCallableArgs<I, O>[\"tags\"];\n\n config?: RunnableConfig;\n\n trace = true;\n\n recurse = true;\n\n #state: Awaited<O>;\n\n constructor(fields: RunnableCallableArgs<I, O>) {\n super();\n this.name = fields.name ?? fields.func.name;\n this.func = fields.func;\n this.config = fields.tags ? { tags: fields.tags } : undefined;\n this.recurse = fields.recurse ?? this.recurse;\n }\n\n getState(): Awaited<O> {\n return this.#state;\n }\n\n async invoke(\n input: I,\n options?: Partial<RunnableConfig> | undefined\n ): Promise<O> {\n const mergedConfig = mergeConfigs(this.config, options);\n\n const returnValue = await AsyncLocalStorageProviderSingleton.runWithConfig(\n mergedConfig,\n async () => this.func(input, mergedConfig as I)\n );\n\n if (Runnable.isRunnable(returnValue) && this.recurse) {\n return await AsyncLocalStorageProviderSingleton.runWithConfig(\n mergedConfig,\n async () => (returnValue as Runnable<I, O>).invoke(input, mergedConfig)\n );\n }\n\n this.#state = returnValue;\n return returnValue;\n }\n}\n"],"mappings":";;;;;AA0BA,IAAa,mBAAb,cAAgEA,oCAAe;CAC7E,eAAyB,CAAC,WAAY;CAEtC;CAEA;CAEA;CAEA,QAAQ;CAER,UAAU;CAEV;CAEA,YAAYC,QAAoC;EAC9C,OAAO;EACP,KAAK,OAAO,OAAO,QAAQ,OAAO,KAAK;EACvC,KAAK,OAAO,OAAO;EACnB,KAAK,SAAS,OAAO,OAAO,EAAE,MAAM,OAAO,KAAM,IAAG;EACpD,KAAK,UAAU,OAAO,WAAW,KAAK;CACvC;CAED,WAAuB;AACrB,SAAO,KAAKC;CACb;CAED,MAAM,OACJC,OACAC,SACY;EACZ,MAAM,4DAA4B,KAAK,QAAQ,QAAQ;EAEvD,MAAM,cAAc,MAAMC,+DAAmC,cAC3D,cACA,YAAY,KAAK,KAAK,OAAO,aAAkB,CAChD;AAED,MAAIL,oCAAS,WAAW,YAAY,IAAI,KAAK,QAC3C,QAAO,MAAMK,+DAAmC,cAC9C,cACA,YAAa,YAA+B,OAAO,OAAO,aAAa,CACxE;EAGH,KAAKH,SAAS;AACd,SAAO;CACR;AACF"}
|
|
@@ -20,6 +20,7 @@ interface RunnableCallableArgs<I, O> {
|
|
|
20
20
|
recurse?: boolean;
|
|
21
21
|
}
|
|
22
22
|
declare class RunnableCallable<I = unknown, O = unknown> extends Runnable<I, O> {
|
|
23
|
+
#private;
|
|
23
24
|
lc_namespace: string[];
|
|
24
25
|
func: RunnableCallableArgs<I, O>["func"];
|
|
25
26
|
tags?: RunnableCallableArgs<I, O>["tags"];
|
|
@@ -27,6 +28,7 @@ declare class RunnableCallable<I = unknown, O = unknown> extends Runnable<I, O>
|
|
|
27
28
|
trace: boolean;
|
|
28
29
|
recurse: boolean;
|
|
29
30
|
constructor(fields: RunnableCallableArgs<I, O>);
|
|
31
|
+
getState(): Awaited<O>;
|
|
30
32
|
invoke(input: I, options?: Partial<RunnableConfig> | undefined): Promise<O>;
|
|
31
33
|
}
|
|
32
34
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RunnableCallable.d.cts","names":["Runnable","RunnableConfig","RunnableCallableArgs","I","O","Promise","RunnableCallable","Partial"],"sources":["../../src/agents/RunnableCallable.d.ts"],"sourcesContent":["import { Runnable, RunnableConfig } from \"@langchain/core/runnables\";\nexport interface RunnableCallableArgs<I, O> {\n /**\n * The name of the runnable.\n */\n name?: string;\n /**\n * The function to call.\n */\n func: (...args: I[]) => O | Promise<O>;\n /**\n * The tags to add to the runnable.\n */\n tags?: string[];\n /**\n * Whether to recurse the runnable.\n */\n recurse?: boolean;\n}\nexport declare class RunnableCallable<I = unknown, O = unknown> extends Runnable<I, O> {\n lc_namespace: string[];\n func: RunnableCallableArgs<I, O>[\"func\"];\n tags?: RunnableCallableArgs<I, O>[\"tags\"];\n config?: RunnableConfig;\n trace: boolean;\n recurse: boolean;\n constructor(fields: RunnableCallableArgs<I, O>);\n invoke(input: I, options?: Partial<RunnableConfig> | undefined): Promise<O>;\n}\n"],"mappings":";;;UACiBE;;AAAjB;;EAAqC,IAQjBC,CAAAA,EAAAA,MAAAA;EAAC;;;EAAkB,IAAA,EAAA,CAAA,GAAA,IAAA,EAAnBA,CAAmB,EAAA,EAAA,GAAXC,CAAW,GAAPC,OAAO,CAACD,CAAD,CAAA;EAUlBE;;;EAA6D,IAAEF,CAAAA,EAAAA,MAAAA,EAAAA;EAAC;;;
|
|
1
|
+
{"version":3,"file":"RunnableCallable.d.cts","names":["Runnable","RunnableConfig","RunnableCallableArgs","I","O","Promise","RunnableCallable","Awaited","Partial"],"sources":["../../src/agents/RunnableCallable.d.ts"],"sourcesContent":["import { Runnable, RunnableConfig } from \"@langchain/core/runnables\";\nexport interface RunnableCallableArgs<I, O> {\n /**\n * The name of the runnable.\n */\n name?: string;\n /**\n * The function to call.\n */\n func: (...args: I[]) => O | Promise<O>;\n /**\n * The tags to add to the runnable.\n */\n tags?: string[];\n /**\n * Whether to recurse the runnable.\n */\n recurse?: boolean;\n}\nexport declare class RunnableCallable<I = unknown, O = unknown> extends Runnable<I, O> {\n #private;\n lc_namespace: string[];\n func: RunnableCallableArgs<I, O>[\"func\"];\n tags?: RunnableCallableArgs<I, O>[\"tags\"];\n config?: RunnableConfig;\n trace: boolean;\n recurse: boolean;\n constructor(fields: RunnableCallableArgs<I, O>);\n getState(): Awaited<O>;\n invoke(input: I, options?: Partial<RunnableConfig> | undefined): Promise<O>;\n}\n"],"mappings":";;;UACiBE;;AAAjB;;EAAqC,IAQjBC,CAAAA,EAAAA,MAAAA;EAAC;;;EAAkB,IAAA,EAAA,CAAA,GAAA,IAAA,EAAnBA,CAAmB,EAAA,EAAA,GAAXC,CAAW,GAAPC,OAAO,CAACD,CAAD,CAAA;EAUlBE;;;EAA6D,IAAEF,CAAAA,EAAAA,MAAAA,EAAAA;EAAC;;;EAGvD,OACED,CAAAA,EAAAA,OAAAA;;AAArBD,cAJUI,gBAIVJ,CAAAA,IAAAA,OAAAA,EAAAA,IAAAA,OAAAA,CAAAA,SAJ6DF,QAI7DE,CAJsEC,CAItED,EAJyEE,CAIzEF,CAAAA,CAAAA;EAAoB,CAAA,OAClBD;EAAc,YAGkBE,EAAAA,MAAAA,EAAAA;EAAC,IAAEC,EALtCF,oBAKsCE,CALjBD,CAKiBC,EALdA,CAKcA,CAAAA,CAAAA,MAAAA,CAAAA;EAAC,IAAzBF,CAAAA,EAJbA,oBAIaA,CAJQC,CAIRD,EAJWE,CAIXF,CAAAA,CAAAA,MAAAA,CAAAA;EAAoB,MACpBE,CAAAA,EAJXH,cAIWG;EAAC,KAATG,EAAAA,OAAAA;EAAO,OACLJ,EAAAA,OAAAA;EAAC,WAAoBF,CAAAA,MAAAA,EAFfC,oBAEeD,CAFME,CAENF,EAFSG,CAETH,CAAAA;EAAc,QAAtBO,CAAAA,CAAAA,EADfD,OACeC,CADPJ,CACOI,CAAAA;EAAO,MAAuCJ,CAAAA,KAAAA,EAA3DD,CAA2DC,EAAAA,OAAAA,CAAAA,EAA9CI,OAA8CJ,CAAtCH,cAAsCG,CAAAA,GAAAA,SAAAA,CAAAA,EAARC,OAAQD,CAAAA,CAAAA,CAAAA"}
|
|
@@ -20,6 +20,7 @@ interface RunnableCallableArgs<I, O> {
|
|
|
20
20
|
recurse?: boolean;
|
|
21
21
|
}
|
|
22
22
|
declare class RunnableCallable<I = unknown, O = unknown> extends Runnable<I, O> {
|
|
23
|
+
#private;
|
|
23
24
|
lc_namespace: string[];
|
|
24
25
|
func: RunnableCallableArgs<I, O>["func"];
|
|
25
26
|
tags?: RunnableCallableArgs<I, O>["tags"];
|
|
@@ -27,6 +28,7 @@ declare class RunnableCallable<I = unknown, O = unknown> extends Runnable<I, O>
|
|
|
27
28
|
trace: boolean;
|
|
28
29
|
recurse: boolean;
|
|
29
30
|
constructor(fields: RunnableCallableArgs<I, O>);
|
|
31
|
+
getState(): Awaited<O>;
|
|
30
32
|
invoke(input: I, options?: Partial<RunnableConfig> | undefined): Promise<O>;
|
|
31
33
|
}
|
|
32
34
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RunnableCallable.d.ts","names":["Runnable","RunnableConfig","RunnableCallableArgs","I","O","Promise","RunnableCallable","Partial"],"sources":["../../src/agents/RunnableCallable.d.ts"],"sourcesContent":["import { Runnable, RunnableConfig } from \"@langchain/core/runnables\";\nexport interface RunnableCallableArgs<I, O> {\n /**\n * The name of the runnable.\n */\n name?: string;\n /**\n * The function to call.\n */\n func: (...args: I[]) => O | Promise<O>;\n /**\n * The tags to add to the runnable.\n */\n tags?: string[];\n /**\n * Whether to recurse the runnable.\n */\n recurse?: boolean;\n}\nexport declare class RunnableCallable<I = unknown, O = unknown> extends Runnable<I, O> {\n lc_namespace: string[];\n func: RunnableCallableArgs<I, O>[\"func\"];\n tags?: RunnableCallableArgs<I, O>[\"tags\"];\n config?: RunnableConfig;\n trace: boolean;\n recurse: boolean;\n constructor(fields: RunnableCallableArgs<I, O>);\n invoke(input: I, options?: Partial<RunnableConfig> | undefined): Promise<O>;\n}\n"],"mappings":";;;UACiBE;;AAAjB;;EAAqC,IAQjBC,CAAAA,EAAAA,MAAAA;EAAC;;;EAAkB,IAAA,EAAA,CAAA,GAAA,IAAA,EAAnBA,CAAmB,EAAA,EAAA,GAAXC,CAAW,GAAPC,OAAO,CAACD,CAAD,CAAA;EAUlBE;;;EAA6D,IAAEF,CAAAA,EAAAA,MAAAA,EAAAA;EAAC;;;
|
|
1
|
+
{"version":3,"file":"RunnableCallable.d.ts","names":["Runnable","RunnableConfig","RunnableCallableArgs","I","O","Promise","RunnableCallable","Awaited","Partial"],"sources":["../../src/agents/RunnableCallable.d.ts"],"sourcesContent":["import { Runnable, RunnableConfig } from \"@langchain/core/runnables\";\nexport interface RunnableCallableArgs<I, O> {\n /**\n * The name of the runnable.\n */\n name?: string;\n /**\n * The function to call.\n */\n func: (...args: I[]) => O | Promise<O>;\n /**\n * The tags to add to the runnable.\n */\n tags?: string[];\n /**\n * Whether to recurse the runnable.\n */\n recurse?: boolean;\n}\nexport declare class RunnableCallable<I = unknown, O = unknown> extends Runnable<I, O> {\n #private;\n lc_namespace: string[];\n func: RunnableCallableArgs<I, O>[\"func\"];\n tags?: RunnableCallableArgs<I, O>[\"tags\"];\n config?: RunnableConfig;\n trace: boolean;\n recurse: boolean;\n constructor(fields: RunnableCallableArgs<I, O>);\n getState(): Awaited<O>;\n invoke(input: I, options?: Partial<RunnableConfig> | undefined): Promise<O>;\n}\n"],"mappings":";;;UACiBE;;AAAjB;;EAAqC,IAQjBC,CAAAA,EAAAA,MAAAA;EAAC;;;EAAkB,IAAA,EAAA,CAAA,GAAA,IAAA,EAAnBA,CAAmB,EAAA,EAAA,GAAXC,CAAW,GAAPC,OAAO,CAACD,CAAD,CAAA;EAUlBE;;;EAA6D,IAAEF,CAAAA,EAAAA,MAAAA,EAAAA;EAAC;;;EAGvD,OACED,CAAAA,EAAAA,OAAAA;;AAArBD,cAJUI,gBAIVJ,CAAAA,IAAAA,OAAAA,EAAAA,IAAAA,OAAAA,CAAAA,SAJ6DF,QAI7DE,CAJsEC,CAItED,EAJyEE,CAIzEF,CAAAA,CAAAA;EAAoB,CAAA,OAClBD;EAAc,YAGkBE,EAAAA,MAAAA,EAAAA;EAAC,IAAEC,EALtCF,oBAKsCE,CALjBD,CAKiBC,EALdA,CAKcA,CAAAA,CAAAA,MAAAA,CAAAA;EAAC,IAAzBF,CAAAA,EAJbA,oBAIaA,CAJQC,CAIRD,EAJWE,CAIXF,CAAAA,CAAAA,MAAAA,CAAAA;EAAoB,MACpBE,CAAAA,EAJXH,cAIWG;EAAC,KAATG,EAAAA,OAAAA;EAAO,OACLJ,EAAAA,OAAAA;EAAC,WAAoBF,CAAAA,MAAAA,EAFfC,oBAEeD,CAFME,CAENF,EAFSG,CAETH,CAAAA;EAAc,QAAtBO,CAAAA,CAAAA,EADfD,OACeC,CADPJ,CACOI,CAAAA;EAAO,MAAuCJ,CAAAA,KAAAA,EAA3DD,CAA2DC,EAAAA,OAAAA,CAAAA,EAA9CI,OAA8CJ,CAAtCH,cAAsCG,CAAAA,GAAAA,SAAAA,CAAAA,EAARC,OAAQD,CAAAA,CAAAA,CAAAA"}
|
|
@@ -9,6 +9,7 @@ var RunnableCallable = class extends Runnable {
|
|
|
9
9
|
config;
|
|
10
10
|
trace = true;
|
|
11
11
|
recurse = true;
|
|
12
|
+
#state;
|
|
12
13
|
constructor(fields) {
|
|
13
14
|
super();
|
|
14
15
|
this.name = fields.name ?? fields.func.name;
|
|
@@ -16,10 +17,14 @@ var RunnableCallable = class extends Runnable {
|
|
|
16
17
|
this.config = fields.tags ? { tags: fields.tags } : void 0;
|
|
17
18
|
this.recurse = fields.recurse ?? this.recurse;
|
|
18
19
|
}
|
|
20
|
+
getState() {
|
|
21
|
+
return this.#state;
|
|
22
|
+
}
|
|
19
23
|
async invoke(input, options) {
|
|
20
24
|
const mergedConfig = mergeConfigs(this.config, options);
|
|
21
25
|
const returnValue = await AsyncLocalStorageProviderSingleton.runWithConfig(mergedConfig, async () => this.func(input, mergedConfig));
|
|
22
26
|
if (Runnable.isRunnable(returnValue) && this.recurse) return await AsyncLocalStorageProviderSingleton.runWithConfig(mergedConfig, async () => returnValue.invoke(input, mergedConfig));
|
|
27
|
+
this.#state = returnValue;
|
|
23
28
|
return returnValue;
|
|
24
29
|
}
|
|
25
30
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RunnableCallable.js","names":["fields: RunnableCallableArgs<I, O>","input: I","options?: Partial<RunnableConfig> | undefined"],"sources":["../../src/agents/RunnableCallable.ts"],"sourcesContent":["import {\n mergeConfigs,\n Runnable,\n RunnableConfig,\n} from \"@langchain/core/runnables\";\nimport { AsyncLocalStorageProviderSingleton } from \"@langchain/core/singletons\";\n\nexport interface RunnableCallableArgs<I, O> {\n /**\n * The name of the runnable.\n */\n name?: string;\n /**\n * The function to call.\n */\n func: (...args: I[]) => O | Promise<O>;\n /**\n * The tags to add to the runnable.\n */\n tags?: string[];\n /**\n * Whether to recurse the runnable.\n */\n recurse?: boolean;\n}\n\nexport class RunnableCallable<I = unknown, O = unknown> extends Runnable<I, O> {\n lc_namespace: string[] = [\"langgraph\"];\n\n func: RunnableCallableArgs<I, O>[\"func\"];\n\n tags?: RunnableCallableArgs<I, O>[\"tags\"];\n\n config?: RunnableConfig;\n\n trace = true;\n\n recurse = true;\n\n constructor(fields: RunnableCallableArgs<I, O>) {\n super();\n this.name = fields.name ?? fields.func.name;\n this.func = fields.func;\n this.config = fields.tags ? { tags: fields.tags } : undefined;\n this.recurse = fields.recurse ?? this.recurse;\n }\n\n async invoke(\n input: I,\n options?: Partial<RunnableConfig> | undefined\n ): Promise<O> {\n const mergedConfig = mergeConfigs(this.config, options);\n\n const returnValue = await AsyncLocalStorageProviderSingleton.runWithConfig(\n mergedConfig,\n async () => this.func(input, mergedConfig as I)\n );\n\n if (Runnable.isRunnable(returnValue) && this.recurse) {\n return await AsyncLocalStorageProviderSingleton.runWithConfig(\n mergedConfig,\n async () => (returnValue as Runnable<I, O>).invoke(input, mergedConfig)\n );\n }\n\n return returnValue;\n }\n}\n"],"mappings":";;;;AA0BA,IAAa,mBAAb,cAAgE,SAAe;CAC7E,eAAyB,CAAC,WAAY;CAEtC;CAEA;CAEA;CAEA,QAAQ;CAER,UAAU;CAEV,YAAYA,QAAoC;EAC9C,OAAO;EACP,KAAK,OAAO,OAAO,QAAQ,OAAO,KAAK;EACvC,KAAK,OAAO,OAAO;EACnB,KAAK,SAAS,OAAO,OAAO,EAAE,MAAM,OAAO,KAAM,IAAG;EACpD,KAAK,UAAU,OAAO,WAAW,KAAK;CACvC;CAED,MAAM,OACJC,OACAC,SACY;EACZ,MAAM,eAAe,aAAa,KAAK,QAAQ,QAAQ;EAEvD,MAAM,cAAc,MAAM,mCAAmC,cAC3D,cACA,YAAY,KAAK,KAAK,OAAO,aAAkB,CAChD;AAED,MAAI,SAAS,WAAW,YAAY,IAAI,KAAK,QAC3C,QAAO,MAAM,mCAAmC,cAC9C,cACA,YAAa,YAA+B,OAAO,OAAO,aAAa,CACxE;
|
|
1
|
+
{"version":3,"file":"RunnableCallable.js","names":["fields: RunnableCallableArgs<I, O>","#state","input: I","options?: Partial<RunnableConfig> | undefined"],"sources":["../../src/agents/RunnableCallable.ts"],"sourcesContent":["import {\n mergeConfigs,\n Runnable,\n RunnableConfig,\n} from \"@langchain/core/runnables\";\nimport { AsyncLocalStorageProviderSingleton } from \"@langchain/core/singletons\";\n\nexport interface RunnableCallableArgs<I, O> {\n /**\n * The name of the runnable.\n */\n name?: string;\n /**\n * The function to call.\n */\n func: (...args: I[]) => O | Promise<O>;\n /**\n * The tags to add to the runnable.\n */\n tags?: string[];\n /**\n * Whether to recurse the runnable.\n */\n recurse?: boolean;\n}\n\nexport class RunnableCallable<I = unknown, O = unknown> extends Runnable<I, O> {\n lc_namespace: string[] = [\"langgraph\"];\n\n func: RunnableCallableArgs<I, O>[\"func\"];\n\n tags?: RunnableCallableArgs<I, O>[\"tags\"];\n\n config?: RunnableConfig;\n\n trace = true;\n\n recurse = true;\n\n #state: Awaited<O>;\n\n constructor(fields: RunnableCallableArgs<I, O>) {\n super();\n this.name = fields.name ?? fields.func.name;\n this.func = fields.func;\n this.config = fields.tags ? { tags: fields.tags } : undefined;\n this.recurse = fields.recurse ?? this.recurse;\n }\n\n getState(): Awaited<O> {\n return this.#state;\n }\n\n async invoke(\n input: I,\n options?: Partial<RunnableConfig> | undefined\n ): Promise<O> {\n const mergedConfig = mergeConfigs(this.config, options);\n\n const returnValue = await AsyncLocalStorageProviderSingleton.runWithConfig(\n mergedConfig,\n async () => this.func(input, mergedConfig as I)\n );\n\n if (Runnable.isRunnable(returnValue) && this.recurse) {\n return await AsyncLocalStorageProviderSingleton.runWithConfig(\n mergedConfig,\n async () => (returnValue as Runnable<I, O>).invoke(input, mergedConfig)\n );\n }\n\n this.#state = returnValue;\n return returnValue;\n }\n}\n"],"mappings":";;;;AA0BA,IAAa,mBAAb,cAAgE,SAAe;CAC7E,eAAyB,CAAC,WAAY;CAEtC;CAEA;CAEA;CAEA,QAAQ;CAER,UAAU;CAEV;CAEA,YAAYA,QAAoC;EAC9C,OAAO;EACP,KAAK,OAAO,OAAO,QAAQ,OAAO,KAAK;EACvC,KAAK,OAAO,OAAO;EACnB,KAAK,SAAS,OAAO,OAAO,EAAE,MAAM,OAAO,KAAM,IAAG;EACpD,KAAK,UAAU,OAAO,WAAW,KAAK;CACvC;CAED,WAAuB;AACrB,SAAO,KAAKC;CACb;CAED,MAAM,OACJC,OACAC,SACY;EACZ,MAAM,eAAe,aAAa,KAAK,QAAQ,QAAQ;EAEvD,MAAM,cAAc,MAAM,mCAAmC,cAC3D,cACA,YAAY,KAAK,KAAK,OAAO,aAAkB,CAChD;AAED,MAAI,SAAS,WAAW,YAAY,IAAI,KAAK,QAC3C,QAAO,MAAM,mCAAmC,cAC9C,cACA,YAAa,YAA+B,OAAO,OAAO,aAAa,CACxE;EAGH,KAAKF,SAAS;AACd,SAAO;CACR;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ResponseFormatUndefined } from "./responses.cjs";
|
|
2
2
|
import { InteropZodObject } from "@langchain/core/utils/types";
|
|
3
|
-
import { BaseMessage } from "@langchain/core/messages";
|
|
4
3
|
import { AnnotationRoot, BinaryOperatorAggregate, LastValue, Messages } from "@langchain/langgraph";
|
|
4
|
+
import { BaseMessage } from "@langchain/core/messages";
|
|
5
5
|
import { InteropZodToStateDefinition } from "@langchain/langgraph/zod";
|
|
6
6
|
|
|
7
7
|
//#region src/agents/annotation.d.ts
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const require_ReactAgent = require('./ReactAgent.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/agents/createAgent.ts
|
|
4
|
+
function createAgent(params) {
|
|
5
|
+
return new require_ReactAgent.ReactAgent(params);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
exports.createAgent = createAgent;
|
|
10
|
+
//# sourceMappingURL=createAgent.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createAgent.cjs","names":["params: CreateAgentParams<\n StateSchema,\n StructuredResponseFormat,\n ContextSchema,\n any\n >","ReactAgent"],"sources":["../../src/agents/createAgent.ts"],"sourcesContent":["import type {\n InteropZodObject,\n InteropZodType,\n} from \"@langchain/core/utils/types\";\n\nimport { MessagesAnnotation } from \"@langchain/langgraph\";\n\nimport { type AnyAnnotationRoot } from \"./annotation.js\";\nimport type { CreateAgentParams, ExtractZodArrayTypes } from \"./types.js\";\nimport type {\n ToolStrategy,\n TypedToolStrategy,\n ProviderStrategy,\n ResponseFormat,\n ResponseFormatUndefined,\n JsonSchemaFormat,\n} from \"./responses.js\";\nimport { ReactAgent } from \"./ReactAgent.js\";\n\n/**\n * Creates a StateGraph agent that relies on a chat model utilizing tool calling.\n *\n * @example\n * ```ts\n * import { ChatOpenAI } from \"@langchain/openai\";\n * import { createAgent, tool } from \"langchain\";\n * import { z } from \"zod\";\n *\n * const model = new ChatOpenAI({\n * model: \"gpt-4o\",\n * });\n *\n * const getWeather = tool((input) => {\n * if ([\"sf\", \"san francisco\"].includes(input.location.toLowerCase())) {\n * return \"It's 60 degrees and foggy.\";\n * } else {\n * return \"It's 90 degrees and sunny.\";\n * }\n * }, {\n * name: \"get_weather\",\n * description: \"Call to get the current weather.\",\n * schema: z.object({\n * location: z.string().describe(\"Location to get the weather for.\"),\n * })\n * })\n *\n * const agent = createAgent({ llm: model, tools: [getWeather] });\n *\n * const inputs = {\n * messages: [{ role: \"user\", content: \"what is the weather in SF?\" }],\n * };\n *\n * const stream = await agent.stream(inputs, { streamMode: \"values\" });\n *\n * for await (const { messages } of stream) {\n * console.log(messages);\n * }\n * // Returns the messages in the state at each step of execution\n * ```\n */\n// Overload 1: With responseFormat as single InteropZodType\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n T,\n ContextSchema,\n InteropZodType<T>\n > & {\n responseFormat: InteropZodType<T>;\n }\n): ReactAgent<StateSchema, T, ContextSchema>;\n\n// Overload 2: With responseFormat as array of InteropZodTypes (infers union type)\nexport function createAgent<\n T extends readonly InteropZodType<any>[],\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n ExtractZodArrayTypes<T> extends Record<string, any>\n ? ExtractZodArrayTypes<T>\n : Record<string, any>,\n ContextSchema,\n T\n > & {\n responseFormat: T;\n }\n): ReactAgent<\n StateSchema,\n ExtractZodArrayTypes<T> extends Record<string, any>\n ? ExtractZodArrayTypes<T>\n : Record<string, any>,\n ContextSchema\n>;\n\n// Overload 3: With responseFormat as JsonSchemaFormat (JSON schema object)\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n Record<string, unknown>,\n ContextSchema,\n JsonSchemaFormat\n > & {\n responseFormat: JsonSchemaFormat;\n }\n): ReactAgent<StateSchema, Record<string, unknown>, ContextSchema>;\n\n// Overload 4: With responseFormat as array of JsonSchemaFormat (JSON schema objects)\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n Record<string, unknown>,\n ContextSchema,\n JsonSchemaFormat[]\n > & {\n responseFormat: JsonSchemaFormat[];\n }\n): ReactAgent<StateSchema, Record<string, unknown>, ContextSchema>;\n\n// Overload 4.5: With responseFormat as union of JsonSchemaFormat | JsonSchemaFormat[]\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n Record<string, unknown>,\n ContextSchema,\n JsonSchemaFormat | JsonSchemaFormat[]\n > & {\n responseFormat: JsonSchemaFormat | JsonSchemaFormat[];\n }\n): ReactAgent<StateSchema, Record<string, unknown>, ContextSchema>;\n\n// Overload 5: With responseFormat as TypedToolStrategy (for union types from toolStrategy)\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n T,\n ContextSchema,\n TypedToolStrategy<T>\n > & {\n responseFormat: TypedToolStrategy<T>;\n }\n): ReactAgent<StateSchema, T, ContextSchema>;\n\n// Overload 6: With responseFormat as single ToolStrategy instance\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<StateSchema, T, ContextSchema, ToolStrategy<T>> & {\n responseFormat: ToolStrategy<T>;\n }\n): ReactAgent<StateSchema, T, ContextSchema>;\n\n// Overload 7: With responseFormat as ProviderStrategy\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n T,\n ContextSchema,\n ProviderStrategy<T>\n > & {\n responseFormat: ProviderStrategy<T>;\n }\n): ReactAgent<StateSchema, T, ContextSchema>;\n\n// Overload 8: Without responseFormat property at all\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: Omit<\n CreateAgentParams<\n StateSchema,\n ResponseFormatUndefined,\n ContextSchema,\n never\n >,\n \"responseFormat\"\n >\n): ReactAgent<StateSchema, ResponseFormatUndefined, ContextSchema>;\n\n// Overload 9: With responseFormat explicitly undefined\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: Omit<\n CreateAgentParams<\n StateSchema,\n ResponseFormatUndefined,\n ContextSchema,\n never\n >,\n \"responseFormat\"\n > & {\n responseFormat?: undefined;\n }\n): ReactAgent<StateSchema, ResponseFormatUndefined, ContextSchema>;\n\n// Overload 10: For other ResponseFormat values (failsafe)\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n StructuredResponseFormat extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n StructuredResponseFormat,\n ContextSchema,\n ResponseFormat\n > & {\n responseFormat: ResponseFormat;\n }\n): ReactAgent<StateSchema, StructuredResponseFormat, ContextSchema>;\n\n// Implementation\nexport function createAgent<\n StateSchema extends AnyAnnotationRoot | InteropZodObject,\n StructuredResponseFormat extends Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject\n>(\n params: CreateAgentParams<\n StateSchema,\n StructuredResponseFormat,\n ContextSchema,\n any\n >\n): ReactAgent<StateSchema, StructuredResponseFormat, ContextSchema> {\n return new ReactAgent(params);\n}\n"],"mappings":";;;AAqQA,SAAgB,YAKdA,QAMkE;AAClE,QAAO,IAAIC,8BAAW;AACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createAgent.js","names":["params: CreateAgentParams<\n StateSchema,\n StructuredResponseFormat,\n ContextSchema,\n any\n >"],"sources":["../../src/agents/createAgent.ts"],"sourcesContent":["import type {\n InteropZodObject,\n InteropZodType,\n} from \"@langchain/core/utils/types\";\n\nimport { MessagesAnnotation } from \"@langchain/langgraph\";\n\nimport { type AnyAnnotationRoot } from \"./annotation.js\";\nimport type { CreateAgentParams, ExtractZodArrayTypes } from \"./types.js\";\nimport type {\n ToolStrategy,\n TypedToolStrategy,\n ProviderStrategy,\n ResponseFormat,\n ResponseFormatUndefined,\n JsonSchemaFormat,\n} from \"./responses.js\";\nimport { ReactAgent } from \"./ReactAgent.js\";\n\n/**\n * Creates a StateGraph agent that relies on a chat model utilizing tool calling.\n *\n * @example\n * ```ts\n * import { ChatOpenAI } from \"@langchain/openai\";\n * import { createAgent, tool } from \"langchain\";\n * import { z } from \"zod\";\n *\n * const model = new ChatOpenAI({\n * model: \"gpt-4o\",\n * });\n *\n * const getWeather = tool((input) => {\n * if ([\"sf\", \"san francisco\"].includes(input.location.toLowerCase())) {\n * return \"It's 60 degrees and foggy.\";\n * } else {\n * return \"It's 90 degrees and sunny.\";\n * }\n * }, {\n * name: \"get_weather\",\n * description: \"Call to get the current weather.\",\n * schema: z.object({\n * location: z.string().describe(\"Location to get the weather for.\"),\n * })\n * })\n *\n * const agent = createAgent({ llm: model, tools: [getWeather] });\n *\n * const inputs = {\n * messages: [{ role: \"user\", content: \"what is the weather in SF?\" }],\n * };\n *\n * const stream = await agent.stream(inputs, { streamMode: \"values\" });\n *\n * for await (const { messages } of stream) {\n * console.log(messages);\n * }\n * // Returns the messages in the state at each step of execution\n * ```\n */\n// Overload 1: With responseFormat as single InteropZodType\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n T,\n ContextSchema,\n InteropZodType<T>\n > & {\n responseFormat: InteropZodType<T>;\n }\n): ReactAgent<StateSchema, T, ContextSchema>;\n\n// Overload 2: With responseFormat as array of InteropZodTypes (infers union type)\nexport function createAgent<\n T extends readonly InteropZodType<any>[],\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n ExtractZodArrayTypes<T> extends Record<string, any>\n ? ExtractZodArrayTypes<T>\n : Record<string, any>,\n ContextSchema,\n T\n > & {\n responseFormat: T;\n }\n): ReactAgent<\n StateSchema,\n ExtractZodArrayTypes<T> extends Record<string, any>\n ? ExtractZodArrayTypes<T>\n : Record<string, any>,\n ContextSchema\n>;\n\n// Overload 3: With responseFormat as JsonSchemaFormat (JSON schema object)\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n Record<string, unknown>,\n ContextSchema,\n JsonSchemaFormat\n > & {\n responseFormat: JsonSchemaFormat;\n }\n): ReactAgent<StateSchema, Record<string, unknown>, ContextSchema>;\n\n// Overload 4: With responseFormat as array of JsonSchemaFormat (JSON schema objects)\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n Record<string, unknown>,\n ContextSchema,\n JsonSchemaFormat[]\n > & {\n responseFormat: JsonSchemaFormat[];\n }\n): ReactAgent<StateSchema, Record<string, unknown>, ContextSchema>;\n\n// Overload 4.5: With responseFormat as union of JsonSchemaFormat | JsonSchemaFormat[]\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n Record<string, unknown>,\n ContextSchema,\n JsonSchemaFormat | JsonSchemaFormat[]\n > & {\n responseFormat: JsonSchemaFormat | JsonSchemaFormat[];\n }\n): ReactAgent<StateSchema, Record<string, unknown>, ContextSchema>;\n\n// Overload 5: With responseFormat as TypedToolStrategy (for union types from toolStrategy)\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n T,\n ContextSchema,\n TypedToolStrategy<T>\n > & {\n responseFormat: TypedToolStrategy<T>;\n }\n): ReactAgent<StateSchema, T, ContextSchema>;\n\n// Overload 6: With responseFormat as single ToolStrategy instance\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<StateSchema, T, ContextSchema, ToolStrategy<T>> & {\n responseFormat: ToolStrategy<T>;\n }\n): ReactAgent<StateSchema, T, ContextSchema>;\n\n// Overload 7: With responseFormat as ProviderStrategy\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n T,\n ContextSchema,\n ProviderStrategy<T>\n > & {\n responseFormat: ProviderStrategy<T>;\n }\n): ReactAgent<StateSchema, T, ContextSchema>;\n\n// Overload 8: Without responseFormat property at all\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: Omit<\n CreateAgentParams<\n StateSchema,\n ResponseFormatUndefined,\n ContextSchema,\n never\n >,\n \"responseFormat\"\n >\n): ReactAgent<StateSchema, ResponseFormatUndefined, ContextSchema>;\n\n// Overload 9: With responseFormat explicitly undefined\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: Omit<\n CreateAgentParams<\n StateSchema,\n ResponseFormatUndefined,\n ContextSchema,\n never\n >,\n \"responseFormat\"\n > & {\n responseFormat?: undefined;\n }\n): ReactAgent<StateSchema, ResponseFormatUndefined, ContextSchema>;\n\n// Overload 10: For other ResponseFormat values (failsafe)\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n StructuredResponseFormat extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n StructuredResponseFormat,\n ContextSchema,\n ResponseFormat\n > & {\n responseFormat: ResponseFormat;\n }\n): ReactAgent<StateSchema, StructuredResponseFormat, ContextSchema>;\n\n// Implementation\nexport function createAgent<\n StateSchema extends AnyAnnotationRoot | InteropZodObject,\n StructuredResponseFormat extends Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject\n>(\n params: CreateAgentParams<\n StateSchema,\n StructuredResponseFormat,\n ContextSchema,\n any\n >\n): ReactAgent<StateSchema, StructuredResponseFormat, ContextSchema> {\n return new ReactAgent(params);\n}\n"],"mappings":";;;AAqQA,SAAgB,YAKdA,QAMkE;AAClE,QAAO,IAAI,WAAW;AACvB"}
|
package/dist/agents/index.cjs
CHANGED
|
@@ -2,15 +2,34 @@ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
|
2
2
|
const require_errors = require('./errors.cjs');
|
|
3
3
|
const require_responses = require('./responses.cjs');
|
|
4
4
|
const require_ToolNode = require('./nodes/ToolNode.cjs');
|
|
5
|
-
const
|
|
5
|
+
const require_createAgent = require('./createAgent.cjs');
|
|
6
|
+
const require_middleware = require('./middlewareAgent/middleware.cjs');
|
|
7
|
+
const require_index = require('./middlewareAgent/index.cjs');
|
|
6
8
|
require('./interrupt.cjs');
|
|
7
9
|
const __langchain_langgraph = require_rolldown_runtime.__toESM(require("@langchain/langgraph"));
|
|
8
10
|
|
|
9
11
|
//#region src/agents/index.ts
|
|
10
|
-
function createAgent(params) {
|
|
11
|
-
|
|
12
|
+
function createAgent$2(params) {
|
|
13
|
+
/**
|
|
14
|
+
* Check if middlewares property is present
|
|
15
|
+
*/
|
|
16
|
+
if ("middlewares" in params && params.middlewares !== void 0) {
|
|
17
|
+
/**
|
|
18
|
+
* The user wants to use the middleware version of the agent.
|
|
19
|
+
* Let's verify that `preModelHook` and `postModelHook` are not provided
|
|
20
|
+
*/
|
|
21
|
+
if ("preModelHook" in params || "postModelHook" in params) throw new Error("The `preModelHook` and `postModelHook` parameters are not supported in the middleware version of the agent.");
|
|
22
|
+
/**
|
|
23
|
+
* Use v2 (middleware version)
|
|
24
|
+
*/
|
|
25
|
+
return require_index.createAgent(params);
|
|
26
|
+
} else
|
|
27
|
+
/**
|
|
28
|
+
* Use v1 (original version)
|
|
29
|
+
*/
|
|
30
|
+
return require_createAgent.createAgent(params);
|
|
12
31
|
}
|
|
13
32
|
|
|
14
33
|
//#endregion
|
|
15
|
-
exports.createAgent = createAgent;
|
|
34
|
+
exports.createAgent = createAgent$2;
|
|
16
35
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["params: CreateAgentParams<\n StateSchema,\n StructuredResponseFormat,\n ContextSchema,\n any\n >","ReactAgent"],"sources":["../../src/agents/index.ts"],"sourcesContent":["import type {\n InteropZodObject,\n InteropZodType,\n} from \"@langchain/core/utils/types\";\n\nimport { MessagesAnnotation } from \"@langchain/langgraph\";\n\nimport { type AnyAnnotationRoot } from \"./annotation.js\";\nimport type { CreateAgentParams, ExtractZodArrayTypes } from \"./types.js\";\nimport type {\n ToolStrategy,\n TypedToolStrategy,\n ProviderStrategy,\n ResponseFormat,\n ResponseFormatUndefined,\n JsonSchemaFormat,\n} from \"./responses.js\";\nimport { ReactAgent } from \"./ReactAgent.js\";\n\n/**\n * Creates a StateGraph agent that relies on a chat model utilizing tool calling.\n *\n * @example\n * ```ts\n * import { ChatOpenAI } from \"@langchain/openai\";\n * import { createAgent, tool } from \"langchain\";\n * import { z } from \"zod\";\n *\n * const model = new ChatOpenAI({\n * model: \"gpt-4o\",\n * });\n *\n * const getWeather = tool((input) => {\n * if ([\"sf\", \"san francisco\"].includes(input.location.toLowerCase())) {\n * return \"It's 60 degrees and foggy.\";\n * } else {\n * return \"It's 90 degrees and sunny.\";\n * }\n * }, {\n * name: \"get_weather\",\n * description: \"Call to get the current weather.\",\n * schema: z.object({\n * location: z.string().describe(\"Location to get the weather for.\"),\n * })\n * })\n *\n * const agent = createAgent({ llm: model, tools: [getWeather] });\n *\n * const inputs = {\n * messages: [{ role: \"user\", content: \"what is the weather in SF?\" }],\n * };\n *\n * const stream = await agent.stream(inputs, { streamMode: \"values\" });\n *\n * for await (const { messages } of stream) {\n * console.log(messages);\n * }\n * // Returns the messages in the state at each step of execution\n * ```\n */\n// Overload 1: With responseFormat as single InteropZodType\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n T,\n ContextSchema,\n InteropZodType<T>\n > & {\n responseFormat: InteropZodType<T>;\n }\n): ReactAgent<StateSchema, T, ContextSchema>;\n\n// Overload 2: With responseFormat as array of InteropZodTypes (infers union type)\nexport function createAgent<\n T extends readonly InteropZodType<any>[],\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n ExtractZodArrayTypes<T> extends Record<string, any>\n ? ExtractZodArrayTypes<T>\n : Record<string, any>,\n ContextSchema,\n T\n > & {\n responseFormat: T;\n }\n): ReactAgent<\n StateSchema,\n ExtractZodArrayTypes<T> extends Record<string, any>\n ? ExtractZodArrayTypes<T>\n : Record<string, any>,\n ContextSchema\n>;\n\n// Overload 3: With responseFormat as JsonSchemaFormat (JSON schema object)\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n Record<string, unknown>,\n ContextSchema,\n JsonSchemaFormat\n > & {\n responseFormat: JsonSchemaFormat;\n }\n): ReactAgent<StateSchema, Record<string, unknown>, ContextSchema>;\n\n// Overload 4: With responseFormat as array of JsonSchemaFormat (JSON schema objects)\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n Record<string, unknown>,\n ContextSchema,\n JsonSchemaFormat[]\n > & {\n responseFormat: JsonSchemaFormat[];\n }\n): ReactAgent<StateSchema, Record<string, unknown>, ContextSchema>;\n\n// Overload 4.5: With responseFormat as union of JsonSchemaFormat | JsonSchemaFormat[]\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n Record<string, unknown>,\n ContextSchema,\n JsonSchemaFormat | JsonSchemaFormat[]\n > & {\n responseFormat: JsonSchemaFormat | JsonSchemaFormat[];\n }\n): ReactAgent<StateSchema, Record<string, unknown>, ContextSchema>;\n\n// Overload 5: With responseFormat as TypedToolStrategy (for union types from toolStrategy)\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n T,\n ContextSchema,\n TypedToolStrategy<T>\n > & {\n responseFormat: TypedToolStrategy<T>;\n }\n): ReactAgent<StateSchema, T, ContextSchema>;\n\n// Overload 6: With responseFormat as single ToolStrategy instance\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<StateSchema, T, ContextSchema, ToolStrategy<T>> & {\n responseFormat: ToolStrategy<T>;\n }\n): ReactAgent<StateSchema, T, ContextSchema>;\n\n// Overload 7: With responseFormat as ProviderStrategy\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n T,\n ContextSchema,\n ProviderStrategy<T>\n > & {\n responseFormat: ProviderStrategy<T>;\n }\n): ReactAgent<StateSchema, T, ContextSchema>;\n\n// Overload 8: Without responseFormat property at all\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: Omit<\n CreateAgentParams<\n StateSchema,\n ResponseFormatUndefined,\n ContextSchema,\n never\n >,\n \"responseFormat\"\n >\n): ReactAgent<StateSchema, ResponseFormatUndefined, ContextSchema>;\n\n// Overload 9: With responseFormat explicitly undefined\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: Omit<\n CreateAgentParams<\n StateSchema,\n ResponseFormatUndefined,\n ContextSchema,\n never\n >,\n \"responseFormat\"\n > & {\n responseFormat?: undefined;\n }\n): ReactAgent<StateSchema, ResponseFormatUndefined, ContextSchema>;\n\n// Overload 10: For other ResponseFormat values (failsafe)\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n StructuredResponseFormat extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n StructuredResponseFormat,\n ContextSchema,\n ResponseFormat\n > & {\n responseFormat: ResponseFormat;\n }\n): ReactAgent<StateSchema, StructuredResponseFormat, ContextSchema>;\n\n// Implementation\nexport function createAgent<\n StateSchema extends AnyAnnotationRoot | InteropZodObject,\n StructuredResponseFormat extends Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject\n>(\n params: CreateAgentParams<\n StateSchema,\n StructuredResponseFormat,\n ContextSchema,\n any\n >\n): ReactAgent<StateSchema, StructuredResponseFormat, ContextSchema> {\n return new ReactAgent(params);\n}\n\nexport * from \"./types.js\";\nexport * from \"./errors.js\";\nexport * from \"./interrupt.js\";\nexport { ToolNode } from \"./nodes/ToolNode.js\";\nexport {\n toolStrategy,\n providerStrategy,\n ToolStrategy,\n ProviderStrategy,\n type ResponseFormat,\n} from \"./responses.js\";\n"],"mappings":";;;;;;;;;AAqQA,SAAgB,YAKdA,QAMkE;AAClE,QAAO,IAAIC,8BAAW;AACvB"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["createAgent","params: any","createAgentV2","createAgentV1"],"sources":["../../src/agents/index.ts"],"sourcesContent":["import type {\n InteropZodObject,\n InteropZodType,\n} from \"@langchain/core/utils/types\";\nimport { MessagesAnnotation } from \"@langchain/langgraph\";\n\n// Import v1 (without middleware)\nimport { createAgent as createAgentV1 } from \"./createAgent.js\";\nimport { ReactAgent as ReactAgentV1 } from \"./ReactAgent.js\";\n\n// Import v2 (with middleware)\nimport { createAgent as createAgentV2 } from \"./middlewareAgent/index.js\";\nimport { ReactAgent as ReactAgentV2 } from \"./middlewareAgent/ReactAgent.js\";\n\nimport { type AnyAnnotationRoot } from \"./annotation.js\";\nimport type { CreateAgentParams, ExtractZodArrayTypes } from \"./types.js\";\nimport type {\n CreateAgentParams as CreateAgentParamsV2,\n AgentMiddleware,\n} from \"./middlewareAgent/types.js\";\nimport type {\n ToolStrategy,\n TypedToolStrategy,\n ProviderStrategy,\n ResponseFormatUndefined,\n JsonSchemaFormat,\n} from \"./responses.js\";\n\n// Re-export types and utilities\nexport * from \"./types.js\";\nexport * from \"./errors.js\";\nexport * from \"./interrupt.js\";\nexport { ToolNode } from \"./nodes/ToolNode.js\";\nexport {\n toolStrategy,\n providerStrategy,\n ToolStrategy,\n ProviderStrategy,\n type ResponseFormat,\n} from \"./responses.js\";\nexport { createMiddleware } from \"./middlewareAgent/index.js\";\nexport type { AgentMiddleware } from \"./middlewareAgent/types.js\";\n\n/**\n * Agents combine language models with tools to create systems that can reason\n * about tasks, decide which tools to use, and iteratively work towards solutions.\n * {@link createAgent} provides a production-ready ReAct (Reasoning + Acting)\n * agent implementation based on the paper {@link https://arxiv.org/abs/2210.03629|ReAct: Synergizing Reasoning and Acting in Language Models.}\n *\n * @example\n * ```ts\n * import { createAgent, tool } from \"langchain\";\n * import { z } from \"zod\";\n *\n * const getWeather = tool((input) => {\n * if ([\"sf\", \"san francisco\"].includes(input.location.toLowerCase())) {\n * return \"It's 60 degrees and foggy.\";\n * } else {\n * return \"It's 90 degrees and sunny.\";\n * }\n * }, {\n * name: \"get_weather\",\n * description: \"Call to get the current weather.\",\n * schema: z.object({\n * location: z.string().describe(\"Location to get the weather for.\"),\n * })\n * })\n *\n * const agent = createAgent({\n * // use chat model from \"@langchain/openai\"\n * model: \"openai:gpt-4o-mini\",\n * tools: [getWeather]\n * });\n *\n * const inputs = {\n * messages: [{ role: \"user\", content: \"what is the weather in SF?\" }],\n * };\n *\n * const stream = await agent.stream(inputs, { streamMode: \"values\" });\n *\n * for await (const { messages } of stream) {\n * console.log(messages);\n * }\n * // Returns the messages in the state at each step of execution\n * ```\n */\n\n// ===== V1 OVERLOADS (WITHOUT MIDDLEWARE) =====\n// These overloads come first to ensure proper type inference when middlewares is NOT provided\n\n// Overload 1: V1 - With responseFormat as single InteropZodType\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n T,\n ContextSchema,\n InteropZodType<T>\n > & {\n responseFormat: InteropZodType<T>;\n }\n): ReactAgentV1<StateSchema, T, ContextSchema>;\n\n// Overload 2: V1 - With responseFormat as array of InteropZodTypes\nexport function createAgent<\n T extends readonly InteropZodType<any>[],\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n ExtractZodArrayTypes<T> extends Record<string, any>\n ? ExtractZodArrayTypes<T>\n : Record<string, any>,\n ContextSchema,\n T\n > & {\n responseFormat: T;\n }\n): ReactAgentV1<\n StateSchema,\n ExtractZodArrayTypes<T> extends Record<string, any>\n ? ExtractZodArrayTypes<T>\n : Record<string, any>,\n ContextSchema\n>;\n\n// Overload 3: V1 - With responseFormat as JsonSchemaFormat\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n Record<string, unknown>,\n ContextSchema,\n JsonSchemaFormat\n > & {\n responseFormat: JsonSchemaFormat;\n }\n): ReactAgentV1<StateSchema, Record<string, unknown>, ContextSchema>;\n\n// Overload 4: V1 - With responseFormat as array of JsonSchemaFormat\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n Record<string, unknown>,\n ContextSchema,\n JsonSchemaFormat[]\n > & {\n responseFormat: JsonSchemaFormat[];\n }\n): ReactAgentV1<StateSchema, Record<string, unknown>, ContextSchema>;\n\n// Overload 5: V1 - With responseFormat as union of JsonSchemaFormat | JsonSchemaFormat[]\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n Record<string, unknown>,\n ContextSchema,\n JsonSchemaFormat | JsonSchemaFormat[]\n > & {\n responseFormat: JsonSchemaFormat | JsonSchemaFormat[];\n }\n): ReactAgentV1<StateSchema, Record<string, unknown>, ContextSchema>;\n\n// Overload 6: V1 - With responseFormat as TypedToolStrategy\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n T,\n ContextSchema,\n TypedToolStrategy<T>\n > & {\n responseFormat: TypedToolStrategy<T>;\n }\n): ReactAgentV1<StateSchema, T, ContextSchema>;\n\n// Overload 7: V1 - With responseFormat as single ToolStrategy\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<StateSchema, T, ContextSchema, ToolStrategy<T>> & {\n responseFormat: ToolStrategy<T>;\n }\n): ReactAgentV1<StateSchema, T, ContextSchema>;\n\n// Overload 8: V1 - With responseFormat as ProviderStrategy\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n T,\n ContextSchema,\n ProviderStrategy<T>\n > & {\n responseFormat: ProviderStrategy<T>;\n }\n): ReactAgentV1<StateSchema, T, ContextSchema>;\n\n// Overload 9: V1 - Without responseFormat property at all\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: Omit<\n CreateAgentParams<\n StateSchema,\n ResponseFormatUndefined,\n ContextSchema,\n never\n >,\n \"responseFormat\"\n >\n): ReactAgentV1<StateSchema, ResponseFormatUndefined, ContextSchema>;\n\n// Overload 10: V1 - With responseFormat explicitly undefined\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: Omit<\n CreateAgentParams<\n StateSchema,\n ResponseFormatUndefined,\n ContextSchema,\n never\n >,\n \"responseFormat\"\n > & {\n responseFormat?: undefined;\n }\n): ReactAgentV1<StateSchema, ResponseFormatUndefined, ContextSchema>;\n\n// Overload 11: V1 - For other ResponseFormat values (failsafe)\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n StructuredResponseFormat extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n StructuredResponseFormat,\n ContextSchema,\n any\n > & {\n responseFormat: any;\n }\n): ReactAgentV1<StateSchema, StructuredResponseFormat, ContextSchema>;\n\n// ===== V2 OVERLOADS (WITH MIDDLEWARE) =====\n// These overloads explicitly require the middlewares property\n\n// Overload 12: With responseFormat as single InteropZodType and middlewares\nexport function createAgent<\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddlewares extends readonly AgentMiddleware<\n any,\n any,\n any\n >[] = readonly AgentMiddleware<any, any, any>[]\n>(\n params: CreateAgentParamsV2<T, ContextSchema, InteropZodType<T>> & {\n responseFormat: InteropZodType<T>;\n middlewares: TMiddlewares;\n }\n): ReactAgentV2<T, ContextSchema, TMiddlewares>;\n\n// Overload 13: With responseFormat as array of InteropZodTypes and middlewares\nexport function createAgent<\n T extends readonly InteropZodType<any>[],\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddlewares extends readonly AgentMiddleware<\n any,\n any,\n any\n >[] = readonly AgentMiddleware<any, any, any>[]\n>(\n params: CreateAgentParamsV2<\n ExtractZodArrayTypes<T> extends Record<string, any>\n ? ExtractZodArrayTypes<T>\n : Record<string, any>,\n ContextSchema,\n T\n > & {\n responseFormat: T;\n middlewares: TMiddlewares;\n }\n): ReactAgentV2<\n ExtractZodArrayTypes<T> extends Record<string, any>\n ? ExtractZodArrayTypes<T>\n : Record<string, any>,\n ContextSchema,\n TMiddlewares\n>;\n\n// Overload 14: With responseFormat as JsonSchemaFormat and middlewares\nexport function createAgent<\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddlewares extends readonly AgentMiddleware<\n any,\n any,\n any\n >[] = readonly AgentMiddleware<any, any, any>[]\n>(\n params: CreateAgentParamsV2<\n Record<string, unknown>,\n ContextSchema,\n JsonSchemaFormat\n > & {\n responseFormat: JsonSchemaFormat;\n middlewares: TMiddlewares;\n }\n): ReactAgentV2<Record<string, unknown>, ContextSchema, TMiddlewares>;\n\n// Overload 15: With responseFormat as array of JsonSchemaFormat and middlewares\nexport function createAgent<\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddlewares extends readonly AgentMiddleware<\n any,\n any,\n any\n >[] = readonly AgentMiddleware<any, any, any>[]\n>(\n params: CreateAgentParamsV2<\n Record<string, unknown>,\n ContextSchema,\n JsonSchemaFormat[]\n > & {\n responseFormat: JsonSchemaFormat[];\n middlewares: TMiddlewares;\n }\n): ReactAgentV2<Record<string, unknown>, ContextSchema, TMiddlewares>;\n\n// Overload 16: With responseFormat as union of JsonSchemaFormat | JsonSchemaFormat[] and middlewares\nexport function createAgent<\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddlewares extends readonly AgentMiddleware<\n any,\n any,\n any\n >[] = readonly AgentMiddleware<any, any, any>[]\n>(\n params: CreateAgentParamsV2<\n Record<string, unknown>,\n ContextSchema,\n JsonSchemaFormat | JsonSchemaFormat[]\n > & {\n responseFormat: JsonSchemaFormat | JsonSchemaFormat[];\n middlewares: TMiddlewares;\n }\n): ReactAgentV2<Record<string, unknown>, ContextSchema, TMiddlewares>;\n\n// Overload 17: With responseFormat as TypedToolStrategy and middlewares\nexport function createAgent<\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddlewares extends readonly AgentMiddleware<\n any,\n any,\n any\n >[] = readonly AgentMiddleware<any, any, any>[]\n>(\n params: CreateAgentParamsV2<T, ContextSchema, TypedToolStrategy<T>> & {\n responseFormat: TypedToolStrategy<T>;\n middlewares: TMiddlewares;\n }\n): ReactAgentV2<T, ContextSchema, TMiddlewares>;\n\n// Overload 18: With responseFormat as single ToolStrategy and middlewares\nexport function createAgent<\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddlewares extends readonly AgentMiddleware<\n any,\n any,\n any\n >[] = readonly AgentMiddleware<any, any, any>[]\n>(\n params: CreateAgentParamsV2<T, ContextSchema, ToolStrategy<T>> & {\n responseFormat: ToolStrategy<T>;\n middlewares: TMiddlewares;\n }\n): ReactAgentV2<T, ContextSchema, TMiddlewares>;\n\n// Overload 19: With responseFormat as ProviderStrategy and middlewares\nexport function createAgent<\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddlewares extends readonly AgentMiddleware<\n any,\n any,\n any\n >[] = readonly AgentMiddleware<any, any, any>[]\n>(\n params: CreateAgentParamsV2<T, ContextSchema, ProviderStrategy<T>> & {\n responseFormat: ProviderStrategy<T>;\n middlewares: TMiddlewares;\n }\n): ReactAgentV2<T, ContextSchema, TMiddlewares>;\n\n// Overload 20: Without responseFormat but with middlewares\nexport function createAgent<\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddlewares extends readonly AgentMiddleware<\n any,\n any,\n any\n >[] = readonly AgentMiddleware<any, any, any>[]\n>(\n params: Omit<\n CreateAgentParamsV2<ResponseFormatUndefined, ContextSchema, never>,\n \"responseFormat\"\n > & { middlewares: TMiddlewares }\n): ReactAgentV2<ResponseFormatUndefined, ContextSchema, TMiddlewares>;\n\n// Overload 21: With responseFormat explicitly undefined and middlewares\nexport function createAgent<\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddlewares extends readonly AgentMiddleware<\n any,\n any,\n any\n >[] = readonly AgentMiddleware<any, any, any>[]\n>(\n params: Omit<\n CreateAgentParamsV2<ResponseFormatUndefined, ContextSchema, never>,\n \"responseFormat\"\n > & {\n responseFormat?: undefined;\n middlewares: TMiddlewares;\n }\n): ReactAgentV2<ResponseFormatUndefined, ContextSchema, TMiddlewares>;\n\n// Overload 22: For other ResponseFormat values with middlewares (failsafe)\nexport function createAgent<\n StructuredResponseFormat extends Record<string, any> = Record<string, any>,\n ContextSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = AnyAnnotationRoot,\n TMiddlewares extends readonly AgentMiddleware<\n any,\n any,\n any\n >[] = readonly AgentMiddleware<any, any, any>[]\n>(\n params: CreateAgentParamsV2<StructuredResponseFormat, ContextSchema, any> & {\n responseFormat: any;\n middlewares: TMiddlewares;\n }\n): ReactAgentV2<StructuredResponseFormat, ContextSchema, TMiddlewares>;\n\nexport function createAgent(params: any): any {\n /**\n * Check if middlewares property is present\n */\n if (\"middlewares\" in params && params.middlewares !== undefined) {\n /**\n * The user wants to use the middleware version of the agent.\n * Let's verify that `preModelHook` and `postModelHook` are not provided\n */\n if (\"preModelHook\" in params || \"postModelHook\" in params) {\n throw new Error(\n \"The `preModelHook` and `postModelHook` parameters are not supported in the middleware version of the agent.\"\n );\n }\n\n /**\n * Use v2 (middleware version)\n */\n return createAgentV2(params);\n } else {\n /**\n * Use v1 (original version)\n */\n return createAgentV1(params);\n }\n}\n"],"mappings":";;;;;;;;;;;AAigBA,SAAgBA,cAAYC,QAAkB;;;;AAI5C,KAAI,iBAAiB,UAAU,OAAO,gBAAgB,QAAW;;;;;AAK/D,MAAI,kBAAkB,UAAU,mBAAmB,OACjD,OAAM,IAAI,MACR;;;;AAOJ,SAAOC,0BAAc,OAAO;CAC7B;;;;AAIC,QAAOC,gCAAc,OAAO;AAE/B"}
|
package/dist/agents/index.d.cts
CHANGED
|
@@ -3,26 +3,27 @@ import { JsonSchemaFormat, ProviderStrategy, ResponseFormat, ResponseFormatUndef
|
|
|
3
3
|
import { AnyAnnotationRoot } from "./annotation.cjs";
|
|
4
4
|
import { ToolNode } from "./nodes/ToolNode.cjs";
|
|
5
5
|
import { AgentRuntime, AgentState, ClientTool, CreateAgentParams, ExtractZodArrayTypes, N, Prompt, ServerTool } from "./types.cjs";
|
|
6
|
+
import { AgentMiddleware, CreateAgentParams as CreateAgentParams$1 } from "./middlewareAgent/types.cjs";
|
|
6
7
|
import { ReactAgent } from "./ReactAgent.cjs";
|
|
8
|
+
import { ReactAgent as ReactAgent$1 } from "./middlewareAgent/ReactAgent.cjs";
|
|
7
9
|
import { ActionRequest, HumanInterrupt, HumanInterruptConfig, HumanResponse } from "./interrupt.cjs";
|
|
10
|
+
import { createMiddleware } from "./middlewareAgent/middleware.cjs";
|
|
8
11
|
import { InteropZodObject, InteropZodType } from "@langchain/core/utils/types";
|
|
9
12
|
import { MessagesAnnotation } from "@langchain/langgraph";
|
|
10
13
|
|
|
11
14
|
//#region src/agents/index.d.ts
|
|
12
15
|
|
|
13
16
|
/**
|
|
14
|
-
*
|
|
17
|
+
* Agents combine language models with tools to create systems that can reason
|
|
18
|
+
* about tasks, decide which tools to use, and iteratively work towards solutions.
|
|
19
|
+
* {@link createAgent} provides a production-ready ReAct (Reasoning + Acting)
|
|
20
|
+
* agent implementation based on the paper {@link https://arxiv.org/abs/2210.03629|ReAct: Synergizing Reasoning and Acting in Language Models.}
|
|
15
21
|
*
|
|
16
22
|
* @example
|
|
17
23
|
* ```ts
|
|
18
|
-
* import { ChatOpenAI } from "@langchain/openai";
|
|
19
24
|
* import { createAgent, tool } from "langchain";
|
|
20
25
|
* import { z } from "zod";
|
|
21
26
|
*
|
|
22
|
-
* const model = new ChatOpenAI({
|
|
23
|
-
* model: "gpt-4o",
|
|
24
|
-
* });
|
|
25
|
-
*
|
|
26
27
|
* const getWeather = tool((input) => {
|
|
27
28
|
* if (["sf", "san francisco"].includes(input.location.toLowerCase())) {
|
|
28
29
|
* return "It's 60 degrees and foggy.";
|
|
@@ -37,7 +38,11 @@ import { MessagesAnnotation } from "@langchain/langgraph";
|
|
|
37
38
|
* })
|
|
38
39
|
* })
|
|
39
40
|
*
|
|
40
|
-
* const agent = createAgent({
|
|
41
|
+
* const agent = createAgent({
|
|
42
|
+
* // use chat model from "@langchain/openai"
|
|
43
|
+
* model: "openai:gpt-4o-mini",
|
|
44
|
+
* tools: [getWeather]
|
|
45
|
+
* });
|
|
41
46
|
*
|
|
42
47
|
* const inputs = {
|
|
43
48
|
* messages: [{ role: "user", content: "what is the weather in SF?" }],
|
|
@@ -51,48 +56,106 @@ import { MessagesAnnotation } from "@langchain/langgraph";
|
|
|
51
56
|
* // Returns the messages in the state at each step of execution
|
|
52
57
|
* ```
|
|
53
58
|
*/
|
|
54
|
-
//
|
|
59
|
+
// ===== V1 OVERLOADS (WITHOUT MIDDLEWARE) =====
|
|
60
|
+
// These overloads come first to ensure proper type inference when middlewares is NOT provided
|
|
61
|
+
// Overload 1: V1 - With responseFormat as single InteropZodType
|
|
55
62
|
declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, T, ContextSchema, InteropZodType<T>> & {
|
|
56
63
|
responseFormat: InteropZodType<T>;
|
|
57
64
|
}): ReactAgent<StateSchema, T, ContextSchema>;
|
|
58
|
-
// Overload 2: With responseFormat as array of InteropZodTypes
|
|
65
|
+
// Overload 2: V1 - With responseFormat as array of InteropZodTypes
|
|
59
66
|
declare function createAgent<T extends readonly InteropZodType<any>[], StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, ExtractZodArrayTypes<T> extends Record<string, any> ? ExtractZodArrayTypes<T> : Record<string, any>, ContextSchema, T> & {
|
|
60
67
|
responseFormat: T;
|
|
61
68
|
}): ReactAgent<StateSchema, ExtractZodArrayTypes<T> extends Record<string, any> ? ExtractZodArrayTypes<T> : Record<string, any>, ContextSchema>;
|
|
62
|
-
// Overload 3: With responseFormat as JsonSchemaFormat
|
|
69
|
+
// Overload 3: V1 - With responseFormat as JsonSchemaFormat
|
|
63
70
|
declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, Record<string, unknown>, ContextSchema, JsonSchemaFormat> & {
|
|
64
71
|
responseFormat: JsonSchemaFormat;
|
|
65
72
|
}): ReactAgent<StateSchema, Record<string, unknown>, ContextSchema>;
|
|
66
|
-
// Overload 4: With responseFormat as array of JsonSchemaFormat
|
|
73
|
+
// Overload 4: V1 - With responseFormat as array of JsonSchemaFormat
|
|
67
74
|
declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, Record<string, unknown>, ContextSchema, JsonSchemaFormat[]> & {
|
|
68
75
|
responseFormat: JsonSchemaFormat[];
|
|
69
76
|
}): ReactAgent<StateSchema, Record<string, unknown>, ContextSchema>;
|
|
70
|
-
// Overload
|
|
77
|
+
// Overload 5: V1 - With responseFormat as union of JsonSchemaFormat | JsonSchemaFormat[]
|
|
71
78
|
declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, Record<string, unknown>, ContextSchema, JsonSchemaFormat | JsonSchemaFormat[]> & {
|
|
72
79
|
responseFormat: JsonSchemaFormat | JsonSchemaFormat[];
|
|
73
80
|
}): ReactAgent<StateSchema, Record<string, unknown>, ContextSchema>;
|
|
74
|
-
// Overload
|
|
81
|
+
// Overload 6: V1 - With responseFormat as TypedToolStrategy
|
|
75
82
|
declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, T, ContextSchema, TypedToolStrategy<T>> & {
|
|
76
83
|
responseFormat: TypedToolStrategy<T>;
|
|
77
84
|
}): ReactAgent<StateSchema, T, ContextSchema>;
|
|
78
|
-
// Overload
|
|
85
|
+
// Overload 7: V1 - With responseFormat as single ToolStrategy
|
|
79
86
|
declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, T, ContextSchema, ToolStrategy<T>> & {
|
|
80
87
|
responseFormat: ToolStrategy<T>;
|
|
81
88
|
}): ReactAgent<StateSchema, T, ContextSchema>;
|
|
82
|
-
// Overload
|
|
89
|
+
// Overload 8: V1 - With responseFormat as ProviderStrategy
|
|
83
90
|
declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, T, ContextSchema, ProviderStrategy<T>> & {
|
|
84
91
|
responseFormat: ProviderStrategy<T>;
|
|
85
92
|
}): ReactAgent<StateSchema, T, ContextSchema>;
|
|
86
|
-
// Overload
|
|
93
|
+
// Overload 9: V1 - Without responseFormat property at all
|
|
87
94
|
declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: Omit<CreateAgentParams<StateSchema, ResponseFormatUndefined, ContextSchema, never>, "responseFormat">): ReactAgent<StateSchema, ResponseFormatUndefined, ContextSchema>;
|
|
88
|
-
// Overload
|
|
95
|
+
// Overload 10: V1 - With responseFormat explicitly undefined
|
|
89
96
|
declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: Omit<CreateAgentParams<StateSchema, ResponseFormatUndefined, ContextSchema, never>, "responseFormat"> & {
|
|
90
97
|
responseFormat?: undefined;
|
|
91
98
|
}): ReactAgent<StateSchema, ResponseFormatUndefined, ContextSchema>;
|
|
92
|
-
// Overload
|
|
93
|
-
declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, StructuredResponseFormat extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, StructuredResponseFormat, ContextSchema,
|
|
94
|
-
responseFormat:
|
|
99
|
+
// Overload 11: V1 - For other ResponseFormat values (failsafe)
|
|
100
|
+
declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, StructuredResponseFormat extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, StructuredResponseFormat, ContextSchema, any> & {
|
|
101
|
+
responseFormat: any;
|
|
95
102
|
}): ReactAgent<StateSchema, StructuredResponseFormat, ContextSchema>;
|
|
103
|
+
// ===== V2 OVERLOADS (WITH MIDDLEWARE) =====
|
|
104
|
+
// These overloads explicitly require the middlewares property
|
|
105
|
+
// Overload 12: With responseFormat as single InteropZodType and middlewares
|
|
106
|
+
declare function createAgent<T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParams$1<T, ContextSchema, InteropZodType<T>> & {
|
|
107
|
+
responseFormat: InteropZodType<T>;
|
|
108
|
+
middlewares: TMiddlewares;
|
|
109
|
+
}): ReactAgent$1<T, ContextSchema, TMiddlewares>;
|
|
110
|
+
// Overload 13: With responseFormat as array of InteropZodTypes and middlewares
|
|
111
|
+
declare function createAgent<T extends readonly InteropZodType<any>[], ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParams$1<ExtractZodArrayTypes<T> extends Record<string, any> ? ExtractZodArrayTypes<T> : Record<string, any>, ContextSchema, T> & {
|
|
112
|
+
responseFormat: T;
|
|
113
|
+
middlewares: TMiddlewares;
|
|
114
|
+
}): ReactAgent$1<ExtractZodArrayTypes<T> extends Record<string, any> ? ExtractZodArrayTypes<T> : Record<string, any>, ContextSchema, TMiddlewares>;
|
|
115
|
+
// Overload 14: With responseFormat as JsonSchemaFormat and middlewares
|
|
116
|
+
declare function createAgent<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParams$1<Record<string, unknown>, ContextSchema, JsonSchemaFormat> & {
|
|
117
|
+
responseFormat: JsonSchemaFormat;
|
|
118
|
+
middlewares: TMiddlewares;
|
|
119
|
+
}): ReactAgent$1<Record<string, unknown>, ContextSchema, TMiddlewares>;
|
|
120
|
+
// Overload 15: With responseFormat as array of JsonSchemaFormat and middlewares
|
|
121
|
+
declare function createAgent<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParams$1<Record<string, unknown>, ContextSchema, JsonSchemaFormat[]> & {
|
|
122
|
+
responseFormat: JsonSchemaFormat[];
|
|
123
|
+
middlewares: TMiddlewares;
|
|
124
|
+
}): ReactAgent$1<Record<string, unknown>, ContextSchema, TMiddlewares>;
|
|
125
|
+
// Overload 16: With responseFormat as union of JsonSchemaFormat | JsonSchemaFormat[] and middlewares
|
|
126
|
+
declare function createAgent<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParams$1<Record<string, unknown>, ContextSchema, JsonSchemaFormat | JsonSchemaFormat[]> & {
|
|
127
|
+
responseFormat: JsonSchemaFormat | JsonSchemaFormat[];
|
|
128
|
+
middlewares: TMiddlewares;
|
|
129
|
+
}): ReactAgent$1<Record<string, unknown>, ContextSchema, TMiddlewares>;
|
|
130
|
+
// Overload 17: With responseFormat as TypedToolStrategy and middlewares
|
|
131
|
+
declare function createAgent<T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParams$1<T, ContextSchema, TypedToolStrategy<T>> & {
|
|
132
|
+
responseFormat: TypedToolStrategy<T>;
|
|
133
|
+
middlewares: TMiddlewares;
|
|
134
|
+
}): ReactAgent$1<T, ContextSchema, TMiddlewares>;
|
|
135
|
+
// Overload 18: With responseFormat as single ToolStrategy and middlewares
|
|
136
|
+
declare function createAgent<T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParams$1<T, ContextSchema, ToolStrategy<T>> & {
|
|
137
|
+
responseFormat: ToolStrategy<T>;
|
|
138
|
+
middlewares: TMiddlewares;
|
|
139
|
+
}): ReactAgent$1<T, ContextSchema, TMiddlewares>;
|
|
140
|
+
// Overload 19: With responseFormat as ProviderStrategy and middlewares
|
|
141
|
+
declare function createAgent<T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParams$1<T, ContextSchema, ProviderStrategy<T>> & {
|
|
142
|
+
responseFormat: ProviderStrategy<T>;
|
|
143
|
+
middlewares: TMiddlewares;
|
|
144
|
+
}): ReactAgent$1<T, ContextSchema, TMiddlewares>;
|
|
145
|
+
// Overload 20: Without responseFormat but with middlewares
|
|
146
|
+
declare function createAgent<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: Omit<CreateAgentParams$1<ResponseFormatUndefined, ContextSchema, never>, "responseFormat"> & {
|
|
147
|
+
middlewares: TMiddlewares;
|
|
148
|
+
}): ReactAgent$1<ResponseFormatUndefined, ContextSchema, TMiddlewares>;
|
|
149
|
+
// Overload 21: With responseFormat explicitly undefined and middlewares
|
|
150
|
+
declare function createAgent<ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: Omit<CreateAgentParams$1<ResponseFormatUndefined, ContextSchema, never>, "responseFormat"> & {
|
|
151
|
+
responseFormat?: undefined;
|
|
152
|
+
middlewares: TMiddlewares;
|
|
153
|
+
}): ReactAgent$1<ResponseFormatUndefined, ContextSchema, TMiddlewares>;
|
|
154
|
+
// Overload 22: For other ResponseFormat values with middlewares (failsafe)
|
|
155
|
+
declare function createAgent<StructuredResponseFormat extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, TMiddlewares extends readonly AgentMiddleware<any, any, any>[] = readonly AgentMiddleware<any, any, any>[]>(params: CreateAgentParams$1<StructuredResponseFormat, ContextSchema, any> & {
|
|
156
|
+
responseFormat: any;
|
|
157
|
+
middlewares: TMiddlewares;
|
|
158
|
+
}): ReactAgent$1<StructuredResponseFormat, ContextSchema, TMiddlewares>;
|
|
96
159
|
//#endregion
|
|
97
160
|
export { createAgent };
|
|
98
161
|
//# sourceMappingURL=index.d.cts.map
|