@langchain/anthropic 0.1.4 → 0.1.5
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.
|
@@ -206,10 +206,7 @@ class ChatAnthropicTools extends chat_models_1.BaseChatModel {
|
|
|
206
206
|
throw new Error(`Anthropic only supports "functionCalling" as a method.`);
|
|
207
207
|
}
|
|
208
208
|
const functionName = name ?? "extract";
|
|
209
|
-
|
|
210
|
-
returnSingle: true,
|
|
211
|
-
keyName: functionName,
|
|
212
|
-
});
|
|
209
|
+
let outputParser;
|
|
213
210
|
let tools;
|
|
214
211
|
if (isZodSchema(schema)) {
|
|
215
212
|
const jsonSchema = (0, zod_to_json_schema_1.zodToJsonSchema)(schema);
|
|
@@ -223,6 +220,11 @@ class ChatAnthropicTools extends chat_models_1.BaseChatModel {
|
|
|
223
220
|
},
|
|
224
221
|
},
|
|
225
222
|
];
|
|
223
|
+
outputParser = new openai_tools_1.JsonOutputKeyToolsParser({
|
|
224
|
+
returnSingle: true,
|
|
225
|
+
keyName: functionName,
|
|
226
|
+
zodSchema: schema,
|
|
227
|
+
});
|
|
226
228
|
}
|
|
227
229
|
else {
|
|
228
230
|
tools = [
|
|
@@ -235,6 +237,10 @@ class ChatAnthropicTools extends chat_models_1.BaseChatModel {
|
|
|
235
237
|
},
|
|
236
238
|
},
|
|
237
239
|
];
|
|
240
|
+
outputParser = new openai_tools_1.JsonOutputKeyToolsParser({
|
|
241
|
+
returnSingle: true,
|
|
242
|
+
keyName: functionName,
|
|
243
|
+
});
|
|
238
244
|
}
|
|
239
245
|
const llm = this.bind({
|
|
240
246
|
tools,
|
|
@@ -271,7 +277,9 @@ class ChatAnthropicTools extends chat_models_1.BaseChatModel {
|
|
|
271
277
|
}
|
|
272
278
|
}
|
|
273
279
|
exports.ChatAnthropicTools = ChatAnthropicTools;
|
|
274
|
-
function isZodSchema(
|
|
280
|
+
function isZodSchema(
|
|
281
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
282
|
+
input) {
|
|
275
283
|
// Check for a characteristic method of Zod schemas
|
|
276
284
|
return typeof input?.parse === "function";
|
|
277
285
|
}
|
|
@@ -203,10 +203,7 @@ export class ChatAnthropicTools extends BaseChatModel {
|
|
|
203
203
|
throw new Error(`Anthropic only supports "functionCalling" as a method.`);
|
|
204
204
|
}
|
|
205
205
|
const functionName = name ?? "extract";
|
|
206
|
-
|
|
207
|
-
returnSingle: true,
|
|
208
|
-
keyName: functionName,
|
|
209
|
-
});
|
|
206
|
+
let outputParser;
|
|
210
207
|
let tools;
|
|
211
208
|
if (isZodSchema(schema)) {
|
|
212
209
|
const jsonSchema = zodToJsonSchema(schema);
|
|
@@ -220,6 +217,11 @@ export class ChatAnthropicTools extends BaseChatModel {
|
|
|
220
217
|
},
|
|
221
218
|
},
|
|
222
219
|
];
|
|
220
|
+
outputParser = new JsonOutputKeyToolsParser({
|
|
221
|
+
returnSingle: true,
|
|
222
|
+
keyName: functionName,
|
|
223
|
+
zodSchema: schema,
|
|
224
|
+
});
|
|
223
225
|
}
|
|
224
226
|
else {
|
|
225
227
|
tools = [
|
|
@@ -232,6 +234,10 @@ export class ChatAnthropicTools extends BaseChatModel {
|
|
|
232
234
|
},
|
|
233
235
|
},
|
|
234
236
|
];
|
|
237
|
+
outputParser = new JsonOutputKeyToolsParser({
|
|
238
|
+
returnSingle: true,
|
|
239
|
+
keyName: functionName,
|
|
240
|
+
});
|
|
235
241
|
}
|
|
236
242
|
const llm = this.bind({
|
|
237
243
|
tools,
|
|
@@ -267,7 +273,9 @@ export class ChatAnthropicTools extends BaseChatModel {
|
|
|
267
273
|
});
|
|
268
274
|
}
|
|
269
275
|
}
|
|
270
|
-
function isZodSchema(
|
|
276
|
+
function isZodSchema(
|
|
277
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
278
|
+
input) {
|
|
271
279
|
// Check for a characteristic method of Zod schemas
|
|
272
280
|
return typeof input?.parse === "function";
|
|
273
281
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langchain/anthropic",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Anthropic integrations for LangChain.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"license": "MIT",
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@anthropic-ai/sdk": "^0.15.0",
|
|
42
|
-
"@langchain/core": "~0.1",
|
|
42
|
+
"@langchain/core": "~0.1.44",
|
|
43
43
|
"fast-xml-parser": "^4.3.5",
|
|
44
44
|
"zod": "^3.22.4",
|
|
45
45
|
"zod-to-json-schema": "^3.22.4"
|