@langchain/core 0.1.29-rc.0 → 0.1.29
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.
|
@@ -34,6 +34,8 @@ class JsonOutputParser extends transform_js_1.BaseCumulativeTransformOutputParse
|
|
|
34
34
|
}
|
|
35
35
|
return (0, json_patch_js_1.compare)(prev, next);
|
|
36
36
|
}
|
|
37
|
+
// This should actually return Partial<T>, but there's no way
|
|
38
|
+
// to specify emitted chunks as instances separate from the main output type.
|
|
37
39
|
async parsePartialResult(generations) {
|
|
38
40
|
return parseJsonMarkdown(generations[0].text);
|
|
39
41
|
}
|
|
@@ -4,13 +4,13 @@ import { ChatGeneration, Generation } from "../outputs.js";
|
|
|
4
4
|
/**
|
|
5
5
|
* Class for parsing the output of an LLM into a JSON object.
|
|
6
6
|
*/
|
|
7
|
-
export declare class JsonOutputParser extends BaseCumulativeTransformOutputParser<
|
|
7
|
+
export declare class JsonOutputParser<T extends Record<string, any> = Record<string, any>> extends BaseCumulativeTransformOutputParser<T> {
|
|
8
8
|
static lc_name(): string;
|
|
9
9
|
lc_namespace: string[];
|
|
10
10
|
lc_serializable: boolean;
|
|
11
11
|
protected _diff(prev: unknown | undefined, next: unknown): Operation[] | undefined;
|
|
12
|
-
parsePartialResult(generations: ChatGeneration[] | Generation[]): Promise<
|
|
13
|
-
parse(text: string): Promise<
|
|
12
|
+
parsePartialResult(generations: ChatGeneration[] | Generation[]): Promise<T | undefined>;
|
|
13
|
+
parse(text: string): Promise<T>;
|
|
14
14
|
getFormatInstructions(): string;
|
|
15
15
|
}
|
|
16
16
|
export declare function parseJsonMarkdown(s: string, parser?: typeof parsePartialJson): any;
|
|
@@ -31,6 +31,8 @@ export class JsonOutputParser extends BaseCumulativeTransformOutputParser {
|
|
|
31
31
|
}
|
|
32
32
|
return compare(prev, next);
|
|
33
33
|
}
|
|
34
|
+
// This should actually return Partial<T>, but there's no way
|
|
35
|
+
// to specify emitted chunks as instances separate from the main output type.
|
|
34
36
|
async parsePartialResult(generations) {
|
|
35
37
|
return parseJsonMarkdown(generations[0].text);
|
|
36
38
|
}
|
|
@@ -65,6 +65,6 @@ export declare class RunnablePassthrough<RunInput> extends Runnable<RunInput, Ru
|
|
|
65
65
|
* });
|
|
66
66
|
* ```
|
|
67
67
|
*/
|
|
68
|
-
static assign<RunInput extends Record<string, unknown>, RunOutput extends Record<string, unknown>>(mapping: RunnableMapLike<RunInput, RunOutput>): RunnableAssign<RunInput, RunInput & RunOutput>;
|
|
68
|
+
static assign<RunInput extends Record<string, unknown> = Record<string, unknown>, RunOutput extends Record<string, unknown> = Record<string, unknown>>(mapping: RunnableMapLike<RunInput, RunOutput>): RunnableAssign<RunInput, RunInput & RunOutput>;
|
|
69
69
|
}
|
|
70
70
|
export {};
|
package/dist/tools.cjs
CHANGED
|
@@ -71,7 +71,7 @@ class StructuredTool extends base_js_1.BaseLangChain {
|
|
|
71
71
|
const runManager = await callbackManager_?.handleToolStart(this.toJSON(), typeof parsed === "string" ? parsed : JSON.stringify(parsed), undefined, undefined, undefined, undefined, config.runName);
|
|
72
72
|
let result;
|
|
73
73
|
try {
|
|
74
|
-
result = await this._call(parsed, runManager);
|
|
74
|
+
result = await this._call(parsed, runManager, config);
|
|
75
75
|
}
|
|
76
76
|
catch (e) {
|
|
77
77
|
await runManager?.handleToolError(e);
|
|
@@ -149,8 +149,8 @@ class DynamicTool extends Tool {
|
|
|
149
149
|
return super.call(arg, config);
|
|
150
150
|
}
|
|
151
151
|
/** @ignore */
|
|
152
|
-
async _call(input, runManager) {
|
|
153
|
-
return this.func(input, runManager);
|
|
152
|
+
async _call(input, runManager, config) {
|
|
153
|
+
return this.func(input, runManager, config);
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
exports.DynamicTool = DynamicTool;
|
|
@@ -205,8 +205,8 @@ class DynamicStructuredTool extends StructuredTool {
|
|
|
205
205
|
}
|
|
206
206
|
return super.call(arg, config, tags);
|
|
207
207
|
}
|
|
208
|
-
_call(arg, runManager) {
|
|
209
|
-
return this.func(arg, runManager);
|
|
208
|
+
_call(arg, runManager, config) {
|
|
209
|
+
return this.func(arg, runManager, config);
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
exports.DynamicStructuredTool = DynamicStructuredTool;
|
package/dist/tools.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ export declare abstract class StructuredTool<T extends z.ZodObject<any, any, any
|
|
|
43
43
|
abstract schema: T | z.ZodEffects<T>;
|
|
44
44
|
get lc_namespace(): string[];
|
|
45
45
|
constructor(fields?: ToolParams);
|
|
46
|
-
protected abstract _call(arg: z.output<T>, runManager?: CallbackManagerForToolRun): Promise<string>;
|
|
46
|
+
protected abstract _call(arg: z.output<T>, runManager?: CallbackManagerForToolRun, config?: RunnableConfig): Promise<string>;
|
|
47
47
|
/**
|
|
48
48
|
* Invokes the tool with the provided input and configuration.
|
|
49
49
|
* @param input The input for the tool.
|
|
@@ -109,13 +109,13 @@ export interface BaseDynamicToolInput extends ToolParams {
|
|
|
109
109
|
* Interface for the input parameters of the DynamicTool class.
|
|
110
110
|
*/
|
|
111
111
|
export interface DynamicToolInput extends BaseDynamicToolInput {
|
|
112
|
-
func: (input: string, runManager?: CallbackManagerForToolRun) => Promise<string>;
|
|
112
|
+
func: (input: string, runManager?: CallbackManagerForToolRun, config?: RunnableConfig) => Promise<string>;
|
|
113
113
|
}
|
|
114
114
|
/**
|
|
115
115
|
* Interface for the input parameters of the DynamicStructuredTool class.
|
|
116
116
|
*/
|
|
117
117
|
export interface DynamicStructuredToolInput<T extends z.ZodObject<any, any, any, any> = z.ZodObject<any, any, any, any>> extends BaseDynamicToolInput {
|
|
118
|
-
func: (input: z.infer<T>, runManager?: CallbackManagerForToolRun) => Promise<string>;
|
|
118
|
+
func: (input: z.infer<T>, runManager?: CallbackManagerForToolRun, config?: RunnableConfig) => Promise<string>;
|
|
119
119
|
schema: T;
|
|
120
120
|
}
|
|
121
121
|
/**
|
|
@@ -129,7 +129,7 @@ export declare class DynamicTool extends Tool {
|
|
|
129
129
|
constructor(fields: DynamicToolInput);
|
|
130
130
|
call(arg: string | undefined | z.input<this["schema"]>, configArg?: RunnableConfig | Callbacks): Promise<string>;
|
|
131
131
|
/** @ignore */
|
|
132
|
-
_call(input: string, runManager?: CallbackManagerForToolRun): Promise<string>;
|
|
132
|
+
_call(input: string, runManager?: CallbackManagerForToolRun, config?: RunnableConfig): Promise<string>;
|
|
133
133
|
}
|
|
134
134
|
/**
|
|
135
135
|
* A tool that can be created dynamically from a function, name, and
|
|
@@ -147,5 +147,5 @@ export declare class DynamicStructuredTool<T extends z.ZodObject<any, any, any,
|
|
|
147
147
|
call(arg: z.output<T>, configArg?: RunnableConfig | Callbacks,
|
|
148
148
|
/** @deprecated */
|
|
149
149
|
tags?: string[]): Promise<string>;
|
|
150
|
-
protected _call(arg: z.output<T>, runManager?: CallbackManagerForToolRun): Promise<string>;
|
|
150
|
+
protected _call(arg: z.output<T>, runManager?: CallbackManagerForToolRun, config?: RunnableConfig): Promise<string>;
|
|
151
151
|
}
|
package/dist/tools.js
CHANGED
|
@@ -67,7 +67,7 @@ export class StructuredTool extends BaseLangChain {
|
|
|
67
67
|
const runManager = await callbackManager_?.handleToolStart(this.toJSON(), typeof parsed === "string" ? parsed : JSON.stringify(parsed), undefined, undefined, undefined, undefined, config.runName);
|
|
68
68
|
let result;
|
|
69
69
|
try {
|
|
70
|
-
result = await this._call(parsed, runManager);
|
|
70
|
+
result = await this._call(parsed, runManager, config);
|
|
71
71
|
}
|
|
72
72
|
catch (e) {
|
|
73
73
|
await runManager?.handleToolError(e);
|
|
@@ -143,8 +143,8 @@ export class DynamicTool extends Tool {
|
|
|
143
143
|
return super.call(arg, config);
|
|
144
144
|
}
|
|
145
145
|
/** @ignore */
|
|
146
|
-
async _call(input, runManager) {
|
|
147
|
-
return this.func(input, runManager);
|
|
146
|
+
async _call(input, runManager, config) {
|
|
147
|
+
return this.func(input, runManager, config);
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
/**
|
|
@@ -198,7 +198,7 @@ export class DynamicStructuredTool extends StructuredTool {
|
|
|
198
198
|
}
|
|
199
199
|
return super.call(arg, config, tags);
|
|
200
200
|
}
|
|
201
|
-
_call(arg, runManager) {
|
|
202
|
-
return this.func(arg, runManager);
|
|
201
|
+
_call(arg, runManager, config) {
|
|
202
|
+
return this.func(arg, runManager, config);
|
|
203
203
|
}
|
|
204
204
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langchain/core",
|
|
3
|
-
"version": "0.1.29
|
|
3
|
+
"version": "0.1.29",
|
|
4
4
|
"description": "Core LangChain.js abstractions and schemas",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"camelcase": "6",
|
|
44
44
|
"decamelize": "1.2.0",
|
|
45
45
|
"js-tiktoken": "^1.0.8",
|
|
46
|
-
"langsmith": "~0.
|
|
46
|
+
"langsmith": "~0.1.1",
|
|
47
47
|
"ml-distance": "^4.0.0",
|
|
48
48
|
"p-queue": "^6.6.2",
|
|
49
49
|
"p-retry": "4",
|