langchain 0.0.101 → 0.0.103
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/agents/toolkits/aws_sfn.cjs +1 -0
- package/agents/toolkits/aws_sfn.d.ts +1 -0
- package/agents/toolkits/aws_sfn.js +1 -0
- package/agents/toolkits/sql.cjs +1 -0
- package/agents/toolkits/sql.d.ts +1 -0
- package/agents/toolkits/sql.js +1 -0
- package/chains/sql_db.cjs +1 -0
- package/chains/sql_db.d.ts +1 -0
- package/chains/sql_db.js +1 -0
- package/chat_models/baiduwenxin.cjs +1 -0
- package/chat_models/baiduwenxin.d.ts +1 -0
- package/chat_models/baiduwenxin.js +1 -0
- package/dist/agents/agent.d.ts +2 -2
- package/dist/agents/chat_convo/index.cjs +2 -2
- package/dist/agents/chat_convo/index.d.ts +2 -2
- package/dist/agents/chat_convo/index.js +3 -3
- package/dist/agents/index.cjs +3 -5
- package/dist/agents/index.d.ts +2 -2
- package/dist/agents/index.js +2 -2
- package/dist/agents/openai/index.cjs +4 -4
- package/dist/agents/openai/index.d.ts +2 -2
- package/dist/agents/openai/index.js +5 -5
- package/dist/agents/{agent_toolkits → toolkits}/index.cjs +1 -4
- package/dist/agents/{agent_toolkits → toolkits}/index.d.ts +0 -1
- package/dist/agents/{agent_toolkits → toolkits}/index.js +0 -1
- package/dist/agents/toolkits/sql/index.cjs +6 -0
- package/dist/agents/toolkits/sql/index.d.ts +1 -0
- package/dist/agents/toolkits/sql/index.js +1 -0
- package/dist/base_language/index.cjs +8 -1
- package/dist/base_language/index.d.ts +7 -8
- package/dist/base_language/index.js +8 -1
- package/dist/callbacks/base.d.ts +29 -29
- package/dist/callbacks/handlers/tracer.cjs +38 -8
- package/dist/callbacks/handlers/tracer.d.ts +10 -6
- package/dist/callbacks/handlers/tracer.js +39 -9
- package/dist/callbacks/handlers/tracer_langchain.cjs +1 -1
- package/dist/callbacks/handlers/tracer_langchain.d.ts +3 -3
- package/dist/callbacks/handlers/tracer_langchain.js +2 -2
- package/dist/callbacks/manager.cjs +82 -22
- package/dist/callbacks/manager.d.ts +28 -4
- package/dist/callbacks/manager.js +80 -21
- package/dist/chains/base.cjs +26 -14
- package/dist/chains/base.d.ts +7 -4
- package/dist/chains/base.js +27 -15
- package/dist/chains/constitutional_ai/constitutional_principle.d.ts +1 -1
- package/dist/chains/conversational_retrieval_chain.cjs +3 -3
- package/dist/chains/conversational_retrieval_chain.d.ts +2 -2
- package/dist/chains/conversational_retrieval_chain.js +3 -3
- package/dist/chains/index.cjs +1 -9
- package/dist/chains/index.d.ts +1 -3
- package/dist/chains/index.js +0 -2
- package/dist/chains/llm_chain.cjs +1 -1
- package/dist/chains/llm_chain.js +1 -1
- package/dist/chains/serde.d.ts +1 -7
- package/dist/chains/sql_db/index.cjs +11 -0
- package/dist/chains/sql_db/index.d.ts +2 -0
- package/dist/chains/sql_db/index.js +2 -0
- package/dist/chains/sql_db/sql_db_chain.cjs +0 -16
- package/dist/chains/sql_db/sql_db_chain.d.ts +0 -3
- package/dist/chains/sql_db/sql_db_chain.js +0 -16
- package/dist/chat_models/anthropic.cjs +2 -5
- package/dist/chat_models/anthropic.d.ts +2 -3
- package/dist/chat_models/anthropic.js +3 -6
- package/dist/chat_models/baiduwenxin.cjs +348 -0
- package/dist/chat_models/baiduwenxin.d.ts +114 -0
- package/dist/chat_models/baiduwenxin.js +344 -0
- package/dist/chat_models/base.cjs +13 -5
- package/dist/chat_models/base.d.ts +9 -9
- package/dist/chat_models/base.js +14 -6
- package/dist/chat_models/googlevertexai.cjs +3 -3
- package/dist/chat_models/googlevertexai.d.ts +6 -6
- package/dist/chat_models/googlevertexai.js +4 -4
- package/dist/chat_models/openai.cjs +31 -16
- package/dist/chat_models/openai.d.ts +6 -4
- package/dist/chat_models/openai.js +32 -17
- package/dist/client/langchainplus.cjs +48 -53
- package/dist/client/langchainplus.d.ts +4 -3
- package/dist/client/langchainplus.js +46 -54
- package/dist/document_loaders/web/apify_dataset.cjs +19 -0
- package/dist/document_loaders/web/apify_dataset.d.ts +14 -1
- package/dist/document_loaders/web/apify_dataset.js +19 -0
- package/dist/embeddings/openai.cjs +19 -4
- package/dist/embeddings/openai.d.ts +1 -0
- package/dist/embeddings/openai.js +19 -4
- package/dist/experimental/autogpt/agent.cjs +3 -3
- package/dist/experimental/autogpt/agent.d.ts +2 -2
- package/dist/experimental/autogpt/agent.js +4 -4
- package/dist/experimental/autogpt/prompt.cjs +8 -8
- package/dist/experimental/autogpt/prompt.d.ts +3 -3
- package/dist/experimental/autogpt/prompt.js +9 -9
- package/dist/llms/base.cjs +16 -8
- package/dist/llms/base.d.ts +5 -5
- package/dist/llms/base.js +17 -9
- package/dist/llms/openai-chat.cjs +24 -5
- package/dist/llms/openai-chat.d.ts +1 -0
- package/dist/llms/openai-chat.js +24 -5
- package/dist/llms/openai.cjs +20 -5
- package/dist/llms/openai.d.ts +1 -0
- package/dist/llms/openai.js +20 -5
- package/dist/load/import_constants.cjs +4 -1
- package/dist/load/import_constants.js +4 -1
- package/dist/load/import_map.cjs +2 -1
- package/dist/load/import_map.d.ts +1 -0
- package/dist/load/import_map.js +1 -0
- package/dist/memory/base.cjs +5 -1
- package/dist/memory/base.d.ts +2 -2
- package/dist/memory/base.js +5 -1
- package/dist/memory/summary.cjs +1 -1
- package/dist/memory/summary.d.ts +4 -4
- package/dist/memory/summary.js +2 -2
- package/dist/memory/zep.cjs +3 -3
- package/dist/memory/zep.js +4 -4
- package/dist/output_parsers/combining.cjs +15 -3
- package/dist/output_parsers/combining.d.ts +6 -1
- package/dist/output_parsers/combining.js +15 -3
- package/dist/output_parsers/fix.cjs +6 -0
- package/dist/output_parsers/fix.d.ts +1 -0
- package/dist/output_parsers/fix.js +6 -0
- package/dist/output_parsers/list.cjs +6 -0
- package/dist/output_parsers/list.d.ts +1 -0
- package/dist/output_parsers/list.js +6 -0
- package/dist/output_parsers/regex.cjs +35 -5
- package/dist/output_parsers/regex.d.ts +13 -0
- package/dist/output_parsers/regex.js +35 -5
- package/dist/prompts/base.cjs +1 -1
- package/dist/prompts/base.d.ts +2 -2
- package/dist/prompts/base.js +2 -2
- package/dist/prompts/chat.cjs +3 -3
- package/dist/prompts/chat.d.ts +15 -15
- package/dist/prompts/chat.js +4 -4
- package/dist/prompts/template.cjs +3 -2
- package/dist/prompts/template.js +3 -2
- package/dist/schema/index.cjs +84 -32
- package/dist/schema/index.d.ts +59 -19
- package/dist/schema/index.js +78 -26
- package/dist/stores/message/dynamodb.d.ts +3 -3
- package/dist/stores/message/in_memory.d.ts +4 -4
- package/dist/stores/message/in_memory.js +1 -1
- package/dist/stores/message/momento.d.ts +3 -3
- package/dist/stores/message/redis.d.ts +3 -3
- package/dist/stores/message/redis.js +1 -1
- package/dist/stores/message/upstash_redis.cjs +1 -9
- package/dist/stores/message/upstash_redis.d.ts +3 -3
- package/dist/stores/message/upstash_redis.js +1 -9
- package/dist/stores/message/utils.cjs +8 -7
- package/dist/stores/message/utils.d.ts +3 -3
- package/dist/stores/message/utils.js +9 -8
- package/dist/tools/base.cjs +5 -2
- package/dist/tools/base.d.ts +4 -2
- package/dist/tools/base.js +6 -3
- package/dist/tools/index.cjs +1 -6
- package/dist/tools/index.d.ts +0 -1
- package/dist/tools/index.js +0 -1
- package/dist/types/openai-types.d.ts +6 -5
- package/dist/util/azure.cjs +44 -0
- package/dist/util/azure.d.ts +30 -0
- package/dist/util/azure.js +40 -0
- package/dist/vectorstores/singlestore.cjs +69 -5
- package/dist/vectorstores/singlestore.d.ts +21 -5
- package/dist/vectorstores/singlestore.js +69 -5
- package/dist/vectorstores/typesense.cjs +9 -8
- package/dist/vectorstores/typesense.d.ts +5 -4
- package/dist/vectorstores/typesense.js +9 -8
- package/package.json +41 -9
- package/tools/sql.cjs +1 -0
- package/tools/sql.d.ts +1 -0
- package/tools/sql.js +1 -0
- package/agents/agent_toolkits/aws_sfn.cjs +0 -1
- package/agents/agent_toolkits/aws_sfn.d.ts +0 -1
- package/agents/agent_toolkits/aws_sfn.js +0 -1
- /package/dist/agents/{agent_toolkits → toolkits}/aws_sfn.cjs +0 -0
- /package/dist/agents/{agent_toolkits → toolkits}/aws_sfn.d.ts +0 -0
- /package/dist/agents/{agent_toolkits → toolkits}/aws_sfn.js +0 -0
- /package/dist/agents/{agent_toolkits → toolkits}/base.cjs +0 -0
- /package/dist/agents/{agent_toolkits → toolkits}/base.d.ts +0 -0
- /package/dist/agents/{agent_toolkits → toolkits}/base.js +0 -0
- /package/dist/agents/{agent_toolkits → toolkits}/json/json.cjs +0 -0
- /package/dist/agents/{agent_toolkits → toolkits}/json/json.d.ts +0 -0
- /package/dist/agents/{agent_toolkits → toolkits}/json/json.js +0 -0
- /package/dist/agents/{agent_toolkits → toolkits}/json/prompt.cjs +0 -0
- /package/dist/agents/{agent_toolkits → toolkits}/json/prompt.d.ts +0 -0
- /package/dist/agents/{agent_toolkits → toolkits}/json/prompt.js +0 -0
- /package/dist/agents/{agent_toolkits → toolkits}/openapi/openapi.cjs +0 -0
- /package/dist/agents/{agent_toolkits → toolkits}/openapi/openapi.d.ts +0 -0
- /package/dist/agents/{agent_toolkits → toolkits}/openapi/openapi.js +0 -0
- /package/dist/agents/{agent_toolkits → toolkits}/openapi/prompt.cjs +0 -0
- /package/dist/agents/{agent_toolkits → toolkits}/openapi/prompt.d.ts +0 -0
- /package/dist/agents/{agent_toolkits → toolkits}/openapi/prompt.js +0 -0
- /package/dist/agents/{agent_toolkits → toolkits}/sql/prompt.cjs +0 -0
- /package/dist/agents/{agent_toolkits → toolkits}/sql/prompt.d.ts +0 -0
- /package/dist/agents/{agent_toolkits → toolkits}/sql/prompt.js +0 -0
- /package/dist/agents/{agent_toolkits → toolkits}/sql/sql.cjs +0 -0
- /package/dist/agents/{agent_toolkits → toolkits}/sql/sql.d.ts +0 -0
- /package/dist/agents/{agent_toolkits → toolkits}/sql/sql.js +0 -0
- /package/dist/agents/{agent_toolkits → toolkits}/vectorstore/prompt.cjs +0 -0
- /package/dist/agents/{agent_toolkits → toolkits}/vectorstore/prompt.d.ts +0 -0
- /package/dist/agents/{agent_toolkits → toolkits}/vectorstore/prompt.js +0 -0
- /package/dist/agents/{agent_toolkits → toolkits}/vectorstore/vectorstore.cjs +0 -0
- /package/dist/agents/{agent_toolkits → toolkits}/vectorstore/vectorstore.d.ts +0 -0
- /package/dist/agents/{agent_toolkits → toolkits}/vectorstore/vectorstore.js +0 -0
- /package/dist/agents/{agent_toolkits → toolkits}/zapier/zapier.cjs +0 -0
- /package/dist/agents/{agent_toolkits → toolkits}/zapier/zapier.d.ts +0 -0
- /package/dist/agents/{agent_toolkits → toolkits}/zapier/zapier.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../../dist/agents/toolkits/aws_sfn.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../dist/agents/toolkits/aws_sfn.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../dist/agents/toolkits/aws_sfn.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../../dist/agents/toolkits/sql/index.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../dist/agents/toolkits/sql/index.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../dist/agents/toolkits/sql/index.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../dist/chains/sql_db/index.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/chains/sql_db/index.js'
|
package/chains/sql_db.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/chains/sql_db/index.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../dist/chat_models/baiduwenxin.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/chat_models/baiduwenxin.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/chat_models/baiduwenxin.js'
|
package/dist/agents/agent.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { BaseLanguageModel } from "../base_language/index.js";
|
|
|
2
2
|
import { CallbackManager, Callbacks } from "../callbacks/manager.js";
|
|
3
3
|
import { LLMChain } from "../chains/llm_chain.js";
|
|
4
4
|
import { BasePromptTemplate } from "../prompts/base.js";
|
|
5
|
-
import { AgentAction, AgentFinish, AgentStep,
|
|
5
|
+
import { AgentAction, AgentFinish, AgentStep, BaseMessage, ChainValues } from "../schema/index.js";
|
|
6
6
|
import { Serializable } from "../load/serializable.js";
|
|
7
7
|
import { StructuredTool, Tool } from "../tools/base.js";
|
|
8
8
|
import { AgentActionOutputParser, AgentInput, SerializedAgent, StoppingMethod } from "./types.js";
|
|
@@ -139,7 +139,7 @@ export declare abstract class Agent extends BaseSingleActionAgent {
|
|
|
139
139
|
/**
|
|
140
140
|
* Construct a scratchpad to let the agent continue its thought process
|
|
141
141
|
*/
|
|
142
|
-
constructScratchPad(steps: AgentStep[]): Promise<string |
|
|
142
|
+
constructScratchPad(steps: AgentStep[]): Promise<string | BaseMessage[]>;
|
|
143
143
|
private _plan;
|
|
144
144
|
/**
|
|
145
145
|
* Decide what to do given some input.
|
|
@@ -46,8 +46,8 @@ class ChatConversationalAgent extends agent_js_1.Agent {
|
|
|
46
46
|
async constructScratchPad(steps) {
|
|
47
47
|
const thoughts = [];
|
|
48
48
|
for (const step of steps) {
|
|
49
|
-
thoughts.push(new index_js_1.
|
|
50
|
-
thoughts.push(new index_js_1.
|
|
49
|
+
thoughts.push(new index_js_1.AIMessage(step.action.log));
|
|
50
|
+
thoughts.push(new index_js_1.HumanMessage((0, template_js_1.renderTemplate)(prompt_js_1.TEMPLATE_TOOL_RESPONSE, "f-string", {
|
|
51
51
|
observation: step.observation,
|
|
52
52
|
})));
|
|
53
53
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseLanguageModel } from "../../base_language/index.js";
|
|
2
2
|
import { ChatPromptTemplate } from "../../prompts/chat.js";
|
|
3
|
-
import { AgentStep,
|
|
3
|
+
import { AgentStep, BaseMessage } from "../../schema/index.js";
|
|
4
4
|
import { Tool } from "../../tools/base.js";
|
|
5
5
|
import { Optional } from "../../types/type-utils.js";
|
|
6
6
|
import { Agent, AgentArgs, OutputParserArgs } from "../agent.js";
|
|
@@ -29,7 +29,7 @@ export declare class ChatConversationalAgent extends Agent {
|
|
|
29
29
|
llmPrefix(): string;
|
|
30
30
|
_stop(): string[];
|
|
31
31
|
static validateTools(tools: Tool[]): void;
|
|
32
|
-
constructScratchPad(steps: AgentStep[]): Promise<
|
|
32
|
+
constructScratchPad(steps: AgentStep[]): Promise<BaseMessage[]>;
|
|
33
33
|
static getDefaultOutputParser(fields?: OutputParserArgs & {
|
|
34
34
|
toolNames: string[];
|
|
35
35
|
}): AgentActionOutputParser;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LLMChain } from "../../chains/llm_chain.js";
|
|
2
2
|
import { ChatPromptTemplate, HumanMessagePromptTemplate, MessagesPlaceholder, SystemMessagePromptTemplate, } from "../../prompts/chat.js";
|
|
3
3
|
import { renderTemplate } from "../../prompts/template.js";
|
|
4
|
-
import {
|
|
4
|
+
import { AIMessage, HumanMessage, } from "../../schema/index.js";
|
|
5
5
|
import { Agent } from "../agent.js";
|
|
6
6
|
import { ChatConversationalAgentOutputParserWithRetries } from "./outputParser.js";
|
|
7
7
|
import { PREFIX_END, DEFAULT_PREFIX, DEFAULT_SUFFIX, TEMPLATE_TOOL_RESPONSE, } from "./prompt.js";
|
|
@@ -43,8 +43,8 @@ export class ChatConversationalAgent extends Agent {
|
|
|
43
43
|
async constructScratchPad(steps) {
|
|
44
44
|
const thoughts = [];
|
|
45
45
|
for (const step of steps) {
|
|
46
|
-
thoughts.push(new
|
|
47
|
-
thoughts.push(new
|
|
46
|
+
thoughts.push(new AIMessage(step.action.log));
|
|
47
|
+
thoughts.push(new HumanMessage(renderTemplate(TEMPLATE_TOOL_RESPONSE, "f-string", {
|
|
48
48
|
observation: step.observation,
|
|
49
49
|
})));
|
|
50
50
|
}
|
package/dist/agents/index.cjs
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OpenAIAgent = exports.StructuredChatOutputParserWithRetries = exports.StructuredChatOutputParser = exports.StructuredChatAgent = exports.AgentActionOutputParser = exports.ZeroShotAgentOutputParser = exports.ZeroShotAgent = exports.initializeAgentExecutorWithOptions = exports.initializeAgentExecutor = exports.AgentExecutor = exports.ChatConversationalAgentOutputParserWithRetries = exports.ChatConversationalAgentOutputParser = exports.ChatConversationalAgent = exports.ChatAgentOutputParser = exports.ChatAgent = exports.Toolkit = exports.createVectorStoreRouterAgent = exports.createVectorStoreAgent = exports.
|
|
3
|
+
exports.OpenAIAgent = exports.StructuredChatOutputParserWithRetries = exports.StructuredChatOutputParser = exports.StructuredChatAgent = exports.AgentActionOutputParser = exports.ZeroShotAgentOutputParser = exports.ZeroShotAgent = exports.initializeAgentExecutorWithOptions = exports.initializeAgentExecutor = exports.AgentExecutor = exports.ChatConversationalAgentOutputParserWithRetries = exports.ChatConversationalAgentOutputParser = exports.ChatConversationalAgent = exports.ChatAgentOutputParser = exports.ChatAgent = exports.Toolkit = exports.createVectorStoreRouterAgent = exports.createVectorStoreAgent = exports.createOpenApiAgent = exports.createJsonAgent = exports.ZapierToolKit = exports.VectorStoreToolkit = exports.VectorStoreRouterToolkit = exports.RequestsToolkit = exports.OpenApiToolkit = exports.JsonToolkit = exports.LLMSingleActionAgent = exports.BaseSingleActionAgent = exports.Agent = void 0;
|
|
4
4
|
var agent_js_1 = require("./agent.cjs");
|
|
5
5
|
Object.defineProperty(exports, "Agent", { enumerable: true, get: function () { return agent_js_1.Agent; } });
|
|
6
6
|
Object.defineProperty(exports, "BaseSingleActionAgent", { enumerable: true, get: function () { return agent_js_1.BaseSingleActionAgent; } });
|
|
7
7
|
Object.defineProperty(exports, "LLMSingleActionAgent", { enumerable: true, get: function () { return agent_js_1.LLMSingleActionAgent; } });
|
|
8
|
-
var index_js_1 = require("./
|
|
8
|
+
var index_js_1 = require("./toolkits/index.cjs");
|
|
9
9
|
Object.defineProperty(exports, "JsonToolkit", { enumerable: true, get: function () { return index_js_1.JsonToolkit; } });
|
|
10
10
|
Object.defineProperty(exports, "OpenApiToolkit", { enumerable: true, get: function () { return index_js_1.OpenApiToolkit; } });
|
|
11
11
|
Object.defineProperty(exports, "RequestsToolkit", { enumerable: true, get: function () { return index_js_1.RequestsToolkit; } });
|
|
12
|
-
Object.defineProperty(exports, "SqlToolkit", { enumerable: true, get: function () { return index_js_1.SqlToolkit; } });
|
|
13
12
|
Object.defineProperty(exports, "VectorStoreRouterToolkit", { enumerable: true, get: function () { return index_js_1.VectorStoreRouterToolkit; } });
|
|
14
13
|
Object.defineProperty(exports, "VectorStoreToolkit", { enumerable: true, get: function () { return index_js_1.VectorStoreToolkit; } });
|
|
15
14
|
Object.defineProperty(exports, "ZapierToolKit", { enumerable: true, get: function () { return index_js_1.ZapierToolKit; } });
|
|
16
15
|
Object.defineProperty(exports, "createJsonAgent", { enumerable: true, get: function () { return index_js_1.createJsonAgent; } });
|
|
17
16
|
Object.defineProperty(exports, "createOpenApiAgent", { enumerable: true, get: function () { return index_js_1.createOpenApiAgent; } });
|
|
18
|
-
Object.defineProperty(exports, "createSqlAgent", { enumerable: true, get: function () { return index_js_1.createSqlAgent; } });
|
|
19
17
|
Object.defineProperty(exports, "createVectorStoreAgent", { enumerable: true, get: function () { return index_js_1.createVectorStoreAgent; } });
|
|
20
18
|
Object.defineProperty(exports, "createVectorStoreRouterAgent", { enumerable: true, get: function () { return index_js_1.createVectorStoreRouterAgent; } });
|
|
21
|
-
var base_js_1 = require("./
|
|
19
|
+
var base_js_1 = require("./toolkits/base.cjs");
|
|
22
20
|
Object.defineProperty(exports, "Toolkit", { enumerable: true, get: function () { return base_js_1.Toolkit; } });
|
|
23
21
|
var index_js_2 = require("./chat/index.cjs");
|
|
24
22
|
Object.defineProperty(exports, "ChatAgent", { enumerable: true, get: function () { return index_js_2.ChatAgent; } });
|
package/dist/agents/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { Agent, AgentArgs, BaseSingleActionAgent, LLMSingleActionAgent, LLMSingleActionAgentInput, OutputParserArgs, } from "./agent.js";
|
|
2
|
-
export { JsonToolkit, OpenApiToolkit, RequestsToolkit,
|
|
3
|
-
export { Toolkit } from "./
|
|
2
|
+
export { JsonToolkit, OpenApiToolkit, RequestsToolkit, VectorStoreInfo, VectorStoreRouterToolkit, VectorStoreToolkit, ZapierToolKit, createJsonAgent, createOpenApiAgent, createVectorStoreAgent, createVectorStoreRouterAgent, } from "./toolkits/index.js";
|
|
3
|
+
export { Toolkit } from "./toolkits/base.js";
|
|
4
4
|
export { ChatAgent, ChatAgentInput, ChatCreatePromptArgs, } from "./chat/index.js";
|
|
5
5
|
export { ChatAgentOutputParser } from "./chat/outputParser.js";
|
|
6
6
|
export { ChatConversationalAgent, ChatConversationalAgentInput, ChatConversationalCreatePromptArgs, } from "./chat_convo/index.js";
|
package/dist/agents/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { Agent, BaseSingleActionAgent, LLMSingleActionAgent, } from "./agent.js";
|
|
2
|
-
export { JsonToolkit, OpenApiToolkit, RequestsToolkit,
|
|
3
|
-
export { Toolkit } from "./
|
|
2
|
+
export { JsonToolkit, OpenApiToolkit, RequestsToolkit, VectorStoreRouterToolkit, VectorStoreToolkit, ZapierToolKit, createJsonAgent, createOpenApiAgent, createVectorStoreAgent, createVectorStoreRouterAgent, } from "./toolkits/index.js";
|
|
3
|
+
export { Toolkit } from "./toolkits/base.js";
|
|
4
4
|
export { ChatAgent, } from "./chat/index.js";
|
|
5
5
|
export { ChatAgentOutputParser } from "./chat/outputParser.js";
|
|
6
6
|
export { ChatConversationalAgent, } from "./chat_convo/index.js";
|
|
@@ -15,11 +15,11 @@ function parseOutput(message) {
|
|
|
15
15
|
toolInput: function_call.arguments
|
|
16
16
|
? JSON.parse(function_call.arguments)
|
|
17
17
|
: {},
|
|
18
|
-
log: message.
|
|
18
|
+
log: message.content,
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
else {
|
|
22
|
-
return { returnValues: { output: message.
|
|
22
|
+
return { returnValues: { output: message.content }, log: message.content };
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
class OpenAIAgent extends agent_js_1.Agent {
|
|
@@ -79,13 +79,13 @@ class OpenAIAgent extends agent_js_1.Agent {
|
|
|
79
79
|
}
|
|
80
80
|
async constructScratchPad(steps) {
|
|
81
81
|
return steps.flatMap(({ action, observation }) => [
|
|
82
|
-
new index_js_1.
|
|
82
|
+
new index_js_1.AIMessage("", {
|
|
83
83
|
function_call: {
|
|
84
84
|
name: action.tool,
|
|
85
85
|
arguments: JSON.stringify(action.toolInput),
|
|
86
86
|
},
|
|
87
87
|
}),
|
|
88
|
-
new index_js_1.
|
|
88
|
+
new index_js_1.FunctionMessage(observation, action.tool),
|
|
89
89
|
]);
|
|
90
90
|
}
|
|
91
91
|
async plan(steps, inputs, callbackManager) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CallbackManager } from "../../callbacks/manager.js";
|
|
2
2
|
import { BasePromptTemplate } from "../../prompts/base.js";
|
|
3
|
-
import { AgentAction, AgentFinish, AgentStep,
|
|
3
|
+
import { AgentAction, AgentFinish, AgentStep, BaseMessage, ChainValues } from "../../schema/index.js";
|
|
4
4
|
import { StructuredTool } from "../../tools/base.js";
|
|
5
5
|
import { Agent, AgentArgs } from "../agent.js";
|
|
6
6
|
import { AgentInput } from "../types.js";
|
|
@@ -21,6 +21,6 @@ export declare class OpenAIAgent extends Agent {
|
|
|
21
21
|
constructor(input: Omit<OpenAIAgentInput, "outputParser">);
|
|
22
22
|
static createPrompt(_tools: StructuredTool[], fields?: OpenAIAgentCreatePromptArgs): BasePromptTemplate;
|
|
23
23
|
static fromLLMAndTools(llm: BaseLanguageModel, tools: StructuredTool[], args?: OpenAIAgentCreatePromptArgs & Pick<AgentArgs, "callbacks">): OpenAIAgent;
|
|
24
|
-
constructScratchPad(steps: AgentStep[]): Promise<string |
|
|
24
|
+
constructScratchPad(steps: AgentStep[]): Promise<string | BaseMessage[]>;
|
|
25
25
|
plan(steps: Array<AgentStep>, inputs: ChainValues, callbackManager?: CallbackManager): Promise<AgentAction | AgentFinish>;
|
|
26
26
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AIMessage, FunctionMessage, } from "../../schema/index.js";
|
|
2
2
|
import { Agent } from "../agent.js";
|
|
3
3
|
import { PREFIX } from "./prompt.js";
|
|
4
4
|
import { ChatPromptTemplate, HumanMessagePromptTemplate, MessagesPlaceholder, SystemMessagePromptTemplate, } from "../../prompts/chat.js";
|
|
@@ -12,11 +12,11 @@ function parseOutput(message) {
|
|
|
12
12
|
toolInput: function_call.arguments
|
|
13
13
|
? JSON.parse(function_call.arguments)
|
|
14
14
|
: {},
|
|
15
|
-
log: message.
|
|
15
|
+
log: message.content,
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
else {
|
|
19
|
-
return { returnValues: { output: message.
|
|
19
|
+
return { returnValues: { output: message.content }, log: message.content };
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
export class OpenAIAgent extends Agent {
|
|
@@ -76,13 +76,13 @@ export class OpenAIAgent extends Agent {
|
|
|
76
76
|
}
|
|
77
77
|
async constructScratchPad(steps) {
|
|
78
78
|
return steps.flatMap(({ action, observation }) => [
|
|
79
|
-
new
|
|
79
|
+
new AIMessage("", {
|
|
80
80
|
function_call: {
|
|
81
81
|
name: action.tool,
|
|
82
82
|
arguments: JSON.stringify(action.toolInput),
|
|
83
83
|
},
|
|
84
84
|
}),
|
|
85
|
-
new
|
|
85
|
+
new FunctionMessage(observation, action.tool),
|
|
86
86
|
]);
|
|
87
87
|
}
|
|
88
88
|
async plan(steps, inputs, callbackManager) {
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ZapierToolKit = exports.createVectorStoreRouterAgent = exports.createVectorStoreAgent = exports.VectorStoreRouterToolkit = exports.VectorStoreToolkit = exports.createOpenApiAgent = exports.OpenApiToolkit = exports.RequestsToolkit = exports.
|
|
3
|
+
exports.ZapierToolKit = exports.createVectorStoreRouterAgent = exports.createVectorStoreAgent = exports.VectorStoreRouterToolkit = exports.VectorStoreToolkit = exports.createOpenApiAgent = exports.OpenApiToolkit = exports.RequestsToolkit = exports.createJsonAgent = exports.JsonToolkit = void 0;
|
|
4
4
|
var json_js_1 = require("./json/json.cjs");
|
|
5
5
|
Object.defineProperty(exports, "JsonToolkit", { enumerable: true, get: function () { return json_js_1.JsonToolkit; } });
|
|
6
6
|
Object.defineProperty(exports, "createJsonAgent", { enumerable: true, get: function () { return json_js_1.createJsonAgent; } });
|
|
7
|
-
var sql_js_1 = require("./sql/sql.cjs");
|
|
8
|
-
Object.defineProperty(exports, "SqlToolkit", { enumerable: true, get: function () { return sql_js_1.SqlToolkit; } });
|
|
9
|
-
Object.defineProperty(exports, "createSqlAgent", { enumerable: true, get: function () { return sql_js_1.createSqlAgent; } });
|
|
10
7
|
var openapi_js_1 = require("./openapi/openapi.cjs");
|
|
11
8
|
Object.defineProperty(exports, "RequestsToolkit", { enumerable: true, get: function () { return openapi_js_1.RequestsToolkit; } });
|
|
12
9
|
Object.defineProperty(exports, "OpenApiToolkit", { enumerable: true, get: function () { return openapi_js_1.OpenApiToolkit; } });
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { JsonToolkit, createJsonAgent } from "./json/json.js";
|
|
2
|
-
export { SqlToolkit, createSqlAgent, SqlCreatePromptArgs } from "./sql/sql.js";
|
|
3
2
|
export { RequestsToolkit, OpenApiToolkit, createOpenApiAgent, } from "./openapi/openapi.js";
|
|
4
3
|
export { VectorStoreInfo, VectorStoreToolkit, VectorStoreRouterToolkit, createVectorStoreAgent, createVectorStoreRouterAgent, } from "./vectorstore/vectorstore.js";
|
|
5
4
|
export { ZapierToolKit } from "./zapier/zapier.js";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { JsonToolkit, createJsonAgent } from "./json/json.js";
|
|
2
|
-
export { SqlToolkit, createSqlAgent } from "./sql/sql.js";
|
|
3
2
|
export { RequestsToolkit, OpenApiToolkit, createOpenApiAgent, } from "./openapi/openapi.js";
|
|
4
3
|
export { VectorStoreToolkit, VectorStoreRouterToolkit, createVectorStoreAgent, createVectorStoreRouterAgent, } from "./vectorstore/vectorstore.js";
|
|
5
4
|
export { ZapierToolKit } from "./zapier/zapier.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSqlAgent = exports.SqlToolkit = void 0;
|
|
4
|
+
var sql_js_1 = require("./sql.cjs");
|
|
5
|
+
Object.defineProperty(exports, "SqlToolkit", { enumerable: true, get: function () { return sql_js_1.SqlToolkit; } });
|
|
6
|
+
Object.defineProperty(exports, "createSqlAgent", { enumerable: true, get: function () { return sql_js_1.createSqlAgent; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SqlCreatePromptArgs, SqlToolkit, createSqlAgent } from "./sql.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SqlToolkit, createSqlAgent } from "./sql.js";
|
|
@@ -39,9 +39,16 @@ class BaseLangChain extends serializable_js_1.Serializable {
|
|
|
39
39
|
writable: true,
|
|
40
40
|
value: void 0
|
|
41
41
|
});
|
|
42
|
+
Object.defineProperty(this, "metadata", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
configurable: true,
|
|
45
|
+
writable: true,
|
|
46
|
+
value: void 0
|
|
47
|
+
});
|
|
42
48
|
this.verbose = params.verbose ?? getVerbosity();
|
|
43
49
|
this.callbacks = params.callbacks;
|
|
44
50
|
this.tags = params.tags ?? [];
|
|
51
|
+
this.metadata = params.metadata ?? {};
|
|
45
52
|
}
|
|
46
53
|
}
|
|
47
54
|
exports.BaseLangChain = BaseLangChain;
|
|
@@ -53,7 +60,7 @@ class BaseLanguageModel extends BaseLangChain {
|
|
|
53
60
|
* Keys that the language model accepts as call options.
|
|
54
61
|
*/
|
|
55
62
|
get callKeys() {
|
|
56
|
-
return ["stop", "timeout", "signal"];
|
|
63
|
+
return ["stop", "timeout", "signal", "tags", "metadata", "callbacks"];
|
|
57
64
|
}
|
|
58
65
|
constructor({ callbacks, callbackManager, ...params }) {
|
|
59
66
|
super({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CallbackManager, Callbacks } from "../callbacks/manager.js";
|
|
1
|
+
import { BaseMessage, BasePromptValue, LLMResult } from "../schema/index.js";
|
|
2
|
+
import { BaseCallbackConfig, CallbackManager, Callbacks } from "../callbacks/manager.js";
|
|
3
3
|
import { AsyncCaller, AsyncCallerParams } from "../util/async_caller.js";
|
|
4
4
|
import { Serializable } from "../load/serializable.js";
|
|
5
5
|
export type SerializedLLM = {
|
|
@@ -10,6 +10,7 @@ export interface BaseLangChainParams {
|
|
|
10
10
|
verbose?: boolean;
|
|
11
11
|
callbacks?: Callbacks;
|
|
12
12
|
tags?: string[];
|
|
13
|
+
metadata?: Record<string, unknown>;
|
|
13
14
|
}
|
|
14
15
|
/**
|
|
15
16
|
* Base class for language models, chains, tools.
|
|
@@ -21,6 +22,7 @@ export declare abstract class BaseLangChain extends Serializable implements Base
|
|
|
21
22
|
verbose: boolean;
|
|
22
23
|
callbacks?: Callbacks;
|
|
23
24
|
tags?: string[];
|
|
25
|
+
metadata?: Record<string, unknown>;
|
|
24
26
|
get lc_attributes(): {
|
|
25
27
|
[key: string]: undefined;
|
|
26
28
|
} | undefined;
|
|
@@ -37,7 +39,7 @@ export interface BaseLanguageModelParams extends AsyncCallerParams, BaseLangChai
|
|
|
37
39
|
*/
|
|
38
40
|
callbackManager?: CallbackManager;
|
|
39
41
|
}
|
|
40
|
-
export interface BaseLanguageModelCallOptions {
|
|
42
|
+
export interface BaseLanguageModelCallOptions extends BaseCallbackConfig {
|
|
41
43
|
/**
|
|
42
44
|
* Stop tokens to use for this call.
|
|
43
45
|
* If not provided, the default stop tokens for the model will be used.
|
|
@@ -50,12 +52,9 @@ export interface BaseLanguageModelCallOptions {
|
|
|
50
52
|
/**
|
|
51
53
|
* Abort signal for this call.
|
|
52
54
|
* If provided, the call will be aborted when the signal is aborted.
|
|
55
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal
|
|
53
56
|
*/
|
|
54
57
|
signal?: AbortSignal;
|
|
55
|
-
/**
|
|
56
|
-
* Tags to attach to this call.
|
|
57
|
-
*/
|
|
58
|
-
tags?: string[];
|
|
59
58
|
}
|
|
60
59
|
/**
|
|
61
60
|
* Base class for language models.
|
|
@@ -74,7 +73,7 @@ export declare abstract class BaseLanguageModel extends BaseLangChain implements
|
|
|
74
73
|
constructor({ callbacks, callbackManager, ...params }: BaseLanguageModelParams);
|
|
75
74
|
abstract generatePrompt(promptValues: BasePromptValue[], options?: string[] | this["CallOptions"], callbacks?: Callbacks): Promise<LLMResult>;
|
|
76
75
|
abstract predict(text: string, options?: string[] | this["CallOptions"], callbacks?: Callbacks): Promise<string>;
|
|
77
|
-
abstract predictMessages(messages:
|
|
76
|
+
abstract predictMessages(messages: BaseMessage[], options?: string[] | this["CallOptions"], callbacks?: Callbacks): Promise<BaseMessage>;
|
|
78
77
|
abstract _modelType(): string;
|
|
79
78
|
abstract _llmType(): string;
|
|
80
79
|
private _encoding?;
|
|
@@ -36,9 +36,16 @@ export class BaseLangChain extends Serializable {
|
|
|
36
36
|
writable: true,
|
|
37
37
|
value: void 0
|
|
38
38
|
});
|
|
39
|
+
Object.defineProperty(this, "metadata", {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
configurable: true,
|
|
42
|
+
writable: true,
|
|
43
|
+
value: void 0
|
|
44
|
+
});
|
|
39
45
|
this.verbose = params.verbose ?? getVerbosity();
|
|
40
46
|
this.callbacks = params.callbacks;
|
|
41
47
|
this.tags = params.tags ?? [];
|
|
48
|
+
this.metadata = params.metadata ?? {};
|
|
42
49
|
}
|
|
43
50
|
}
|
|
44
51
|
/**
|
|
@@ -49,7 +56,7 @@ export class BaseLanguageModel extends BaseLangChain {
|
|
|
49
56
|
* Keys that the language model accepts as call options.
|
|
50
57
|
*/
|
|
51
58
|
get callKeys() {
|
|
52
|
-
return ["stop", "timeout", "signal"];
|
|
59
|
+
return ["stop", "timeout", "signal", "tags", "metadata", "callbacks"];
|
|
53
60
|
}
|
|
54
61
|
constructor({ callbacks, callbackManager, ...params }) {
|
|
55
62
|
super({
|
package/dist/callbacks/base.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentAction, AgentFinish,
|
|
1
|
+
import { AgentAction, AgentFinish, BaseMessage, ChainValues, LLMResult } from "../schema/index.js";
|
|
2
2
|
import { Serializable, Serialized, SerializedNotImplemented } from "../load/serializable.js";
|
|
3
3
|
import { SerializedFields } from "../load/map_keys.js";
|
|
4
4
|
type Error = any;
|
|
@@ -16,7 +16,7 @@ declare abstract class BaseCallbackHandlerMethodsClass {
|
|
|
16
16
|
* Called at the start of an LLM or Chat Model run, with the prompt(s)
|
|
17
17
|
* and the run ID.
|
|
18
18
|
*/
|
|
19
|
-
handleLLMStart?(llm: Serialized, prompts: string[], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[]): Promise<void> | void;
|
|
19
|
+
handleLLMStart?(llm: Serialized, prompts: string[], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>): Promise<void> | void;
|
|
20
20
|
/**
|
|
21
21
|
* Called when an LLM/ChatModel in `streaming` mode produces a new token
|
|
22
22
|
*/
|
|
@@ -27,57 +27,57 @@ declare abstract class BaseCallbackHandlerMethodsClass {
|
|
|
27
27
|
* idx.completion is the index of the completion that produced the token
|
|
28
28
|
* (if multiple completions per prompt are requested)
|
|
29
29
|
*/
|
|
30
|
-
idx: NewTokenIndices, runId: string, parentRunId?: string): Promise<void> | void;
|
|
30
|
+
idx: NewTokenIndices, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;
|
|
31
31
|
/**
|
|
32
32
|
* Called if an LLM/ChatModel run encounters an error
|
|
33
33
|
*/
|
|
34
|
-
handleLLMError?(err: Error, runId: string, parentRunId?: string): Promise<void> | void;
|
|
34
|
+
handleLLMError?(err: Error, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;
|
|
35
35
|
/**
|
|
36
36
|
* Called at the end of an LLM/ChatModel run, with the output and the run ID.
|
|
37
37
|
*/
|
|
38
|
-
handleLLMEnd?(output: LLMResult, runId: string, parentRunId?: string): Promise<void> | void;
|
|
38
|
+
handleLLMEnd?(output: LLMResult, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;
|
|
39
39
|
/**
|
|
40
40
|
* Called at the start of a Chat Model run, with the prompt(s)
|
|
41
41
|
* and the run ID.
|
|
42
42
|
*/
|
|
43
|
-
handleChatModelStart?(llm: Serialized, messages:
|
|
43
|
+
handleChatModelStart?(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string, extraParams?: Record<string, unknown>, tags?: string[], metadata?: Record<string, unknown>): Promise<void> | void;
|
|
44
44
|
/**
|
|
45
45
|
* Called at the start of a Chain run, with the chain name and inputs
|
|
46
46
|
* and the run ID.
|
|
47
47
|
*/
|
|
48
|
-
handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;
|
|
48
|
+
handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>): Promise<void> | void;
|
|
49
49
|
/**
|
|
50
50
|
* Called if a Chain run encounters an error
|
|
51
51
|
*/
|
|
52
|
-
handleChainError?(err: Error, runId: string, parentRunId?: string): Promise<void> | void;
|
|
52
|
+
handleChainError?(err: Error, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;
|
|
53
53
|
/**
|
|
54
54
|
* Called at the end of a Chain run, with the outputs and the run ID.
|
|
55
55
|
*/
|
|
56
|
-
handleChainEnd?(outputs: ChainValues, runId: string, parentRunId?: string): Promise<void> | void;
|
|
56
|
+
handleChainEnd?(outputs: ChainValues, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;
|
|
57
57
|
/**
|
|
58
58
|
* Called at the start of a Tool run, with the tool name and input
|
|
59
59
|
* and the run ID.
|
|
60
60
|
*/
|
|
61
|
-
handleToolStart?(tool: Serialized, input: string, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;
|
|
61
|
+
handleToolStart?(tool: Serialized, input: string, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>): Promise<void> | void;
|
|
62
62
|
/**
|
|
63
63
|
* Called if a Tool run encounters an error
|
|
64
64
|
*/
|
|
65
|
-
handleToolError?(err: Error, runId: string, parentRunId?: string): Promise<void> | void;
|
|
65
|
+
handleToolError?(err: Error, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;
|
|
66
66
|
/**
|
|
67
67
|
* Called at the end of a Tool run, with the tool output and the run ID.
|
|
68
68
|
*/
|
|
69
|
-
handleToolEnd?(output: string, runId: string, parentRunId?: string): Promise<void> | void;
|
|
70
|
-
handleText?(text: string, runId: string, parentRunId?: string): Promise<void> | void;
|
|
69
|
+
handleToolEnd?(output: string, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;
|
|
70
|
+
handleText?(text: string, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;
|
|
71
71
|
/**
|
|
72
72
|
* Called when an agent is about to execute an action,
|
|
73
73
|
* with the action and the run ID.
|
|
74
74
|
*/
|
|
75
|
-
handleAgentAction?(action: AgentAction, runId: string, parentRunId?: string): Promise<void> | void;
|
|
75
|
+
handleAgentAction?(action: AgentAction, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;
|
|
76
76
|
/**
|
|
77
77
|
* Called when an agent finishes execution, before it exits.
|
|
78
78
|
* with the final output and the run ID.
|
|
79
79
|
*/
|
|
80
|
-
handleAgentEnd?(action: AgentFinish, runId: string, parentRunId?: string): Promise<void> | void;
|
|
80
|
+
handleAgentEnd?(action: AgentFinish, runId: string, parentRunId?: string, tags?: string[]): Promise<void> | void;
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
83
|
* Base interface for callbacks. All methods are optional. If a method is not
|
|
@@ -136,61 +136,61 @@ export declare abstract class BaseCallbackHandler extends BaseCallbackHandlerMet
|
|
|
136
136
|
* Called at the start of an LLM or Chat Model run, with the prompt(s)
|
|
137
137
|
* and the run ID.
|
|
138
138
|
*/
|
|
139
|
-
handleLLMStart?(llm: Serialized, prompts: string[], runId: string, parentRunId?: string | undefined, extraParams?: Record<string, unknown> | undefined, tags?: string[] | undefined): void | Promise<void>;
|
|
139
|
+
handleLLMStart?(llm: Serialized, prompts: string[], runId: string, parentRunId?: string | undefined, extraParams?: Record<string, unknown> | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined): void | Promise<void>;
|
|
140
140
|
/**
|
|
141
141
|
* Called when an LLM/ChatModel in `streaming` mode produces a new token
|
|
142
142
|
*/
|
|
143
|
-
handleLLMNewToken?(token: string, idx: NewTokenIndices, runId: string, parentRunId?: string | undefined): void | Promise<void>;
|
|
143
|
+
handleLLMNewToken?(token: string, idx: NewTokenIndices, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;
|
|
144
144
|
/**
|
|
145
145
|
* Called if an LLM/ChatModel run encounters an error
|
|
146
146
|
*/
|
|
147
|
-
handleLLMError?(err: any, runId: string, parentRunId?: string | undefined): void | Promise<void>;
|
|
147
|
+
handleLLMError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;
|
|
148
148
|
/**
|
|
149
149
|
* Called at the end of an LLM/ChatModel run, with the output and the run ID.
|
|
150
150
|
*/
|
|
151
|
-
handleLLMEnd?(output: LLMResult, runId: string, parentRunId?: string | undefined): void | Promise<void>;
|
|
151
|
+
handleLLMEnd?(output: LLMResult, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;
|
|
152
152
|
/**
|
|
153
153
|
* Called at the start of a Chat Model run, with the prompt(s)
|
|
154
154
|
* and the run ID.
|
|
155
155
|
*/
|
|
156
|
-
handleChatModelStart?(llm: Serialized, messages:
|
|
156
|
+
handleChatModelStart?(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string | undefined, extraParams?: Record<string, unknown> | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined): void | Promise<void>;
|
|
157
157
|
/**
|
|
158
158
|
* Called at the start of a Chain run, with the chain name and inputs
|
|
159
159
|
* and the run ID.
|
|
160
160
|
*/
|
|
161
|
-
handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;
|
|
161
|
+
handleChainStart?(chain: Serialized, inputs: ChainValues, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined): void | Promise<void>;
|
|
162
162
|
/**
|
|
163
163
|
* Called if a Chain run encounters an error
|
|
164
164
|
*/
|
|
165
|
-
handleChainError?(err: any, runId: string, parentRunId?: string | undefined): void | Promise<void>;
|
|
165
|
+
handleChainError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;
|
|
166
166
|
/**
|
|
167
167
|
* Called at the end of a Chain run, with the outputs and the run ID.
|
|
168
168
|
*/
|
|
169
|
-
handleChainEnd?(outputs: ChainValues, runId: string, parentRunId?: string | undefined): void | Promise<void>;
|
|
169
|
+
handleChainEnd?(outputs: ChainValues, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;
|
|
170
170
|
/**
|
|
171
171
|
* Called at the start of a Tool run, with the tool name and input
|
|
172
172
|
* and the run ID.
|
|
173
173
|
*/
|
|
174
|
-
handleToolStart?(tool: Serialized, input: string, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;
|
|
174
|
+
handleToolStart?(tool: Serialized, input: string, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined, metadata?: Record<string, unknown> | undefined): void | Promise<void>;
|
|
175
175
|
/**
|
|
176
176
|
* Called if a Tool run encounters an error
|
|
177
177
|
*/
|
|
178
|
-
handleToolError?(err: any, runId: string, parentRunId?: string | undefined): void | Promise<void>;
|
|
178
|
+
handleToolError?(err: any, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;
|
|
179
179
|
/**
|
|
180
180
|
* Called at the end of a Tool run, with the tool output and the run ID.
|
|
181
181
|
*/
|
|
182
|
-
handleToolEnd?(output: string, runId: string, parentRunId?: string | undefined): void | Promise<void>;
|
|
183
|
-
handleText?(text: string, runId: string, parentRunId?: string | undefined): void | Promise<void>;
|
|
182
|
+
handleToolEnd?(output: string, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;
|
|
183
|
+
handleText?(text: string, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;
|
|
184
184
|
/**
|
|
185
185
|
* Called when an agent is about to execute an action,
|
|
186
186
|
* with the action and the run ID.
|
|
187
187
|
*/
|
|
188
|
-
handleAgentAction?(action: AgentAction, runId: string, parentRunId?: string | undefined): void | Promise<void>;
|
|
188
|
+
handleAgentAction?(action: AgentAction, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;
|
|
189
189
|
/**
|
|
190
190
|
* Called when an agent finishes execution, before it exits.
|
|
191
191
|
* with the final output and the run ID.
|
|
192
192
|
*/
|
|
193
|
-
handleAgentEnd?(action: AgentFinish, runId: string, parentRunId?: string | undefined): void | Promise<void>;
|
|
193
|
+
handleAgentEnd?(action: AgentFinish, runId: string, parentRunId?: string | undefined, tags?: string[] | undefined): void | Promise<void>;
|
|
194
194
|
};
|
|
195
195
|
}
|
|
196
196
|
export {};
|