Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@langchain/anthropic

Package Overview
Dependencies
Maintainers
10
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@langchain/anthropic - npm Package Compare versions

Comparing version 0.2.17 to 0.3.0-rc.0

10

dist/chat_models.d.ts

@@ -510,2 +510,3 @@ import { Anthropic, type ClientOptions } from "@anthropic-ai/sdk";

* @returns {AnthropicTool[] | undefined} The formatted tools, or undefined if none are passed.
* @throws {Error} If a mix of AnthropicTools and StructuredTools are passed.
*/

@@ -556,13 +557,4 @@ formatStructuredToolToAnthropic(tools: ChatAnthropicCallOptions["tools"]): AnthropicTool[] | undefined;

id: string;
/** Does nucleus sampling, in which we compute the
* cumulative distribution over all the options for each
* subsequent token in decreasing probability order and
* cut it off once it reaches a particular probability
* specified by top_p. Defaults to -1, which disables it.
* Note that you should either alter temperature or top_p,
* but not both.
*/
model: Anthropic.Messages.Model;
stop_reason: "tool_use" | "stop_sequence" | "end_turn" | "max_tokens" | null;
/** Anthropic API URL */
stop_sequence: string | null;

@@ -569,0 +561,0 @@ usage: Anthropic.Messages.Usage;

47

dist/chat_models.js

@@ -593,2 +593,3 @@ import { Anthropic } from "@anthropic-ai/sdk";

* @returns {AnthropicTool[] | undefined} The formatted tools, or undefined if none are passed.
* @throws {Error} If a mix of AnthropicTools and StructuredTools are passed.
*/

@@ -599,22 +600,28 @@ formatStructuredToolToAnthropic(tools) {

}
return tools.map((tool) => {
if (isAnthropicTool(tool)) {
return tool;
}
if (isOpenAITool(tool)) {
return {
name: tool.function.name,
description: tool.function.description,
input_schema: tool.function.parameters,
};
}
if (isLangChainTool(tool)) {
return {
name: tool.name,
description: tool.description,
input_schema: zodToJsonSchema(tool.schema),
};
}
throw new Error(`Unknown tool type passed to ChatAnthropic: ${JSON.stringify(tool, null, 2)}`);
});
// eslint-disable-next-line @typescript-eslint/no-explicit-any
if (tools.every((tool) => isAnthropicTool(tool))) {
// If the tool is already an anthropic tool, return it
return tools;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
if (tools.every((tool) => isOpenAITool(tool))) {
// Formatted as OpenAI tool, convert to Anthropic tool
return tools.map((tc) => ({
name: tc.function.name,
description: tc.function.description,
input_schema: tc.function.parameters,
}));
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
if (tools.some((tool) => isAnthropicTool(tool))) {
throw new Error(`Can not pass in a mix of tool schemas to ChatAnthropic`);
}
if (tools.every(isLangChainTool)) {
return tools.map((t) => ({
name: t.name,
description: t.description,
input_schema: zodToJsonSchema(t.schema),
}));
}
throw new Error("Unsupported tool type passed to ChatAnthropic");
}

@@ -621,0 +628,0 @@ bindTools(tools, kwargs) {

@@ -102,3 +102,2 @@ /**

const contentBlocks = content.map((contentPart) => {
const cacheControl = "cache_control" in contentPart ? contentPart.cache_control : undefined;
if (contentPart.type === "image_url") {

@@ -115,3 +114,2 @@ let source;

source,
...(cacheControl ? { cache_control: cacheControl } : {}),
};

@@ -125,3 +123,2 @@ }

text: contentPart.text,
...(cacheControl ? { cache_control: cacheControl } : {}),
};

@@ -152,3 +149,2 @@ }

...contentPartCopy,
...(cacheControl ? { cache_control: cacheControl } : {}),
// eslint-disable-next-line @typescript-eslint/no-explicit-any

@@ -155,0 +151,0 @@ };

{
"name": "@langchain/anthropic",
"version": "0.2.17",
"version": "0.3.0-rc.0",
"description": "Anthropic integrations for LangChain.js",

@@ -39,3 +39,2 @@ "type": "module",

"@anthropic-ai/sdk": "^0.25.2",
"@langchain/core": ">=0.2.21 <0.3.0",
"fast-xml-parser": "^4.4.1",

@@ -45,5 +44,9 @@ "zod": "^3.22.4",

},
"peerDependencies": {
"@langchain/core": ">=0.2.21 <0.4.0 || 0.3.0-rc.0"
},
"devDependencies": {
"@anthropic-ai/vertex-sdk": "^0.4.1",
"@jest/globals": "^29.5.0",
"@langchain/core": "workspace:*",
"@langchain/scripts": ">=0.1.0 <0.2.0",

@@ -50,0 +53,0 @@ "@langchain/standard-tests": "0.0.0",

@@ -21,13 +21,13 @@ # @langchain/anthropic

"@langchain/anthropic": "^0.0.9",
"langchain": "0.0.207"
"@langchain/core": "^0.3.0"
},
"resolutions": {
"@langchain/core": "0.1.5"
"@langchain/core": "^0.3.0"
},
"overrides": {
"@langchain/core": "0.1.5"
"@langchain/core": "^0.3.0"
},
"pnpm": {
"overrides": {
"@langchain/core": "0.1.5"
"@langchain/core": "^0.3.0"
}

@@ -34,0 +34,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc