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.3.7 to 0.3.8

37

dist/utils/message_inputs.js

@@ -21,9 +21,9 @@ /**

}
function _mergeMessages(messages) {
function _ensureMessageContents(messages) {
// Merge runs of human/tool messages into single human messages with content blocks.
const merged = [];
const updatedMsgs = [];
for (const message of messages) {
if (message._getType() === "tool") {
if (typeof message.content === "string") {
const previousMessage = merged[merged.length - 1];
const previousMessage = updatedMsgs[updatedMsgs.length - 1];
if (previousMessage?._getType() === "human" &&

@@ -42,3 +42,3 @@ Array.isArray(previousMessage.content) &&

// If not, we create a new human message with the tool result.
merged.push(new HumanMessage({
updatedMsgs.push(new HumanMessage({
content: [

@@ -55,3 +55,3 @@ {

else {
merged.push(new HumanMessage({
updatedMsgs.push(new HumanMessage({
content: [

@@ -68,27 +68,6 @@ {

else {
const previousMessage = merged[merged.length - 1];
if (previousMessage?._getType() === "human" &&
message._getType() === "human") {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let combinedContent;
if (typeof previousMessage.content === "string") {
combinedContent = [{ type: "text", text: previousMessage.content }];
}
else {
combinedContent = previousMessage.content;
}
if (typeof message.content === "string") {
combinedContent.push({ type: "text", text: message.content });
}
else {
combinedContent = combinedContent.concat(message.content);
}
previousMessage.content = combinedContent;
}
else {
merged.push(message);
}
updatedMsgs.push(message);
}
}
return merged;
return updatedMsgs;
}

@@ -179,3 +158,3 @@ export function _convertLangChainToolCallToAnthropic(toolCall) {

export function _convertMessagesToAnthropicPayload(messages) {
const mergedMessages = _mergeMessages(messages);
const mergedMessages = _ensureMessageContents(messages);
let system;

@@ -182,0 +161,0 @@ if (mergedMessages.length > 0 && mergedMessages[0]._getType() === "system") {

{
"name": "@langchain/anthropic",
"version": "0.3.7",
"version": "0.3.8",
"description": "Anthropic integrations for LangChain.js",

@@ -5,0 +5,0 @@ "type": "module",

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