langchain 0.3.30 → 0.3.32
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/openai_tools/output_parser.cjs +18 -13
- package/dist/agents/openai_tools/output_parser.js +18 -13
- package/dist/agents/tool_calling/output_parser.cjs +1 -1
- package/dist/agents/tool_calling/output_parser.js +1 -1
- package/dist/chains/openai_functions/openapi.cjs +2 -1
- package/dist/chains/openai_functions/openapi.js +2 -1
- package/dist/chat_models/universal.cjs +1 -1
- package/dist/chat_models/universal.js +1 -1
- package/dist/hub/base.cjs +19 -0
- package/dist/hub/base.d.ts +1 -0
- package/dist/hub/base.js +18 -0
- package/dist/hub/index.cjs +1 -1
- package/dist/hub/index.js +2 -2
- package/dist/hub/node.cjs +1 -1
- package/dist/hub/node.js +2 -2
- package/dist/smith/runner_utils.cjs +2 -1
- package/dist/smith/runner_utils.js +2 -1
- package/dist/util/sql_utils.cjs +1 -0
- package/dist/util/sql_utils.js +1 -0
- package/package.json +5 -5
|
@@ -68,19 +68,24 @@ class OpenAIToolsAgentOutputParser extends types_js_1.AgentMultiActionOutputPars
|
|
|
68
68
|
if (message.additional_kwargs.tool_calls) {
|
|
69
69
|
const toolCalls = message.additional_kwargs.tool_calls;
|
|
70
70
|
try {
|
|
71
|
-
return toolCalls
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
71
|
+
return toolCalls
|
|
72
|
+
.map((toolCall, i) => {
|
|
73
|
+
if (toolCall.type === "function") {
|
|
74
|
+
const toolInput = toolCall.function.arguments
|
|
75
|
+
? JSON.parse(toolCall.function.arguments)
|
|
76
|
+
: {};
|
|
77
|
+
const messageLog = i === 0 ? [message] : [];
|
|
78
|
+
return {
|
|
79
|
+
tool: toolCall.function.name,
|
|
80
|
+
toolInput,
|
|
81
|
+
toolCallId: toolCall.id,
|
|
82
|
+
log: `Invoking "${toolCall.function.name}" with ${toolCall.function.arguments ?? "{}"}\n${message.content}`,
|
|
83
|
+
messageLog,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return undefined;
|
|
87
|
+
})
|
|
88
|
+
.filter(Boolean);
|
|
84
89
|
}
|
|
85
90
|
catch (error) {
|
|
86
91
|
throw new output_parsers_1.OutputParserException(`Failed to parse tool arguments from chat model response. Text: "${JSON.stringify(toolCalls)}". ${error}`);
|
|
@@ -65,19 +65,24 @@ export class OpenAIToolsAgentOutputParser extends AgentMultiActionOutputParser {
|
|
|
65
65
|
if (message.additional_kwargs.tool_calls) {
|
|
66
66
|
const toolCalls = message.additional_kwargs.tool_calls;
|
|
67
67
|
try {
|
|
68
|
-
return toolCalls
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
68
|
+
return toolCalls
|
|
69
|
+
.map((toolCall, i) => {
|
|
70
|
+
if (toolCall.type === "function") {
|
|
71
|
+
const toolInput = toolCall.function.arguments
|
|
72
|
+
? JSON.parse(toolCall.function.arguments)
|
|
73
|
+
: {};
|
|
74
|
+
const messageLog = i === 0 ? [message] : [];
|
|
75
|
+
return {
|
|
76
|
+
tool: toolCall.function.name,
|
|
77
|
+
toolInput,
|
|
78
|
+
toolCallId: toolCall.id,
|
|
79
|
+
log: `Invoking "${toolCall.function.name}" with ${toolCall.function.arguments ?? "{}"}\n${message.content}`,
|
|
80
|
+
messageLog,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return undefined;
|
|
84
|
+
})
|
|
85
|
+
.filter(Boolean);
|
|
81
86
|
}
|
|
82
87
|
catch (error) {
|
|
83
88
|
throw new OutputParserException(`Failed to parse tool arguments from chat model response. Text: "${JSON.stringify(toolCalls)}". ${error}`);
|
|
@@ -14,7 +14,7 @@ function parseAIMessageToToolAction(message) {
|
|
|
14
14
|
toolCalls = message.tool_calls;
|
|
15
15
|
}
|
|
16
16
|
else {
|
|
17
|
-
if (message.additional_kwargs.tool_calls
|
|
17
|
+
if (!message.additional_kwargs.tool_calls ||
|
|
18
18
|
message.additional_kwargs.tool_calls.length === 0) {
|
|
19
19
|
return {
|
|
20
20
|
returnValues: { output: message.content },
|
|
@@ -10,7 +10,7 @@ export function parseAIMessageToToolAction(message) {
|
|
|
10
10
|
toolCalls = message.tool_calls;
|
|
11
11
|
}
|
|
12
12
|
else {
|
|
13
|
-
if (message.additional_kwargs.tool_calls
|
|
13
|
+
if (!message.additional_kwargs.tool_calls ||
|
|
14
14
|
message.additional_kwargs.tool_calls.length === 0) {
|
|
15
15
|
return {
|
|
16
16
|
returnValues: { output: message.content },
|
|
@@ -149,9 +149,10 @@ function convertOpenAPISchemaToJSONSchema(schema, spec) {
|
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
151
|
if (schema.type === "array") {
|
|
152
|
+
const openAPIItems = spec.getSchema(schema.items) ?? {};
|
|
152
153
|
return {
|
|
153
154
|
type: "array",
|
|
154
|
-
items: convertOpenAPISchemaToJSONSchema(
|
|
155
|
+
items: convertOpenAPISchemaToJSONSchema(openAPIItems, spec),
|
|
155
156
|
minItems: schema.minItems,
|
|
156
157
|
maxItems: schema.maxItems,
|
|
157
158
|
};
|
|
@@ -144,9 +144,10 @@ export function convertOpenAPISchemaToJSONSchema(schema, spec) {
|
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
146
|
if (schema.type === "array") {
|
|
147
|
+
const openAPIItems = spec.getSchema(schema.items) ?? {};
|
|
147
148
|
return {
|
|
148
149
|
type: "array",
|
|
149
|
-
items: convertOpenAPISchemaToJSONSchema(
|
|
150
|
+
items: convertOpenAPISchemaToJSONSchema(openAPIItems, spec),
|
|
150
151
|
minItems: schema.minItems,
|
|
151
152
|
maxItems: schema.maxItems,
|
|
152
153
|
};
|
|
@@ -616,7 +616,7 @@ exports.ConfigurableModel = ConfigurableModel;
|
|
|
616
616
|
* This function initializes a ChatModel based on the provided model name and provider.
|
|
617
617
|
* It supports various model providers and allows for runtime configuration of model parameters.
|
|
618
618
|
*
|
|
619
|
-
* Security Note: Setting `configurableFields` to "any" means fields like
|
|
619
|
+
* Security Note: Setting `configurableFields` to "any" means fields like apiKey, baseUrl, etc.
|
|
620
620
|
* can be altered at runtime, potentially redirecting model requests to a different service/user.
|
|
621
621
|
* Make sure that if you're accepting untrusted configurations, you enumerate the
|
|
622
622
|
* `configurableFields` explicitly.
|
|
@@ -577,7 +577,7 @@ export class ConfigurableModel extends BaseChatModel {
|
|
|
577
577
|
* This function initializes a ChatModel based on the provided model name and provider.
|
|
578
578
|
* It supports various model providers and allows for runtime configuration of model parameters.
|
|
579
579
|
*
|
|
580
|
-
* Security Note: Setting `configurableFields` to "any" means fields like
|
|
580
|
+
* Security Note: Setting `configurableFields` to "any" means fields like apiKey, baseUrl, etc.
|
|
581
581
|
* can be altered at runtime, potentially redirecting model requests to a different service/user.
|
|
582
582
|
* Make sure that if you're accepting untrusted configurations, you enumerate the
|
|
583
583
|
* `configurableFields` explicitly.
|
package/dist/hub/base.cjs
CHANGED
|
@@ -4,6 +4,7 @@ exports.basePush = basePush;
|
|
|
4
4
|
exports.basePull = basePull;
|
|
5
5
|
exports.generateModelImportMap = generateModelImportMap;
|
|
6
6
|
exports.generateOptionalImportMap = generateOptionalImportMap;
|
|
7
|
+
exports.bindOutputSchema = bindOutputSchema;
|
|
7
8
|
const langsmith_1 = require("langsmith");
|
|
8
9
|
/**
|
|
9
10
|
* Push a prompt to the hub.
|
|
@@ -138,3 +139,21 @@ modelClass) {
|
|
|
138
139
|
}
|
|
139
140
|
return optionalImportMap;
|
|
140
141
|
}
|
|
142
|
+
function bindOutputSchema(loadedSequence) {
|
|
143
|
+
if ("first" in loadedSequence &&
|
|
144
|
+
loadedSequence.first !== null &&
|
|
145
|
+
typeof loadedSequence.first === "object" &&
|
|
146
|
+
"schema" in loadedSequence.first &&
|
|
147
|
+
"last" in loadedSequence &&
|
|
148
|
+
loadedSequence.last !== null &&
|
|
149
|
+
typeof loadedSequence.last === "object" &&
|
|
150
|
+
"bound" in loadedSequence.last &&
|
|
151
|
+
loadedSequence.last.bound !== null &&
|
|
152
|
+
typeof loadedSequence.last.bound === "object" &&
|
|
153
|
+
"withStructuredOutput" in loadedSequence.last.bound &&
|
|
154
|
+
typeof loadedSequence.last.bound.withStructuredOutput === "function") {
|
|
155
|
+
// eslint-disable-next-line no-param-reassign
|
|
156
|
+
loadedSequence.last.bound = loadedSequence.last.bound.withStructuredOutput(loadedSequence.first.schema);
|
|
157
|
+
}
|
|
158
|
+
return loadedSequence;
|
|
159
|
+
}
|
package/dist/hub/base.d.ts
CHANGED
|
@@ -28,3 +28,4 @@ export declare function basePull(ownerRepoCommit: string, options?: {
|
|
|
28
28
|
}): Promise<import("langsmith/schemas").PromptCommit>;
|
|
29
29
|
export declare function generateModelImportMap(modelClass?: new (...args: any[]) => BaseLanguageModel): Record<string, any>;
|
|
30
30
|
export declare function generateOptionalImportMap(modelClass?: new (...args: any[]) => BaseLanguageModel): Record<string, any>;
|
|
31
|
+
export declare function bindOutputSchema<T extends Runnable>(loadedSequence: T): T;
|
package/dist/hub/base.js
CHANGED
|
@@ -132,3 +132,21 @@ modelClass) {
|
|
|
132
132
|
}
|
|
133
133
|
return optionalImportMap;
|
|
134
134
|
}
|
|
135
|
+
export function bindOutputSchema(loadedSequence) {
|
|
136
|
+
if ("first" in loadedSequence &&
|
|
137
|
+
loadedSequence.first !== null &&
|
|
138
|
+
typeof loadedSequence.first === "object" &&
|
|
139
|
+
"schema" in loadedSequence.first &&
|
|
140
|
+
"last" in loadedSequence &&
|
|
141
|
+
loadedSequence.last !== null &&
|
|
142
|
+
typeof loadedSequence.last === "object" &&
|
|
143
|
+
"bound" in loadedSequence.last &&
|
|
144
|
+
loadedSequence.last.bound !== null &&
|
|
145
|
+
typeof loadedSequence.last.bound === "object" &&
|
|
146
|
+
"withStructuredOutput" in loadedSequence.last.bound &&
|
|
147
|
+
typeof loadedSequence.last.bound.withStructuredOutput === "function") {
|
|
148
|
+
// eslint-disable-next-line no-param-reassign
|
|
149
|
+
loadedSequence.last.bound = loadedSequence.last.bound.withStructuredOutput(loadedSequence.first.schema);
|
|
150
|
+
}
|
|
151
|
+
return loadedSequence;
|
|
152
|
+
}
|
package/dist/hub/index.cjs
CHANGED
|
@@ -25,7 +25,7 @@ async function pull(ownerRepoCommit, options) {
|
|
|
25
25
|
const promptObject = await (0, base_js_1.basePull)(ownerRepoCommit, options);
|
|
26
26
|
try {
|
|
27
27
|
const loadedPrompt = await (0, index_js_1.load)(JSON.stringify(promptObject.manifest), undefined, (0, base_js_1.generateOptionalImportMap)(options?.modelClass), (0, base_js_1.generateModelImportMap)(options?.modelClass));
|
|
28
|
-
return loadedPrompt;
|
|
28
|
+
return (0, base_js_1.bindOutputSchema)(loadedPrompt);
|
|
29
29
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
30
|
}
|
|
31
31
|
catch (e) {
|
package/dist/hub/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { load } from "../load/index.js";
|
|
2
|
-
import { basePush, basePull, generateModelImportMap, generateOptionalImportMap, } from "./base.js";
|
|
2
|
+
import { basePush, basePull, generateModelImportMap, generateOptionalImportMap, bindOutputSchema, } from "./base.js";
|
|
3
3
|
export { basePush as push };
|
|
4
4
|
/**
|
|
5
5
|
* Pull a prompt from the hub.
|
|
@@ -21,7 +21,7 @@ export async function pull(ownerRepoCommit, options) {
|
|
|
21
21
|
const promptObject = await basePull(ownerRepoCommit, options);
|
|
22
22
|
try {
|
|
23
23
|
const loadedPrompt = await load(JSON.stringify(promptObject.manifest), undefined, generateOptionalImportMap(options?.modelClass), generateModelImportMap(options?.modelClass));
|
|
24
|
-
return loadedPrompt;
|
|
24
|
+
return bindOutputSchema(loadedPrompt);
|
|
25
25
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
26
|
}
|
|
27
27
|
catch (e) {
|
package/dist/hub/node.cjs
CHANGED
|
@@ -85,5 +85,5 @@ async function pull(ownerRepoCommit, options) {
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
const loadedPrompt = await (0, index_js_1.load)(JSON.stringify(promptObject.manifest), undefined, (0, base_js_1.generateOptionalImportMap)(modelClass), (0, base_js_1.generateModelImportMap)(modelClass));
|
|
88
|
-
return loadedPrompt;
|
|
88
|
+
return (0, base_js_1.bindOutputSchema)(loadedPrompt);
|
|
89
89
|
}
|
package/dist/hub/node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { basePush, basePull, generateModelImportMap, generateOptionalImportMap, } from "./base.js";
|
|
1
|
+
import { basePush, basePull, generateModelImportMap, generateOptionalImportMap, bindOutputSchema, } from "./base.js";
|
|
2
2
|
import { load } from "../load/index.js";
|
|
3
3
|
// TODO: Make this the default, add web entrypoint in next breaking release
|
|
4
4
|
export { basePush as push };
|
|
@@ -49,5 +49,5 @@ export async function pull(ownerRepoCommit, options) {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
const loadedPrompt = await load(JSON.stringify(promptObject.manifest), undefined, generateOptionalImportMap(modelClass), generateModelImportMap(modelClass));
|
|
52
|
-
return loadedPrompt;
|
|
52
|
+
return bindOutputSchema(loadedPrompt);
|
|
53
53
|
}
|
|
@@ -422,7 +422,8 @@ const applyEvaluators = async ({ evaluation, runs, examples, client, maxConcurre
|
|
|
422
422
|
progress.increment();
|
|
423
423
|
return {
|
|
424
424
|
execution_time: run?.end_time && run.start_time
|
|
425
|
-
? run.end_time -
|
|
425
|
+
? new Date(run.end_time).getTime() -
|
|
426
|
+
new Date(run.start_time).getTime()
|
|
426
427
|
: undefined,
|
|
427
428
|
feedback: evaluatorResults.map((evalResult) => evalResult.status === "fulfilled"
|
|
428
429
|
? evalResult.value
|
|
@@ -419,7 +419,8 @@ const applyEvaluators = async ({ evaluation, runs, examples, client, maxConcurre
|
|
|
419
419
|
progress.increment();
|
|
420
420
|
return {
|
|
421
421
|
execution_time: run?.end_time && run.start_time
|
|
422
|
-
? run.end_time -
|
|
422
|
+
? new Date(run.end_time).getTime() -
|
|
423
|
+
new Date(run.start_time).getTime()
|
|
423
424
|
: undefined,
|
|
424
425
|
feedback: evaluatorResults.map((evalResult) => evalResult.status === "fulfilled"
|
|
425
426
|
? evalResult.value
|
package/dist/util/sql_utils.cjs
CHANGED
|
@@ -64,6 +64,7 @@ const getTableAndColumnsName = async (appDataSource) => {
|
|
|
64
64
|
return formatToSqlTable(rep);
|
|
65
65
|
}
|
|
66
66
|
if (appDataSource.options.type === "sqlite" ||
|
|
67
|
+
appDataSource.options.type === "better-sqlite3" ||
|
|
67
68
|
appDataSource.options.type === "sqljs") {
|
|
68
69
|
sql =
|
|
69
70
|
"SELECT \n" +
|
package/dist/util/sql_utils.js
CHANGED
|
@@ -58,6 +58,7 @@ export const getTableAndColumnsName = async (appDataSource) => {
|
|
|
58
58
|
return formatToSqlTable(rep);
|
|
59
59
|
}
|
|
60
60
|
if (appDataSource.options.type === "sqlite" ||
|
|
61
|
+
appDataSource.options.type === "better-sqlite3" ||
|
|
61
62
|
appDataSource.options.type === "sqljs") {
|
|
62
63
|
sql =
|
|
63
64
|
"SELECT \n" +
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "langchain",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.32",
|
|
4
4
|
"description": "Typescript bindings for langchain",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -419,7 +419,7 @@
|
|
|
419
419
|
"@langchain/aws": "*",
|
|
420
420
|
"@langchain/cerebras": "*",
|
|
421
421
|
"@langchain/cohere": "*",
|
|
422
|
-
"@langchain/core": "
|
|
422
|
+
"@langchain/core": "workspace:*",
|
|
423
423
|
"@langchain/deepseek": "*",
|
|
424
424
|
"@langchain/google-genai": "*",
|
|
425
425
|
"@langchain/google-vertexai": "*",
|
|
@@ -440,7 +440,7 @@
|
|
|
440
440
|
"@types/ws": "^8",
|
|
441
441
|
"@typescript-eslint/eslint-plugin": "^5.58.0",
|
|
442
442
|
"@typescript-eslint/parser": "^5.58.0",
|
|
443
|
-
"axios": "^
|
|
443
|
+
"axios": "^1.11.0",
|
|
444
444
|
"cheerio": "1.0.0-rc.12",
|
|
445
445
|
"dotenv": "^16.0.3",
|
|
446
446
|
"dpdm": "^3.14.0",
|
|
@@ -545,7 +545,7 @@
|
|
|
545
545
|
"js-tiktoken": "^1.0.12",
|
|
546
546
|
"js-yaml": "^4.1.0",
|
|
547
547
|
"jsonpointer": "^5.0.1",
|
|
548
|
-
"langsmith": "^0.3.
|
|
548
|
+
"langsmith": "^0.3.46",
|
|
549
549
|
"openapi-types": "^12.1.3",
|
|
550
550
|
"p-retry": "4",
|
|
551
551
|
"uuid": "^10.0.0",
|
|
@@ -1418,4 +1418,4 @@
|
|
|
1418
1418
|
},
|
|
1419
1419
|
"./package.json": "./package.json"
|
|
1420
1420
|
}
|
|
1421
|
-
}
|
|
1421
|
+
}
|