langchain 0.0.197-rc.0 → 0.0.197
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/executor.cjs +351 -1
- package/dist/agents/executor.d.ts +61 -3
- package/dist/agents/executor.js +350 -1
- package/dist/agents/toolkits/conversational_retrieval/token_buffer_memory.d.ts +1 -1
- package/dist/base_language/count_tokens.cjs +1 -1
- package/dist/base_language/count_tokens.d.ts +1 -1
- package/dist/base_language/count_tokens.js +1 -1
- package/dist/base_language/index.cjs +1 -1
- package/dist/base_language/index.d.ts +1 -1
- package/dist/base_language/index.js +1 -1
- package/dist/cache/base.cjs +1 -1
- package/dist/cache/base.d.ts +1 -1
- package/dist/cache/base.js +1 -1
- package/dist/cache/index.cjs +1 -1
- package/dist/cache/index.d.ts +1 -1
- package/dist/cache/index.js +1 -1
- package/dist/callbacks/base.cjs +1 -1
- package/dist/callbacks/base.d.ts +1 -1
- package/dist/callbacks/base.js +1 -1
- package/dist/callbacks/handlers/console.cjs +1 -1
- package/dist/callbacks/handlers/console.d.ts +1 -1
- package/dist/callbacks/handlers/console.js +1 -1
- package/dist/callbacks/handlers/initialize.cjs +1 -1
- package/dist/callbacks/handlers/initialize.d.ts +1 -1
- package/dist/callbacks/handlers/initialize.js +1 -1
- package/dist/callbacks/handlers/log_stream.cjs +1 -1
- package/dist/callbacks/handlers/log_stream.d.ts +1 -1
- package/dist/callbacks/handlers/log_stream.js +1 -1
- package/dist/callbacks/handlers/run_collector.cjs +1 -1
- package/dist/callbacks/handlers/run_collector.d.ts +1 -1
- package/dist/callbacks/handlers/run_collector.js +1 -1
- package/dist/callbacks/handlers/tracer.cjs +1 -1
- package/dist/callbacks/handlers/tracer.d.ts +1 -1
- package/dist/callbacks/handlers/tracer.js +1 -1
- package/dist/callbacks/handlers/tracer_langchain.cjs +1 -1
- package/dist/callbacks/handlers/tracer_langchain.d.ts +1 -1
- package/dist/callbacks/handlers/tracer_langchain.js +1 -1
- package/dist/callbacks/handlers/tracer_langchain_v1.cjs +1 -1
- package/dist/callbacks/handlers/tracer_langchain_v1.d.ts +1 -1
- package/dist/callbacks/handlers/tracer_langchain_v1.js +1 -1
- package/dist/callbacks/manager.cjs +1 -1
- package/dist/callbacks/manager.d.ts +1 -1
- package/dist/callbacks/manager.js +1 -1
- package/dist/callbacks/promises.cjs +1 -1
- package/dist/callbacks/promises.d.ts +1 -1
- package/dist/callbacks/promises.js +1 -1
- package/dist/chains/base.cjs +16 -0
- package/dist/chains/base.d.ts +2 -0
- package/dist/chains/base.js +16 -0
- package/dist/chains/openai_functions/structured_output.cjs +1 -1
- package/dist/chains/openai_functions/structured_output.d.ts +1 -1
- package/dist/chains/openai_functions/structured_output.js +1 -1
- package/dist/chat_models/anthropic.cjs +351 -15
- package/dist/chat_models/anthropic.d.ts +157 -1
- package/dist/chat_models/anthropic.js +348 -1
- package/dist/chat_models/base.cjs +1 -1
- package/dist/chat_models/base.d.ts +1 -1
- package/dist/chat_models/base.js +1 -1
- package/dist/chat_models/cloudflare_workersai.cjs +5 -0
- package/dist/chat_models/cloudflare_workersai.d.ts +3 -0
- package/dist/chat_models/cloudflare_workersai.js +5 -0
- package/dist/chat_models/fireworks.d.ts +1 -1
- package/dist/chat_models/minimax.d.ts +1 -1
- package/dist/document.cjs +1 -1
- package/dist/document.d.ts +1 -1
- package/dist/document.js +1 -1
- package/dist/document_loaders/web/azure_blob_storage_file.d.ts +1 -1
- package/dist/document_loaders/web/s3.d.ts +1 -1
- package/dist/embeddings/base.cjs +1 -1
- package/dist/embeddings/base.d.ts +1 -1
- package/dist/embeddings/base.js +1 -1
- package/dist/embeddings/cache_backed.cjs +1 -1
- package/dist/embeddings/cache_backed.js +1 -1
- package/dist/experimental/openai_files/index.d.ts +1 -1
- package/dist/experimental/plan_and_execute/prompt.d.ts +1 -1
- package/dist/llms/base.cjs +1 -1
- package/dist/llms/base.d.ts +1 -1
- package/dist/llms/base.js +1 -1
- package/dist/llms/fireworks.d.ts +1 -1
- package/dist/load/index.cjs +4 -2
- package/dist/load/index.d.ts +2 -2
- package/dist/load/index.js +4 -2
- package/dist/load/serializable.cjs +1 -1
- package/dist/load/serializable.d.ts +1 -1
- package/dist/load/serializable.js +1 -1
- package/dist/memory/base.cjs +2 -2
- package/dist/memory/base.d.ts +2 -2
- package/dist/memory/base.js +2 -2
- package/dist/output_parsers/list.cjs +1 -1
- package/dist/output_parsers/list.d.ts +1 -1
- package/dist/output_parsers/list.js +1 -1
- package/dist/output_parsers/openai_functions.cjs +1 -1
- package/dist/output_parsers/openai_functions.d.ts +1 -1
- package/dist/output_parsers/openai_functions.js +1 -1
- package/dist/output_parsers/structured.d.ts +1 -1
- package/dist/prompts/base.cjs +3 -3
- package/dist/prompts/base.d.ts +3 -3
- package/dist/prompts/base.js +3 -3
- package/dist/prompts/chat.cjs +2 -2
- package/dist/prompts/chat.d.ts +2 -2
- package/dist/prompts/chat.js +2 -2
- package/dist/prompts/few_shot.cjs +1 -1
- package/dist/prompts/few_shot.d.ts +1 -1
- package/dist/prompts/few_shot.js +1 -1
- package/dist/prompts/index.cjs +1 -1
- package/dist/prompts/index.d.ts +1 -1
- package/dist/prompts/index.js +1 -1
- package/dist/prompts/pipeline.cjs +1 -1
- package/dist/prompts/pipeline.d.ts +1 -1
- package/dist/prompts/pipeline.js +1 -1
- package/dist/prompts/prompt.cjs +1 -1
- package/dist/prompts/prompt.d.ts +1 -1
- package/dist/prompts/prompt.js +1 -1
- package/dist/prompts/selectors/LengthBasedExampleSelector.cjs +1 -1
- package/dist/prompts/selectors/LengthBasedExampleSelector.d.ts +1 -1
- package/dist/prompts/selectors/LengthBasedExampleSelector.js +1 -1
- package/dist/prompts/selectors/SemanticSimilarityExampleSelector.cjs +1 -1
- package/dist/prompts/selectors/SemanticSimilarityExampleSelector.d.ts +1 -1
- package/dist/prompts/selectors/SemanticSimilarityExampleSelector.js +1 -1
- package/dist/prompts/selectors/conditional.cjs +1 -1
- package/dist/prompts/selectors/conditional.d.ts +1 -1
- package/dist/prompts/selectors/conditional.js +1 -1
- package/dist/prompts/serde.d.ts +1 -1
- package/dist/prompts/template.cjs +1 -1
- package/dist/prompts/template.d.ts +1 -1
- package/dist/prompts/template.js +1 -1
- package/dist/runnables/index.cjs +1 -1
- package/dist/runnables/index.d.ts +1 -1
- package/dist/runnables/index.js +1 -1
- package/dist/schema/document.cjs +1 -1
- package/dist/schema/document.d.ts +1 -1
- package/dist/schema/document.js +1 -1
- package/dist/schema/index.cjs +7 -7
- package/dist/schema/index.d.ts +10 -10
- package/dist/schema/index.js +7 -7
- package/dist/schema/output_parser.cjs +1 -1
- package/dist/schema/output_parser.d.ts +1 -1
- package/dist/schema/output_parser.js +1 -1
- package/dist/schema/retriever.cjs +1 -1
- package/dist/schema/retriever.d.ts +1 -1
- package/dist/schema/retriever.js +1 -1
- package/dist/schema/runnable/base.cjs +1 -1
- package/dist/schema/runnable/base.d.ts +1 -1
- package/dist/schema/runnable/base.js +1 -1
- package/dist/schema/runnable/branch.cjs +1 -1
- package/dist/schema/runnable/branch.d.ts +1 -1
- package/dist/schema/runnable/branch.js +1 -1
- package/dist/schema/runnable/config.d.ts +1 -1
- package/dist/schema/runnable/index.cjs +1 -1
- package/dist/schema/runnable/index.d.ts +1 -1
- package/dist/schema/runnable/index.js +1 -1
- package/dist/schema/runnable/passthrough.cjs +1 -1
- package/dist/schema/runnable/passthrough.d.ts +1 -1
- package/dist/schema/runnable/passthrough.js +1 -1
- package/dist/schema/runnable/router.cjs +1 -1
- package/dist/schema/runnable/router.d.ts +1 -1
- package/dist/schema/runnable/router.js +1 -1
- package/dist/schema/storage.cjs +1 -1
- package/dist/schema/storage.d.ts +1 -1
- package/dist/schema/storage.js +1 -1
- package/dist/tools/base.cjs +4 -108
- package/dist/tools/base.d.ts +1 -72
- package/dist/tools/base.js +1 -105
- package/dist/tools/bingserpapi.d.ts +1 -1
- package/dist/tools/searchapi.d.ts +1 -1
- package/dist/tools/serpapi.d.ts +1 -1
- package/dist/tools/serper.d.ts +1 -1
- package/dist/util/async_caller.cjs +1 -1
- package/dist/util/async_caller.d.ts +1 -1
- package/dist/util/async_caller.js +1 -1
- package/dist/util/env.cjs +9 -70
- package/dist/util/env.d.ts +1 -21
- package/dist/util/env.js +1 -62
- package/package.json +3 -5
package/dist/tools/base.cjs
CHANGED
|
@@ -1,111 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Tool = exports.StructuredTool = exports.ToolInputParsingException = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* Custom error class used to handle exceptions related to tool input parsing.
|
|
9
|
-
* It extends the built-in `Error` class and adds an optional `output`
|
|
10
|
-
* property that can hold the output that caused the exception.
|
|
11
|
-
*/
|
|
12
|
-
class ToolInputParsingException extends Error {
|
|
13
|
-
constructor(message, output) {
|
|
14
|
-
super(message);
|
|
15
|
-
Object.defineProperty(this, "output", {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
configurable: true,
|
|
18
|
-
writable: true,
|
|
19
|
-
value: void 0
|
|
20
|
-
});
|
|
21
|
-
this.output = output;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.ToolInputParsingException = ToolInputParsingException;
|
|
25
|
-
/**
|
|
26
|
-
* Base class for Tools that accept input of any shape defined by a Zod schema.
|
|
27
|
-
*/
|
|
28
|
-
class StructuredTool extends index_js_1.BaseLangChain {
|
|
29
|
-
get lc_namespace() {
|
|
30
|
-
return ["langchain", "tools"];
|
|
31
|
-
}
|
|
32
|
-
constructor(fields) {
|
|
33
|
-
super(fields ?? {});
|
|
34
|
-
Object.defineProperty(this, "returnDirect", {
|
|
35
|
-
enumerable: true,
|
|
36
|
-
configurable: true,
|
|
37
|
-
writable: true,
|
|
38
|
-
value: false
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Invokes the tool with the provided input and configuration.
|
|
43
|
-
* @param input The input for the tool.
|
|
44
|
-
* @param config Optional configuration for the tool.
|
|
45
|
-
* @returns A Promise that resolves with a string.
|
|
46
|
-
*/
|
|
47
|
-
async invoke(input, config) {
|
|
48
|
-
return this.call(input, config);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Calls the tool with the provided argument, configuration, and tags. It
|
|
52
|
-
* parses the input according to the schema, handles any errors, and
|
|
53
|
-
* manages callbacks.
|
|
54
|
-
* @param arg The input argument for the tool.
|
|
55
|
-
* @param configArg Optional configuration or callbacks for the tool.
|
|
56
|
-
* @param tags Optional tags for the tool.
|
|
57
|
-
* @returns A Promise that resolves with a string.
|
|
58
|
-
*/
|
|
59
|
-
async call(arg, configArg,
|
|
60
|
-
/** @deprecated */
|
|
61
|
-
tags) {
|
|
62
|
-
let parsed;
|
|
63
|
-
try {
|
|
64
|
-
parsed = await this.schema.parseAsync(arg);
|
|
65
|
-
}
|
|
66
|
-
catch (e) {
|
|
67
|
-
throw new ToolInputParsingException(`Received tool input did not match expected schema`, JSON.stringify(arg));
|
|
68
|
-
}
|
|
69
|
-
const config = (0, manager_js_1.parseCallbackConfigArg)(configArg);
|
|
70
|
-
const callbackManager_ = await manager_js_1.CallbackManager.configure(config.callbacks, this.callbacks, config.tags || tags, this.tags, config.metadata, this.metadata, { verbose: this.verbose });
|
|
71
|
-
const runManager = await callbackManager_?.handleToolStart(this.toJSON(), typeof parsed === "string" ? parsed : JSON.stringify(parsed), undefined, undefined, undefined, undefined, config.runName);
|
|
72
|
-
let result;
|
|
73
|
-
try {
|
|
74
|
-
result = await this._call(parsed, runManager);
|
|
75
|
-
}
|
|
76
|
-
catch (e) {
|
|
77
|
-
await runManager?.handleToolError(e);
|
|
78
|
-
throw e;
|
|
79
|
-
}
|
|
80
|
-
await runManager?.handleToolEnd(result);
|
|
81
|
-
return result;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
exports.StructuredTool = StructuredTool;
|
|
85
|
-
/**
|
|
86
|
-
* Base class for Tools that accept input as a string.
|
|
87
|
-
*/
|
|
88
|
-
class Tool extends StructuredTool {
|
|
89
|
-
constructor(fields) {
|
|
90
|
-
super(fields);
|
|
91
|
-
Object.defineProperty(this, "schema", {
|
|
92
|
-
enumerable: true,
|
|
93
|
-
configurable: true,
|
|
94
|
-
writable: true,
|
|
95
|
-
value: zod_1.z
|
|
96
|
-
.object({ input: zod_1.z.string().optional() })
|
|
97
|
-
.transform((obj) => obj.input)
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Calls the tool with the provided argument and callbacks. It handles
|
|
102
|
-
* string inputs specifically.
|
|
103
|
-
* @param arg The input argument for the tool, which can be a string, undefined, or an input of the tool's schema.
|
|
104
|
-
* @param callbacks Optional callbacks for the tool.
|
|
105
|
-
* @returns A Promise that resolves with a string.
|
|
106
|
-
*/
|
|
107
|
-
call(arg, callbacks) {
|
|
108
|
-
return super.call(typeof arg === "string" || !arg ? { input: arg } : arg, callbacks);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
exports.Tool = Tool;
|
|
4
|
+
var tools_1 = require("@langchain/core/tools");
|
|
5
|
+
Object.defineProperty(exports, "ToolInputParsingException", { enumerable: true, get: function () { return tools_1.ToolInputParsingException; } });
|
|
6
|
+
Object.defineProperty(exports, "StructuredTool", { enumerable: true, get: function () { return tools_1.StructuredTool; } });
|
|
7
|
+
Object.defineProperty(exports, "Tool", { enumerable: true, get: function () { return tools_1.Tool; } });
|
package/dist/tools/base.d.ts
CHANGED
|
@@ -1,72 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { CallbackManagerForToolRun, Callbacks } from "../callbacks/manager.js";
|
|
3
|
-
import { BaseLangChain, BaseLangChainParams } from "../base_language/index.js";
|
|
4
|
-
import { RunnableConfig } from "../schema/runnable/config.js";
|
|
5
|
-
/**
|
|
6
|
-
* Parameters for the Tool classes.
|
|
7
|
-
*/
|
|
8
|
-
export interface ToolParams extends BaseLangChainParams {
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Custom error class used to handle exceptions related to tool input parsing.
|
|
12
|
-
* It extends the built-in `Error` class and adds an optional `output`
|
|
13
|
-
* property that can hold the output that caused the exception.
|
|
14
|
-
*/
|
|
15
|
-
export declare class ToolInputParsingException extends Error {
|
|
16
|
-
output?: string;
|
|
17
|
-
constructor(message: string, output?: string);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Base class for Tools that accept input of any shape defined by a Zod schema.
|
|
21
|
-
*/
|
|
22
|
-
export declare abstract class StructuredTool<T extends z.ZodObject<any, any, any, any> = z.ZodObject<any, any, any, any>> extends BaseLangChain<(z.output<T> extends string ? string : never) | z.input<T>, string> {
|
|
23
|
-
abstract schema: T | z.ZodEffects<T>;
|
|
24
|
-
get lc_namespace(): string[];
|
|
25
|
-
constructor(fields?: ToolParams);
|
|
26
|
-
protected abstract _call(arg: z.output<T>, runManager?: CallbackManagerForToolRun): Promise<string>;
|
|
27
|
-
/**
|
|
28
|
-
* Invokes the tool with the provided input and configuration.
|
|
29
|
-
* @param input The input for the tool.
|
|
30
|
-
* @param config Optional configuration for the tool.
|
|
31
|
-
* @returns A Promise that resolves with a string.
|
|
32
|
-
*/
|
|
33
|
-
invoke(input: (z.output<T> extends string ? string : never) | z.input<T>, config?: RunnableConfig): Promise<string>;
|
|
34
|
-
/**
|
|
35
|
-
* Calls the tool with the provided argument, configuration, and tags. It
|
|
36
|
-
* parses the input according to the schema, handles any errors, and
|
|
37
|
-
* manages callbacks.
|
|
38
|
-
* @param arg The input argument for the tool.
|
|
39
|
-
* @param configArg Optional configuration or callbacks for the tool.
|
|
40
|
-
* @param tags Optional tags for the tool.
|
|
41
|
-
* @returns A Promise that resolves with a string.
|
|
42
|
-
*/
|
|
43
|
-
call(arg: (z.output<T> extends string ? string : never) | z.input<T>, configArg?: Callbacks | RunnableConfig,
|
|
44
|
-
/** @deprecated */
|
|
45
|
-
tags?: string[]): Promise<string>;
|
|
46
|
-
abstract name: string;
|
|
47
|
-
abstract description: string;
|
|
48
|
-
returnDirect: boolean;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Base class for Tools that accept input as a string.
|
|
52
|
-
*/
|
|
53
|
-
export declare abstract class Tool extends StructuredTool {
|
|
54
|
-
schema: z.ZodEffects<z.ZodObject<{
|
|
55
|
-
input: z.ZodOptional<z.ZodString>;
|
|
56
|
-
}, "strip", z.ZodTypeAny, {
|
|
57
|
-
input?: string | undefined;
|
|
58
|
-
}, {
|
|
59
|
-
input?: string | undefined;
|
|
60
|
-
}>, string | undefined, {
|
|
61
|
-
input?: string | undefined;
|
|
62
|
-
}>;
|
|
63
|
-
constructor(fields?: ToolParams);
|
|
64
|
-
/**
|
|
65
|
-
* Calls the tool with the provided argument and callbacks. It handles
|
|
66
|
-
* string inputs specifically.
|
|
67
|
-
* @param arg The input argument for the tool, which can be a string, undefined, or an input of the tool's schema.
|
|
68
|
-
* @param callbacks Optional callbacks for the tool.
|
|
69
|
-
* @returns A Promise that resolves with a string.
|
|
70
|
-
*/
|
|
71
|
-
call(arg: string | undefined | z.input<this["schema"]>, callbacks?: Callbacks): Promise<string>;
|
|
72
|
-
}
|
|
1
|
+
export { type ToolParams, ToolInputParsingException, StructuredTool, Tool, } from "@langchain/core/tools";
|
package/dist/tools/base.js
CHANGED
|
@@ -1,105 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { CallbackManager, parseCallbackConfigArg, } from "../callbacks/manager.js";
|
|
3
|
-
import { BaseLangChain } from "../base_language/index.js";
|
|
4
|
-
/**
|
|
5
|
-
* Custom error class used to handle exceptions related to tool input parsing.
|
|
6
|
-
* It extends the built-in `Error` class and adds an optional `output`
|
|
7
|
-
* property that can hold the output that caused the exception.
|
|
8
|
-
*/
|
|
9
|
-
export class ToolInputParsingException extends Error {
|
|
10
|
-
constructor(message, output) {
|
|
11
|
-
super(message);
|
|
12
|
-
Object.defineProperty(this, "output", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
configurable: true,
|
|
15
|
-
writable: true,
|
|
16
|
-
value: void 0
|
|
17
|
-
});
|
|
18
|
-
this.output = output;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Base class for Tools that accept input of any shape defined by a Zod schema.
|
|
23
|
-
*/
|
|
24
|
-
export class StructuredTool extends BaseLangChain {
|
|
25
|
-
get lc_namespace() {
|
|
26
|
-
return ["langchain", "tools"];
|
|
27
|
-
}
|
|
28
|
-
constructor(fields) {
|
|
29
|
-
super(fields ?? {});
|
|
30
|
-
Object.defineProperty(this, "returnDirect", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
configurable: true,
|
|
33
|
-
writable: true,
|
|
34
|
-
value: false
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Invokes the tool with the provided input and configuration.
|
|
39
|
-
* @param input The input for the tool.
|
|
40
|
-
* @param config Optional configuration for the tool.
|
|
41
|
-
* @returns A Promise that resolves with a string.
|
|
42
|
-
*/
|
|
43
|
-
async invoke(input, config) {
|
|
44
|
-
return this.call(input, config);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Calls the tool with the provided argument, configuration, and tags. It
|
|
48
|
-
* parses the input according to the schema, handles any errors, and
|
|
49
|
-
* manages callbacks.
|
|
50
|
-
* @param arg The input argument for the tool.
|
|
51
|
-
* @param configArg Optional configuration or callbacks for the tool.
|
|
52
|
-
* @param tags Optional tags for the tool.
|
|
53
|
-
* @returns A Promise that resolves with a string.
|
|
54
|
-
*/
|
|
55
|
-
async call(arg, configArg,
|
|
56
|
-
/** @deprecated */
|
|
57
|
-
tags) {
|
|
58
|
-
let parsed;
|
|
59
|
-
try {
|
|
60
|
-
parsed = await this.schema.parseAsync(arg);
|
|
61
|
-
}
|
|
62
|
-
catch (e) {
|
|
63
|
-
throw new ToolInputParsingException(`Received tool input did not match expected schema`, JSON.stringify(arg));
|
|
64
|
-
}
|
|
65
|
-
const config = parseCallbackConfigArg(configArg);
|
|
66
|
-
const callbackManager_ = await CallbackManager.configure(config.callbacks, this.callbacks, config.tags || tags, this.tags, config.metadata, this.metadata, { verbose: this.verbose });
|
|
67
|
-
const runManager = await callbackManager_?.handleToolStart(this.toJSON(), typeof parsed === "string" ? parsed : JSON.stringify(parsed), undefined, undefined, undefined, undefined, config.runName);
|
|
68
|
-
let result;
|
|
69
|
-
try {
|
|
70
|
-
result = await this._call(parsed, runManager);
|
|
71
|
-
}
|
|
72
|
-
catch (e) {
|
|
73
|
-
await runManager?.handleToolError(e);
|
|
74
|
-
throw e;
|
|
75
|
-
}
|
|
76
|
-
await runManager?.handleToolEnd(result);
|
|
77
|
-
return result;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Base class for Tools that accept input as a string.
|
|
82
|
-
*/
|
|
83
|
-
export class Tool extends StructuredTool {
|
|
84
|
-
constructor(fields) {
|
|
85
|
-
super(fields);
|
|
86
|
-
Object.defineProperty(this, "schema", {
|
|
87
|
-
enumerable: true,
|
|
88
|
-
configurable: true,
|
|
89
|
-
writable: true,
|
|
90
|
-
value: z
|
|
91
|
-
.object({ input: z.string().optional() })
|
|
92
|
-
.transform((obj) => obj.input)
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Calls the tool with the provided argument and callbacks. It handles
|
|
97
|
-
* string inputs specifically.
|
|
98
|
-
* @param arg The input argument for the tool, which can be a string, undefined, or an input of the tool's schema.
|
|
99
|
-
* @param callbacks Optional callbacks for the tool.
|
|
100
|
-
* @returns A Promise that resolves with a string.
|
|
101
|
-
*/
|
|
102
|
-
call(arg, callbacks) {
|
|
103
|
-
return super.call(typeof arg === "string" || !arg ? { input: arg } : arg, callbacks);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
1
|
+
export { ToolInputParsingException, StructuredTool, Tool, } from "@langchain/core/tools";
|
|
@@ -11,7 +11,7 @@ declare class BingSerpAPI extends Tool {
|
|
|
11
11
|
/**
|
|
12
12
|
* Not implemented. Will throw an error if called.
|
|
13
13
|
*/
|
|
14
|
-
toJSON(): import("langchain
|
|
14
|
+
toJSON(): import("@langchain/core/load/serializable").SerializedNotImplemented;
|
|
15
15
|
name: string;
|
|
16
16
|
description: string;
|
|
17
17
|
key: string;
|
|
@@ -62,7 +62,7 @@ export declare class SearchApi extends Tool {
|
|
|
62
62
|
* and will throw an error if called.
|
|
63
63
|
* @returns Throws an error.
|
|
64
64
|
*/
|
|
65
|
-
toJSON(): import("langchain
|
|
65
|
+
toJSON(): import("@langchain/core/load/serializable").SerializedNotImplemented;
|
|
66
66
|
protected apiKey: string;
|
|
67
67
|
protected params: Partial<SearchApiParameters>;
|
|
68
68
|
constructor(apiKey?: string | undefined, params?: Partial<SearchApiParameters>);
|
package/dist/tools/serpapi.d.ts
CHANGED
|
@@ -281,7 +281,7 @@ type UrlParameters = Record<string, string | number | boolean | undefined | null
|
|
|
281
281
|
*/
|
|
282
282
|
export declare class SerpAPI extends Tool {
|
|
283
283
|
static lc_name(): string;
|
|
284
|
-
toJSON(): import("langchain
|
|
284
|
+
toJSON(): import("@langchain/core/load/serializable").SerializedNotImplemented;
|
|
285
285
|
protected key: string;
|
|
286
286
|
protected params: Partial<SerpAPIParameters>;
|
|
287
287
|
protected baseUrl: string;
|
package/dist/tools/serper.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export declare class Serper extends Tool {
|
|
|
21
21
|
* and will throw an error if called.
|
|
22
22
|
* @returns Throws an error.
|
|
23
23
|
*/
|
|
24
|
-
toJSON(): import("langchain
|
|
24
|
+
toJSON(): import("@langchain/core/load/serializable").SerializedNotImplemented;
|
|
25
25
|
protected key: string;
|
|
26
26
|
protected params: Partial<SerperParameters>;
|
|
27
27
|
constructor(apiKey?: string | undefined, params?: Partial<SerperParameters>);
|
|
@@ -14,4 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("langchain
|
|
17
|
+
__exportStar(require("@langchain/core/utils/async_caller"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "langchain
|
|
1
|
+
export * from "@langchain/core/utils/async_caller";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "langchain
|
|
1
|
+
export * from "@langchain/core/utils/async_caller";
|
package/dist/util/env.cjs
CHANGED
|
@@ -1,73 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getEnvironmentVariable = exports.getRuntimeEnvironment = exports.getEnv = exports.isNode = exports.isDeno = exports.isJsDom = exports.isWebWorker = exports.isBrowser = void 0;
|
|
4
|
-
|
|
5
|
-
exports
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
navigator.userAgent.includes("jsdom")));
|
|
14
|
-
exports.isJsDom = isJsDom;
|
|
15
|
-
// Supabase Edge Function provides a `Deno` global object
|
|
16
|
-
// without `version` property
|
|
17
|
-
const isDeno = () => typeof Deno !== "undefined";
|
|
18
|
-
exports.isDeno = isDeno;
|
|
19
|
-
// Mark not-as-node if in Supabase Edge Function
|
|
20
|
-
const isNode = () => typeof process !== "undefined" &&
|
|
21
|
-
typeof process.versions !== "undefined" &&
|
|
22
|
-
typeof process.versions.node !== "undefined" &&
|
|
23
|
-
!(0, exports.isDeno)();
|
|
24
|
-
exports.isNode = isNode;
|
|
25
|
-
const getEnv = () => {
|
|
26
|
-
let env;
|
|
27
|
-
if ((0, exports.isBrowser)()) {
|
|
28
|
-
env = "browser";
|
|
29
|
-
}
|
|
30
|
-
else if ((0, exports.isNode)()) {
|
|
31
|
-
env = "node";
|
|
32
|
-
}
|
|
33
|
-
else if ((0, exports.isWebWorker)()) {
|
|
34
|
-
env = "webworker";
|
|
35
|
-
}
|
|
36
|
-
else if ((0, exports.isJsDom)()) {
|
|
37
|
-
env = "jsdom";
|
|
38
|
-
}
|
|
39
|
-
else if ((0, exports.isDeno)()) {
|
|
40
|
-
env = "deno";
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
env = "other";
|
|
44
|
-
}
|
|
45
|
-
return env;
|
|
46
|
-
};
|
|
47
|
-
exports.getEnv = getEnv;
|
|
48
|
-
let runtimeEnvironment;
|
|
49
|
-
async function getRuntimeEnvironment() {
|
|
50
|
-
if (runtimeEnvironment === undefined) {
|
|
51
|
-
const env = (0, exports.getEnv)();
|
|
52
|
-
runtimeEnvironment = {
|
|
53
|
-
library: "langchain-js",
|
|
54
|
-
runtime: env,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
return runtimeEnvironment;
|
|
58
|
-
}
|
|
59
|
-
exports.getRuntimeEnvironment = getRuntimeEnvironment;
|
|
60
|
-
function getEnvironmentVariable(name) {
|
|
61
|
-
// Certain Deno setups will throw an error if you try to access environment variables
|
|
62
|
-
// https://github.com/langchain-ai/langchainjs/issues/1412
|
|
63
|
-
try {
|
|
64
|
-
return typeof process !== "undefined"
|
|
65
|
-
? // eslint-disable-next-line no-process-env
|
|
66
|
-
process.env?.[name]
|
|
67
|
-
: undefined;
|
|
68
|
-
}
|
|
69
|
-
catch (e) {
|
|
70
|
-
return undefined;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
exports.getEnvironmentVariable = getEnvironmentVariable;
|
|
4
|
+
var env_1 = require("@langchain/core/utils/env");
|
|
5
|
+
Object.defineProperty(exports, "isBrowser", { enumerable: true, get: function () { return env_1.isBrowser; } });
|
|
6
|
+
Object.defineProperty(exports, "isWebWorker", { enumerable: true, get: function () { return env_1.isWebWorker; } });
|
|
7
|
+
Object.defineProperty(exports, "isJsDom", { enumerable: true, get: function () { return env_1.isJsDom; } });
|
|
8
|
+
Object.defineProperty(exports, "isDeno", { enumerable: true, get: function () { return env_1.isDeno; } });
|
|
9
|
+
Object.defineProperty(exports, "isNode", { enumerable: true, get: function () { return env_1.isNode; } });
|
|
10
|
+
Object.defineProperty(exports, "getEnv", { enumerable: true, get: function () { return env_1.getEnv; } });
|
|
11
|
+
Object.defineProperty(exports, "getRuntimeEnvironment", { enumerable: true, get: function () { return env_1.getRuntimeEnvironment; } });
|
|
12
|
+
Object.defineProperty(exports, "getEnvironmentVariable", { enumerable: true, get: function () { return env_1.getEnvironmentVariable; } });
|
package/dist/util/env.d.ts
CHANGED
|
@@ -1,21 +1 @@
|
|
|
1
|
-
|
|
2
|
-
const Deno: {
|
|
3
|
-
version: {
|
|
4
|
-
deno: string;
|
|
5
|
-
};
|
|
6
|
-
} | undefined;
|
|
7
|
-
}
|
|
8
|
-
export declare const isBrowser: () => boolean;
|
|
9
|
-
export declare const isWebWorker: () => boolean;
|
|
10
|
-
export declare const isJsDom: () => boolean;
|
|
11
|
-
export declare const isDeno: () => boolean;
|
|
12
|
-
export declare const isNode: () => boolean;
|
|
13
|
-
export declare const getEnv: () => string;
|
|
14
|
-
export type RuntimeEnvironment = {
|
|
15
|
-
library: string;
|
|
16
|
-
libraryVersion?: string;
|
|
17
|
-
runtime: string;
|
|
18
|
-
runtimeVersion?: string;
|
|
19
|
-
};
|
|
20
|
-
export declare function getRuntimeEnvironment(): Promise<RuntimeEnvironment>;
|
|
21
|
-
export declare function getEnvironmentVariable(name: string): string | undefined;
|
|
1
|
+
export { isBrowser, isWebWorker, isJsDom, isDeno, isNode, getEnv, type RuntimeEnvironment, getRuntimeEnvironment, getEnvironmentVariable, } from "@langchain/core/utils/env";
|
package/dist/util/env.js
CHANGED
|
@@ -1,62 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export const isWebWorker = () => typeof globalThis === "object" &&
|
|
3
|
-
globalThis.constructor &&
|
|
4
|
-
globalThis.constructor.name === "DedicatedWorkerGlobalScope";
|
|
5
|
-
export const isJsDom = () => (typeof window !== "undefined" && window.name === "nodejs") ||
|
|
6
|
-
(typeof navigator !== "undefined" &&
|
|
7
|
-
(navigator.userAgent.includes("Node.js") ||
|
|
8
|
-
navigator.userAgent.includes("jsdom")));
|
|
9
|
-
// Supabase Edge Function provides a `Deno` global object
|
|
10
|
-
// without `version` property
|
|
11
|
-
export const isDeno = () => typeof Deno !== "undefined";
|
|
12
|
-
// Mark not-as-node if in Supabase Edge Function
|
|
13
|
-
export const isNode = () => typeof process !== "undefined" &&
|
|
14
|
-
typeof process.versions !== "undefined" &&
|
|
15
|
-
typeof process.versions.node !== "undefined" &&
|
|
16
|
-
!isDeno();
|
|
17
|
-
export const getEnv = () => {
|
|
18
|
-
let env;
|
|
19
|
-
if (isBrowser()) {
|
|
20
|
-
env = "browser";
|
|
21
|
-
}
|
|
22
|
-
else if (isNode()) {
|
|
23
|
-
env = "node";
|
|
24
|
-
}
|
|
25
|
-
else if (isWebWorker()) {
|
|
26
|
-
env = "webworker";
|
|
27
|
-
}
|
|
28
|
-
else if (isJsDom()) {
|
|
29
|
-
env = "jsdom";
|
|
30
|
-
}
|
|
31
|
-
else if (isDeno()) {
|
|
32
|
-
env = "deno";
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
env = "other";
|
|
36
|
-
}
|
|
37
|
-
return env;
|
|
38
|
-
};
|
|
39
|
-
let runtimeEnvironment;
|
|
40
|
-
export async function getRuntimeEnvironment() {
|
|
41
|
-
if (runtimeEnvironment === undefined) {
|
|
42
|
-
const env = getEnv();
|
|
43
|
-
runtimeEnvironment = {
|
|
44
|
-
library: "langchain-js",
|
|
45
|
-
runtime: env,
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
return runtimeEnvironment;
|
|
49
|
-
}
|
|
50
|
-
export function getEnvironmentVariable(name) {
|
|
51
|
-
// Certain Deno setups will throw an error if you try to access environment variables
|
|
52
|
-
// https://github.com/langchain-ai/langchainjs/issues/1412
|
|
53
|
-
try {
|
|
54
|
-
return typeof process !== "undefined"
|
|
55
|
-
? // eslint-disable-next-line no-process-env
|
|
56
|
-
process.env?.[name]
|
|
57
|
-
: undefined;
|
|
58
|
-
}
|
|
59
|
-
catch (e) {
|
|
60
|
-
return undefined;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
1
|
+
export { isBrowser, isWebWorker, isJsDom, isDeno, isNode, getEnv, getRuntimeEnvironment, getEnvironmentVariable, } from "@langchain/core/utils/env";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "langchain",
|
|
3
|
-
"version": "0.0.197
|
|
3
|
+
"version": "0.0.197",
|
|
4
4
|
"description": "Typescript bindings for langchain",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -865,7 +865,6 @@
|
|
|
865
865
|
"@google-cloud/storage": "^6.10.1",
|
|
866
866
|
"@huggingface/inference": "^2.6.4",
|
|
867
867
|
"@jest/globals": "^29.5.0",
|
|
868
|
-
"@langchain/anthropic": "workspace:*",
|
|
869
868
|
"@mozilla/readability": "^0.4.4",
|
|
870
869
|
"@notionhq/client": "^2.2.10",
|
|
871
870
|
"@opensearch-project/opensearch": "^2.2.0",
|
|
@@ -943,7 +942,6 @@
|
|
|
943
942
|
"jest": "^29.5.0",
|
|
944
943
|
"jest-environment-node": "^29.6.4",
|
|
945
944
|
"jsdom": "^22.1.0",
|
|
946
|
-
"langchain-core": "workspace:*",
|
|
947
945
|
"llmonitor": "^0.5.9",
|
|
948
946
|
"lodash": "^4.17.21",
|
|
949
947
|
"mammoth": "^1.5.1",
|
|
@@ -1379,14 +1377,14 @@
|
|
|
1379
1377
|
}
|
|
1380
1378
|
},
|
|
1381
1379
|
"dependencies": {
|
|
1382
|
-
"@
|
|
1380
|
+
"@anthropic-ai/sdk": "^0.9.1",
|
|
1381
|
+
"@langchain/core": "^0.0.1",
|
|
1383
1382
|
"binary-extensions": "^2.2.0",
|
|
1384
1383
|
"expr-eval": "^2.0.2",
|
|
1385
1384
|
"flat": "^5.0.2",
|
|
1386
1385
|
"js-tiktoken": "^1.0.7",
|
|
1387
1386
|
"js-yaml": "^4.1.0",
|
|
1388
1387
|
"jsonpointer": "^5.0.1",
|
|
1389
|
-
"langchain-core": "^0.0.4",
|
|
1390
1388
|
"langchainhub": "~0.0.6",
|
|
1391
1389
|
"langsmith": "~0.0.48",
|
|
1392
1390
|
"ml-distance": "^4.0.0",
|