@langchain/anthropic 0.1.4 → 0.1.6

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.
@@ -119,7 +119,7 @@ export declare class ChatAnthropicMessages<CallOptions extends BaseLanguageModel
119
119
  metadata?: Anthropic.Messages.MessageCreateParams.Metadata | undefined;
120
120
  stream?: boolean | undefined;
121
121
  max_tokens: number;
122
- model: string;
122
+ model: (string & {}) | "claude-3-opus-20240229" | "claude-3-sonnet-20240229" | "claude-2.1'" | "claude-2.0" | "claude-instant-1.2";
123
123
  stop_sequences?: string[] | undefined;
124
124
  system?: string | undefined;
125
125
  temperature?: number | undefined;
@@ -134,7 +134,7 @@ export declare class ChatAnthropicMessages<CallOptions extends BaseLanguageModel
134
134
  metadata?: Anthropic.Messages.MessageCreateParams.Metadata | undefined;
135
135
  stream?: boolean | undefined;
136
136
  max_tokens: number;
137
- model: string;
137
+ model: (string & {}) | "claude-3-opus-20240229" | "claude-3-sonnet-20240229" | "claude-2.1'" | "claude-2.0" | "claude-instant-1.2";
138
138
  stop_sequences?: string[] | undefined;
139
139
  system?: string | undefined;
140
140
  temperature?: number | undefined;
@@ -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
- const outputParser = new openai_tools_1.JsonOutputKeyToolsParser({
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(input) {
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
- const outputParser = new JsonOutputKeyToolsParser({
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(input) {
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.4",
3
+ "version": "0.1.6",
4
4
  "description": "Anthropic integrations for LangChain.js",
5
5
  "type": "module",
6
6
  "engines": {
@@ -29,6 +29,7 @@
29
29
  "test": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%",
30
30
  "test:watch": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts",
31
31
  "test:single": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules yarn run jest --config jest.config.cjs --testTimeout 100000",
32
+ "test:int": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --testPathPattern=\\.int\\.test.ts --testTimeout 100000 --maxWorkers=50%",
32
33
  "format": "prettier --config .prettierrc --write \"src\"",
33
34
  "format:check": "prettier --config .prettierrc --check \"src\"",
34
35
  "move-cjs-to-dist": "yarn lc-build --config ./langchain.config.js --move-cjs-dist",
@@ -38,8 +39,8 @@
38
39
  "author": "LangChain",
39
40
  "license": "MIT",
40
41
  "dependencies": {
41
- "@anthropic-ai/sdk": "^0.15.0",
42
- "@langchain/core": "~0.1",
42
+ "@anthropic-ai/sdk": "^0.17.2",
43
+ "@langchain/core": "~0.1.44",
43
44
  "fast-xml-parser": "^4.3.5",
44
45
  "zod": "^3.22.4",
45
46
  "zod-to-json-schema": "^3.22.4"