langchain 0.1.0 → 0.1.2
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/agent.cjs +1 -1
- package/dist/agents/agent.d.ts +1 -1
- package/dist/agents/agent.js +1 -1
- package/dist/chains/openai_functions/base.cjs +144 -0
- package/dist/chains/openai_functions/base.d.ts +153 -0
- package/dist/chains/openai_functions/base.js +139 -0
- package/dist/chains/openai_functions/index.cjs +4 -1
- package/dist/chains/openai_functions/index.d.ts +1 -0
- package/dist/chains/openai_functions/index.js +1 -0
- package/dist/evaluation/agents/trajectory.d.ts +2 -2
- package/dist/evaluation/base.d.ts +7 -6
- package/dist/evaluation/comparison/pairwise.d.ts +2 -2
- package/dist/evaluation/criteria/criteria.d.ts +2 -2
- package/dist/experimental/chat_models/ollama_functions.d.ts +1 -0
- package/dist/experimental/prompts/custom_format.cjs +68 -0
- package/dist/experimental/prompts/custom_format.d.ts +24 -0
- package/dist/experimental/prompts/custom_format.js +64 -0
- package/dist/experimental/prompts/handlebars.cjs +71 -0
- package/dist/experimental/prompts/handlebars.d.ts +13 -0
- package/dist/experimental/prompts/handlebars.js +62 -0
- package/dist/load/import_constants.cjs +1 -0
- package/dist/load/import_constants.js +1 -0
- 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/output_parsers/datetime.cjs +63 -0
- package/dist/output_parsers/datetime.d.ts +27 -0
- package/dist/output_parsers/datetime.js +59 -0
- package/dist/output_parsers/index.cjs +3 -1
- package/dist/output_parsers/index.d.ts +1 -0
- package/dist/output_parsers/index.js +1 -0
- package/dist/output_parsers/openai_functions.cjs +8 -3
- package/dist/output_parsers/openai_functions.d.ts +8 -5
- package/dist/output_parsers/openai_functions.js +8 -3
- package/dist/output_parsers/openai_tools.cjs +18 -5
- package/dist/output_parsers/openai_tools.d.ts +4 -0
- package/dist/output_parsers/openai_tools.js +18 -5
- package/experimental/prompts/custom_format.cjs +1 -0
- package/experimental/prompts/custom_format.d.ts +1 -0
- package/experimental/prompts/custom_format.js +1 -0
- package/experimental/prompts/handlebars.cjs +1 -0
- package/experimental/prompts/handlebars.d.ts +1 -0
- package/experimental/prompts/handlebars.js +1 -0
- package/package.json +24 -2
|
@@ -15,7 +15,7 @@ export class OutputFunctionsParser extends BaseLLMOutputParser {
|
|
|
15
15
|
enumerable: true,
|
|
16
16
|
configurable: true,
|
|
17
17
|
writable: true,
|
|
18
|
-
value: ["langchain", "output_parsers"]
|
|
18
|
+
value: ["langchain", "output_parsers", "openai_functions"]
|
|
19
19
|
});
|
|
20
20
|
Object.defineProperty(this, "lc_serializable", {
|
|
21
21
|
enumerable: true,
|
|
@@ -71,7 +71,7 @@ export class JsonOutputFunctionsParser extends BaseCumulativeTransformOutputPars
|
|
|
71
71
|
enumerable: true,
|
|
72
72
|
configurable: true,
|
|
73
73
|
writable: true,
|
|
74
|
-
value: ["langchain", "output_parsers"]
|
|
74
|
+
value: ["langchain", "output_parsers", "openai_functions"]
|
|
75
75
|
});
|
|
76
76
|
Object.defineProperty(this, "lc_serializable", {
|
|
77
77
|
enumerable: true,
|
|
@@ -153,13 +153,18 @@ export class JsonKeyOutputFunctionsParser extends BaseLLMOutputParser {
|
|
|
153
153
|
static lc_name() {
|
|
154
154
|
return "JsonKeyOutputFunctionsParser";
|
|
155
155
|
}
|
|
156
|
+
get lc_aliases() {
|
|
157
|
+
return {
|
|
158
|
+
attrName: "key_name",
|
|
159
|
+
};
|
|
160
|
+
}
|
|
156
161
|
constructor(fields) {
|
|
157
162
|
super(fields);
|
|
158
163
|
Object.defineProperty(this, "lc_namespace", {
|
|
159
164
|
enumerable: true,
|
|
160
165
|
configurable: true,
|
|
161
166
|
writable: true,
|
|
162
|
-
value: ["langchain", "output_parsers"]
|
|
167
|
+
value: ["langchain", "output_parsers", "openai_functions"]
|
|
163
168
|
});
|
|
164
169
|
Object.defineProperty(this, "lc_serializable", {
|
|
165
170
|
enumerable: true,
|
|
@@ -13,7 +13,7 @@ class JsonOutputToolsParser extends output_parsers_1.BaseLLMOutputParser {
|
|
|
13
13
|
enumerable: true,
|
|
14
14
|
configurable: true,
|
|
15
15
|
writable: true,
|
|
16
|
-
value: ["langchain", "output_parsers"]
|
|
16
|
+
value: ["langchain", "output_parsers", "openai_tools"]
|
|
17
17
|
});
|
|
18
18
|
Object.defineProperty(this, "lc_serializable", {
|
|
19
19
|
enumerable: true,
|
|
@@ -40,11 +40,24 @@ class JsonOutputToolsParser extends output_parsers_1.BaseLLMOutputParser {
|
|
|
40
40
|
const parsedToolCalls = [];
|
|
41
41
|
for (const toolCall of clonedToolCalls) {
|
|
42
42
|
if (toolCall.function !== undefined) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
// @ts-expect-error name and arguemnts are defined by Object.defineProperty
|
|
44
|
+
const parsedToolCall = {
|
|
45
|
+
type: toolCall.function.name,
|
|
46
|
+
args: JSON.parse(toolCall.function.arguments),
|
|
47
|
+
};
|
|
48
|
+
// backward-compatibility with previous
|
|
49
|
+
// versions of Langchain JS, which uses `name` and `arguments`
|
|
50
|
+
Object.defineProperty(parsedToolCall, "name", {
|
|
51
|
+
get() {
|
|
52
|
+
return this.type;
|
|
53
|
+
},
|
|
47
54
|
});
|
|
55
|
+
Object.defineProperty(parsedToolCall, "arguments", {
|
|
56
|
+
get() {
|
|
57
|
+
return this.args;
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
parsedToolCalls.push(parsedToolCall);
|
|
48
61
|
}
|
|
49
62
|
}
|
|
50
63
|
return parsedToolCalls;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { BaseLLMOutputParser } from "@langchain/core/output_parsers";
|
|
2
2
|
import type { ChatGeneration } from "@langchain/core/outputs";
|
|
3
3
|
export type ParsedToolCall = {
|
|
4
|
+
type: string;
|
|
5
|
+
args: Record<string, any>;
|
|
6
|
+
/** @deprecated Use `type` instead. Will be removed in 0.2.0. */
|
|
4
7
|
name: string;
|
|
8
|
+
/** @deprecated Use `args` instead. Will be removed in 0.2.0. */
|
|
5
9
|
arguments: Record<string, any>;
|
|
6
10
|
};
|
|
7
11
|
/**
|
|
@@ -10,7 +10,7 @@ export class JsonOutputToolsParser extends BaseLLMOutputParser {
|
|
|
10
10
|
enumerable: true,
|
|
11
11
|
configurable: true,
|
|
12
12
|
writable: true,
|
|
13
|
-
value: ["langchain", "output_parsers"]
|
|
13
|
+
value: ["langchain", "output_parsers", "openai_tools"]
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(this, "lc_serializable", {
|
|
16
16
|
enumerable: true,
|
|
@@ -37,11 +37,24 @@ export class JsonOutputToolsParser extends BaseLLMOutputParser {
|
|
|
37
37
|
const parsedToolCalls = [];
|
|
38
38
|
for (const toolCall of clonedToolCalls) {
|
|
39
39
|
if (toolCall.function !== undefined) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
// @ts-expect-error name and arguemnts are defined by Object.defineProperty
|
|
41
|
+
const parsedToolCall = {
|
|
42
|
+
type: toolCall.function.name,
|
|
43
|
+
args: JSON.parse(toolCall.function.arguments),
|
|
44
|
+
};
|
|
45
|
+
// backward-compatibility with previous
|
|
46
|
+
// versions of Langchain JS, which uses `name` and `arguments`
|
|
47
|
+
Object.defineProperty(parsedToolCall, "name", {
|
|
48
|
+
get() {
|
|
49
|
+
return this.type;
|
|
50
|
+
},
|
|
44
51
|
});
|
|
52
|
+
Object.defineProperty(parsedToolCall, "arguments", {
|
|
53
|
+
get() {
|
|
54
|
+
return this.args;
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
parsedToolCalls.push(parsedToolCall);
|
|
45
58
|
}
|
|
46
59
|
}
|
|
47
60
|
return parsedToolCalls;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../../dist/experimental/prompts/custom_format.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../dist/experimental/prompts/custom_format.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../dist/experimental/prompts/custom_format.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../../dist/experimental/prompts/handlebars.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../dist/experimental/prompts/handlebars.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../dist/experimental/prompts/handlebars.js'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "langchain",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Typescript bindings for langchain",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -853,6 +853,12 @@
|
|
|
853
853
|
"experimental/masking.cjs",
|
|
854
854
|
"experimental/masking.js",
|
|
855
855
|
"experimental/masking.d.ts",
|
|
856
|
+
"experimental/prompts/custom_format.cjs",
|
|
857
|
+
"experimental/prompts/custom_format.js",
|
|
858
|
+
"experimental/prompts/custom_format.d.ts",
|
|
859
|
+
"experimental/prompts/handlebars.cjs",
|
|
860
|
+
"experimental/prompts/handlebars.js",
|
|
861
|
+
"experimental/prompts/handlebars.d.ts",
|
|
856
862
|
"experimental/tools/pyinterpreter.cjs",
|
|
857
863
|
"experimental/tools/pyinterpreter.js",
|
|
858
864
|
"experimental/tools/pyinterpreter.d.ts",
|
|
@@ -919,6 +925,7 @@
|
|
|
919
925
|
"@tsconfig/recommended": "^1.0.2",
|
|
920
926
|
"@types/d3-dsv": "^2",
|
|
921
927
|
"@types/decamelize": "^1.2.0",
|
|
928
|
+
"@types/handlebars": "^4.1.0",
|
|
922
929
|
"@types/html-to-text": "^9",
|
|
923
930
|
"@types/js-yaml": "^4",
|
|
924
931
|
"@types/jsdom": "^21.1.1",
|
|
@@ -949,6 +956,7 @@
|
|
|
949
956
|
"fast-xml-parser": "^4.2.7",
|
|
950
957
|
"google-auth-library": "^8.9.0",
|
|
951
958
|
"googleapis": "^126.0.1",
|
|
959
|
+
"handlebars": "^4.7.8",
|
|
952
960
|
"html-to-text": "^9.0.5",
|
|
953
961
|
"ignore": "^5.2.0",
|
|
954
962
|
"ioredis": "^5.3.2",
|
|
@@ -1008,6 +1016,7 @@
|
|
|
1008
1016
|
"fast-xml-parser": "^4.2.7",
|
|
1009
1017
|
"google-auth-library": "^8.9.0",
|
|
1010
1018
|
"googleapis": "^126.0.1",
|
|
1019
|
+
"handlebars": "^4.7.8",
|
|
1011
1020
|
"html-to-text": "^9.0.5",
|
|
1012
1021
|
"ignore": "^5.2.0",
|
|
1013
1022
|
"ioredis": "^5.3.2",
|
|
@@ -1115,6 +1124,9 @@
|
|
|
1115
1124
|
"googleapis": {
|
|
1116
1125
|
"optional": true
|
|
1117
1126
|
},
|
|
1127
|
+
"handlebars": {
|
|
1128
|
+
"optional": true
|
|
1129
|
+
},
|
|
1118
1130
|
"html-to-text": {
|
|
1119
1131
|
"optional": true
|
|
1120
1132
|
},
|
|
@@ -1191,7 +1203,7 @@
|
|
|
1191
1203
|
"dependencies": {
|
|
1192
1204
|
"@anthropic-ai/sdk": "^0.9.1",
|
|
1193
1205
|
"@langchain/community": "~0.0.15",
|
|
1194
|
-
"@langchain/core": "~0.1.
|
|
1206
|
+
"@langchain/core": "~0.1.12",
|
|
1195
1207
|
"@langchain/openai": "~0.0.10",
|
|
1196
1208
|
"binary-extensions": "^2.2.0",
|
|
1197
1209
|
"expr-eval": "^2.0.2",
|
|
@@ -2631,6 +2643,16 @@
|
|
|
2631
2643
|
"import": "./experimental/masking.js",
|
|
2632
2644
|
"require": "./experimental/masking.cjs"
|
|
2633
2645
|
},
|
|
2646
|
+
"./experimental/prompts/custom_format": {
|
|
2647
|
+
"types": "./experimental/prompts/custom_format.d.ts",
|
|
2648
|
+
"import": "./experimental/prompts/custom_format.js",
|
|
2649
|
+
"require": "./experimental/prompts/custom_format.cjs"
|
|
2650
|
+
},
|
|
2651
|
+
"./experimental/prompts/handlebars": {
|
|
2652
|
+
"types": "./experimental/prompts/handlebars.d.ts",
|
|
2653
|
+
"import": "./experimental/prompts/handlebars.js",
|
|
2654
|
+
"require": "./experimental/prompts/handlebars.cjs"
|
|
2655
|
+
},
|
|
2634
2656
|
"./experimental/tools/pyinterpreter": {
|
|
2635
2657
|
"types": "./experimental/tools/pyinterpreter.d.ts",
|
|
2636
2658
|
"import": "./experimental/tools/pyinterpreter.js",
|