langchain 0.0.60 → 0.0.61
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/callbacks/base.cjs +3 -4
- package/dist/callbacks/base.d.ts +95 -3
- package/dist/callbacks/base.js +2 -2
- package/dist/callbacks/index.cjs +1 -2
- package/dist/callbacks/index.d.ts +1 -1
- package/dist/callbacks/index.js +1 -1
- package/dist/callbacks/manager.d.ts +4 -4
- package/dist/tools/index.cjs +2 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +1 -1
- package/package.json +1 -1
package/dist/callbacks/base.cjs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseCallbackHandler =
|
|
3
|
+
exports.BaseCallbackHandler = void 0;
|
|
4
4
|
const uuid_1 = require("uuid");
|
|
5
|
-
class
|
|
5
|
+
class BaseCallbackHandlerMethodsClass {
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
class BaseCallbackHandler extends BaseCallbackHandlerMethods {
|
|
7
|
+
class BaseCallbackHandler extends BaseCallbackHandlerMethodsClass {
|
|
9
8
|
constructor(input) {
|
|
10
9
|
super();
|
|
11
10
|
Object.defineProperty(this, "ignoreLLM", {
|
package/dist/callbacks/base.d.ts
CHANGED
|
@@ -5,58 +5,150 @@ export interface BaseCallbackHandlerInput {
|
|
|
5
5
|
ignoreChain?: boolean;
|
|
6
6
|
ignoreAgent?: boolean;
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
declare abstract class BaseCallbackHandlerMethodsClass {
|
|
9
|
+
/**
|
|
10
|
+
* Called at the start of an LLM or Chat Model run, with the prompt(s)
|
|
11
|
+
* and the run ID.
|
|
12
|
+
*/
|
|
9
13
|
handleLLMStart?(llm: {
|
|
10
14
|
name: string;
|
|
11
15
|
}, prompts: string[], runId: string, parentRunId?: string): Promise<void> | void;
|
|
16
|
+
/**
|
|
17
|
+
* Called when an LLM/ChatModel in `streaming` mode produces a new token
|
|
18
|
+
*/
|
|
12
19
|
handleLLMNewToken?(token: string, runId: string, parentRunId?: string): Promise<void> | void;
|
|
20
|
+
/**
|
|
21
|
+
* Called if an LLM/ChatModel run encounters an error
|
|
22
|
+
*/
|
|
13
23
|
handleLLMError?(err: Error, runId: string, parentRunId?: string): Promise<void> | void;
|
|
24
|
+
/**
|
|
25
|
+
* Called at the end of an LLM/ChatModel run, with the output and the run ID.
|
|
26
|
+
*/
|
|
14
27
|
handleLLMEnd?(output: LLMResult, runId: string, parentRunId?: string): Promise<void> | void;
|
|
28
|
+
/**
|
|
29
|
+
* Called at the start of a Chain run, with the chain name and inputs
|
|
30
|
+
* and the run ID.
|
|
31
|
+
*/
|
|
15
32
|
handleChainStart?(chain: {
|
|
16
33
|
name: string;
|
|
17
34
|
}, inputs: ChainValues, runId: string, parentRunId?: string): Promise<void> | void;
|
|
35
|
+
/**
|
|
36
|
+
* Called if a Chain run encounters an error
|
|
37
|
+
*/
|
|
18
38
|
handleChainError?(err: Error, runId: string, parentRunId?: string): Promise<void> | void;
|
|
39
|
+
/**
|
|
40
|
+
* Called at the end of a Chain run, with the outputs and the run ID.
|
|
41
|
+
*/
|
|
19
42
|
handleChainEnd?(outputs: ChainValues, runId: string, parentRunId?: string): Promise<void> | void;
|
|
43
|
+
/**
|
|
44
|
+
* Called at the start of a Tool run, with the tool name and input
|
|
45
|
+
* and the run ID.
|
|
46
|
+
*/
|
|
20
47
|
handleToolStart?(tool: {
|
|
21
48
|
name: string;
|
|
22
49
|
}, input: string, runId: string, parentRunId?: string): Promise<void> | void;
|
|
50
|
+
/**
|
|
51
|
+
* Called if a Tool run encounters an error
|
|
52
|
+
*/
|
|
23
53
|
handleToolError?(err: Error, runId: string, parentRunId?: string): Promise<void> | void;
|
|
54
|
+
/**
|
|
55
|
+
* Called at the end of a Tool run, with the tool output and the run ID.
|
|
56
|
+
*/
|
|
24
57
|
handleToolEnd?(output: string, runId: string, parentRunId?: string): Promise<void> | void;
|
|
25
58
|
handleText?(text: string, runId: string, parentRunId?: string): Promise<void> | void;
|
|
59
|
+
/**
|
|
60
|
+
* Called when an agent is about to execute an action,
|
|
61
|
+
* with the action and the run ID.
|
|
62
|
+
*/
|
|
26
63
|
handleAgentAction?(action: AgentAction, runId: string, parentRunId?: string): Promise<void> | void;
|
|
64
|
+
/**
|
|
65
|
+
* Called when an agent finishes execution, before it exits.
|
|
66
|
+
* with the final output and the run ID.
|
|
67
|
+
*/
|
|
27
68
|
handleAgentEnd?(action: AgentFinish, runId: string, parentRunId?: string): Promise<void> | void;
|
|
28
69
|
}
|
|
29
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Base interface for callbacks. All methods are optional. If a method is not
|
|
72
|
+
* implemented, it will be ignored. If a method is implemented, it will be
|
|
73
|
+
* called at the appropriate time. All methods are called with the run ID of
|
|
74
|
+
* the LLM/ChatModel/Chain that is running, which is generated by the
|
|
75
|
+
* CallbackManager.
|
|
76
|
+
*
|
|
77
|
+
* @interface
|
|
78
|
+
*/
|
|
79
|
+
export type CallbackHandlerMethods = BaseCallbackHandlerMethodsClass;
|
|
80
|
+
export declare abstract class BaseCallbackHandler extends BaseCallbackHandlerMethodsClass implements BaseCallbackHandlerInput {
|
|
30
81
|
abstract name: string;
|
|
31
82
|
ignoreLLM: boolean;
|
|
32
83
|
ignoreChain: boolean;
|
|
33
84
|
ignoreAgent: boolean;
|
|
34
85
|
constructor(input?: BaseCallbackHandlerInput);
|
|
35
86
|
copy(): BaseCallbackHandler;
|
|
36
|
-
static fromMethods(methods:
|
|
87
|
+
static fromMethods(methods: CallbackHandlerMethods): {
|
|
37
88
|
name: string;
|
|
38
89
|
ignoreLLM: boolean;
|
|
39
90
|
ignoreChain: boolean;
|
|
40
91
|
ignoreAgent: boolean;
|
|
41
92
|
copy(): BaseCallbackHandler;
|
|
93
|
+
/**
|
|
94
|
+
* Called at the start of an LLM or Chat Model run, with the prompt(s)
|
|
95
|
+
* and the run ID.
|
|
96
|
+
*/
|
|
42
97
|
handleLLMStart?(llm: {
|
|
43
98
|
name: string;
|
|
44
99
|
}, prompts: string[], runId: string, parentRunId?: string | undefined): void | Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* Called when an LLM/ChatModel in `streaming` mode produces a new token
|
|
102
|
+
*/
|
|
45
103
|
handleLLMNewToken?(token: string, runId: string, parentRunId?: string | undefined): void | Promise<void>;
|
|
104
|
+
/**
|
|
105
|
+
* Called if an LLM/ChatModel run encounters an error
|
|
106
|
+
*/
|
|
46
107
|
handleLLMError?(err: any, runId: string, parentRunId?: string | undefined): void | Promise<void>;
|
|
108
|
+
/**
|
|
109
|
+
* Called at the end of an LLM/ChatModel run, with the output and the run ID.
|
|
110
|
+
*/
|
|
47
111
|
handleLLMEnd?(output: LLMResult, runId: string, parentRunId?: string | undefined): void | Promise<void>;
|
|
112
|
+
/**
|
|
113
|
+
* Called at the start of a Chain run, with the chain name and inputs
|
|
114
|
+
* and the run ID.
|
|
115
|
+
*/
|
|
48
116
|
handleChainStart?(chain: {
|
|
49
117
|
name: string;
|
|
50
118
|
}, inputs: ChainValues, runId: string, parentRunId?: string | undefined): void | Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* Called if a Chain run encounters an error
|
|
121
|
+
*/
|
|
51
122
|
handleChainError?(err: any, runId: string, parentRunId?: string | undefined): void | Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* Called at the end of a Chain run, with the outputs and the run ID.
|
|
125
|
+
*/
|
|
52
126
|
handleChainEnd?(outputs: ChainValues, runId: string, parentRunId?: string | undefined): void | Promise<void>;
|
|
127
|
+
/**
|
|
128
|
+
* Called at the start of a Tool run, with the tool name and input
|
|
129
|
+
* and the run ID.
|
|
130
|
+
*/
|
|
53
131
|
handleToolStart?(tool: {
|
|
54
132
|
name: string;
|
|
55
133
|
}, input: string, runId: string, parentRunId?: string | undefined): void | Promise<void>;
|
|
134
|
+
/**
|
|
135
|
+
* Called if a Tool run encounters an error
|
|
136
|
+
*/
|
|
56
137
|
handleToolError?(err: any, runId: string, parentRunId?: string | undefined): void | Promise<void>;
|
|
138
|
+
/**
|
|
139
|
+
* Called at the end of a Tool run, with the tool output and the run ID.
|
|
140
|
+
*/
|
|
57
141
|
handleToolEnd?(output: string, runId: string, parentRunId?: string | undefined): void | Promise<void>;
|
|
58
142
|
handleText?(text: string, runId: string, parentRunId?: string | undefined): void | Promise<void>;
|
|
143
|
+
/**
|
|
144
|
+
* Called when an agent is about to execute an action,
|
|
145
|
+
* with the action and the run ID.
|
|
146
|
+
*/
|
|
59
147
|
handleAgentAction?(action: AgentAction, runId: string, parentRunId?: string | undefined): void | Promise<void>;
|
|
148
|
+
/**
|
|
149
|
+
* Called when an agent finishes execution, before it exits.
|
|
150
|
+
* with the final output and the run ID.
|
|
151
|
+
*/
|
|
60
152
|
handleAgentEnd?(action: AgentFinish, runId: string, parentRunId?: string | undefined): void | Promise<void>;
|
|
61
153
|
};
|
|
62
154
|
}
|
package/dist/callbacks/base.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from "uuid";
|
|
2
|
-
|
|
2
|
+
class BaseCallbackHandlerMethodsClass {
|
|
3
3
|
}
|
|
4
|
-
export class BaseCallbackHandler extends
|
|
4
|
+
export class BaseCallbackHandler extends BaseCallbackHandlerMethodsClass {
|
|
5
5
|
constructor(input) {
|
|
6
6
|
super();
|
|
7
7
|
Object.defineProperty(this, "ignoreLLM", {
|
package/dist/callbacks/index.cjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ConsoleCallbackHandler = exports.CallbackManagerForToolRun = exports.CallbackManagerForLLMRun = exports.CallbackManagerForChainRun = exports.CallbackManager = exports.getTracingCallbackHandler = exports.LangChainTracer = exports.
|
|
3
|
+
exports.ConsoleCallbackHandler = exports.CallbackManagerForToolRun = exports.CallbackManagerForLLMRun = exports.CallbackManagerForChainRun = exports.CallbackManager = exports.getTracingCallbackHandler = exports.LangChainTracer = exports.BaseCallbackHandler = void 0;
|
|
4
4
|
var base_js_1 = require("./base.cjs");
|
|
5
5
|
Object.defineProperty(exports, "BaseCallbackHandler", { enumerable: true, get: function () { return base_js_1.BaseCallbackHandler; } });
|
|
6
|
-
Object.defineProperty(exports, "BaseCallbackHandlerMethods", { enumerable: true, get: function () { return base_js_1.BaseCallbackHandlerMethods; } });
|
|
7
6
|
var tracers_js_1 = require("./handlers/tracers.cjs");
|
|
8
7
|
Object.defineProperty(exports, "LangChainTracer", { enumerable: true, get: function () { return tracers_js_1.LangChainTracer; } });
|
|
9
8
|
var initialize_js_1 = require("./handlers/initialize.cjs");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { BaseCallbackHandler,
|
|
1
|
+
export { BaseCallbackHandler, CallbackHandlerMethods, BaseCallbackHandlerInput, } from "./base.js";
|
|
2
2
|
export { LangChainTracer, BaseRun, LLMRun, ChainRun, ToolRun, } from "./handlers/tracers.js";
|
|
3
3
|
export { getTracingCallbackHandler } from "./handlers/initialize.js";
|
|
4
4
|
export { CallbackManager, CallbackManagerForChainRun, CallbackManagerForLLMRun, CallbackManagerForToolRun, CallbackManagerOptions, Callbacks, } from "./manager.js";
|
package/dist/callbacks/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { BaseCallbackHandler,
|
|
1
|
+
export { BaseCallbackHandler, } from "./base.js";
|
|
2
2
|
export { LangChainTracer, } from "./handlers/tracers.js";
|
|
3
3
|
export { getTracingCallbackHandler } from "./handlers/initialize.js";
|
|
4
4
|
export { CallbackManager, CallbackManagerForChainRun, CallbackManagerForLLMRun, CallbackManagerForToolRun, } from "./manager.js";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { AgentAction, AgentFinish, ChainValues, LLMResult } from "../schema/index.js";
|
|
2
|
-
import { BaseCallbackHandler,
|
|
2
|
+
import { BaseCallbackHandler, CallbackHandlerMethods } from "./base.js";
|
|
3
3
|
type BaseCallbackManagerMethods = {
|
|
4
|
-
[K in keyof
|
|
4
|
+
[K in keyof CallbackHandlerMethods]?: (...args: Parameters<Required<CallbackHandlerMethods>[K]>) => Promise<unknown>;
|
|
5
5
|
};
|
|
6
6
|
export interface CallbackManagerOptions {
|
|
7
7
|
verbose?: boolean;
|
|
8
8
|
tracing?: boolean;
|
|
9
9
|
}
|
|
10
|
-
export type Callbacks = CallbackManager | (BaseCallbackHandler |
|
|
10
|
+
export type Callbacks = CallbackManager | (BaseCallbackHandler | CallbackHandlerMethods)[];
|
|
11
11
|
export declare abstract class BaseCallbackManager {
|
|
12
12
|
abstract addHandler(handler: BaseCallbackHandler): void;
|
|
13
13
|
abstract removeHandler(handler: BaseCallbackHandler): void;
|
|
@@ -58,7 +58,7 @@ export declare class CallbackManager extends BaseCallbackManager implements Base
|
|
|
58
58
|
removeHandler(handler: BaseCallbackHandler): void;
|
|
59
59
|
setHandlers(handlers: BaseCallbackHandler[], inherit?: boolean): void;
|
|
60
60
|
copy(additionalHandlers?: BaseCallbackHandler[], inherit?: boolean): CallbackManager;
|
|
61
|
-
static fromHandlers(handlers:
|
|
61
|
+
static fromHandlers(handlers: CallbackHandlerMethods): CallbackManager;
|
|
62
62
|
static configure(inheritableHandlers?: Callbacks, localHandlers?: Callbacks, options?: CallbackManagerOptions): Promise<CallbackManager | undefined>;
|
|
63
63
|
}
|
|
64
64
|
export {};
|
package/dist/tools/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WriteFileTool = exports.ReadFileTool = exports.AIPluginTool = exports.Serper = exports.ZapierNLAWrapper = exports.ZapierNLARunAction = exports.VectorStoreQATool = exports.RequestsPostTool = exports.RequestsGetTool = exports.JsonGetValueTool = exports.JsonListKeysTool = exports.JsonSpec = exports.QueryCheckerTool = exports.ListTablesSqlTool = exports.InfoSqlTool = exports.QuerySqlTool = exports.ChainTool = exports.IFTTTWebhook = exports.DynamicTool = exports.Tool = exports.BingSerpAPI = exports.DadJokeAPI = exports.SerpAPI = void 0;
|
|
3
|
+
exports.WriteFileTool = exports.ReadFileTool = exports.AIPluginTool = exports.Serper = exports.ZapierNLAWrapper = exports.ZapierNLARunAction = exports.VectorStoreQATool = exports.RequestsPostTool = exports.RequestsGetTool = exports.JsonGetValueTool = exports.JsonListKeysTool = exports.JsonSpec = exports.QueryCheckerTool = exports.ListTablesSqlTool = exports.InfoSqlTool = exports.QuerySqlTool = exports.ChainTool = exports.IFTTTWebhook = exports.DynamicTool = exports.StructuredTool = exports.Tool = exports.BingSerpAPI = exports.DadJokeAPI = exports.SerpAPI = void 0;
|
|
4
4
|
var serpapi_js_1 = require("./serpapi.cjs");
|
|
5
5
|
Object.defineProperty(exports, "SerpAPI", { enumerable: true, get: function () { return serpapi_js_1.SerpAPI; } });
|
|
6
6
|
var dadjokeapi_js_1 = require("./dadjokeapi.cjs");
|
|
@@ -9,6 +9,7 @@ var bingserpapi_js_1 = require("./bingserpapi.cjs");
|
|
|
9
9
|
Object.defineProperty(exports, "BingSerpAPI", { enumerable: true, get: function () { return bingserpapi_js_1.BingSerpAPI; } });
|
|
10
10
|
var base_js_1 = require("./base.cjs");
|
|
11
11
|
Object.defineProperty(exports, "Tool", { enumerable: true, get: function () { return base_js_1.Tool; } });
|
|
12
|
+
Object.defineProperty(exports, "StructuredTool", { enumerable: true, get: function () { return base_js_1.StructuredTool; } });
|
|
12
13
|
var dynamic_js_1 = require("./dynamic.cjs");
|
|
13
14
|
Object.defineProperty(exports, "DynamicTool", { enumerable: true, get: function () { return dynamic_js_1.DynamicTool; } });
|
|
14
15
|
var IFTTTWebhook_js_1 = require("./IFTTTWebhook.cjs");
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { SerpAPI, SerpAPIParameters } from "./serpapi.js";
|
|
2
2
|
export { DadJokeAPI } from "./dadjokeapi.js";
|
|
3
3
|
export { BingSerpAPI } from "./bingserpapi.js";
|
|
4
|
-
export { Tool, ToolParams } from "./base.js";
|
|
4
|
+
export { Tool, ToolParams, StructuredTool } from "./base.js";
|
|
5
5
|
export { DynamicTool, DynamicToolInput } from "./dynamic.js";
|
|
6
6
|
export { IFTTTWebhook } from "./IFTTTWebhook.js";
|
|
7
7
|
export { ChainTool, ChainToolInput } from "./chain.js";
|
package/dist/tools/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { SerpAPI } from "./serpapi.js";
|
|
2
2
|
export { DadJokeAPI } from "./dadjokeapi.js";
|
|
3
3
|
export { BingSerpAPI } from "./bingserpapi.js";
|
|
4
|
-
export { Tool } from "./base.js";
|
|
4
|
+
export { Tool, StructuredTool } from "./base.js";
|
|
5
5
|
export { DynamicTool } from "./dynamic.js";
|
|
6
6
|
export { IFTTTWebhook } from "./IFTTTWebhook.js";
|
|
7
7
|
export { ChainTool } from "./chain.js";
|