Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

anthropic[patch]: Bump version, relax types #6526

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libs/langchain-anthropic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"author": "LangChain",
"license": "MIT",
"dependencies": {
"@anthropic-ai/sdk": "^0.22.0",
"@anthropic-ai/sdk": "^0.25.2",
"@langchain/core": ">=0.2.21 <0.3.0",
"fast-xml-parser": "^4.4.1",
"zod": "^3.22.4",
Expand Down
19 changes: 9 additions & 10 deletions libs/langchain-anthropic/src/utils/message_inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import {
isAIMessage,
} from "@langchain/core/messages";
import { ToolCall } from "@langchain/core/messages/tool";
import { AnthropicMessageParam, AnthropicToolResponse } from "../types.js";
import {
AnthropicMessageCreateParams,
AnthropicToolResponse,
} from "../types.js";

function _formatImage(imageUrl: string) {
const regex = /^data:(image\/.+);base64,(.+)$/;
Expand Down Expand Up @@ -179,16 +182,12 @@ function _formatContent(content: MessageContent) {
* @param messages The base messages to format as a prompt.
* @returns The formatted prompt.
*/
export function _formatMessagesForAnthropic(messages: BaseMessage[]): {
system?: string;
messages: AnthropicMessageParam[];
} {
export function _formatMessagesForAnthropic(
messages: BaseMessage[]
): AnthropicMessageCreateParams {
const mergedMessages = _mergeMessages(messages);
let system: string | undefined;
let system;
if (mergedMessages.length > 0 && mergedMessages[0]._getType() === "system") {
if (typeof messages[0].content !== "string") {
throw new Error("System message content must be a string.");
}
system = messages[0].content;
}
const conversationMessages =
Expand Down Expand Up @@ -256,5 +255,5 @@ export function _formatMessagesForAnthropic(messages: BaseMessage[]): {
return {
messages: formattedMessages,
system,
};
} as AnthropicMessageCreateParams;
}
11 changes: 5 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,9 @@ __metadata:
languageName: node
linkType: hard

"@anthropic-ai/sdk@npm:^0.22.0":
version: 0.22.0
resolution: "@anthropic-ai/sdk@npm:0.22.0"
"@anthropic-ai/sdk@npm:^0.25.2":
version: 0.25.2
resolution: "@anthropic-ai/sdk@npm:0.25.2"
dependencies:
"@types/node": ^18.11.18
"@types/node-fetch": ^2.6.4
Expand All @@ -222,8 +222,7 @@ __metadata:
form-data-encoder: 1.7.2
formdata-node: ^4.3.2
node-fetch: ^2.6.7
web-streams-polyfill: ^3.2.1
checksum: f09fc6ea1f5f68483fd2dbdc1ab78a0914d7a3f39fd4a921f5a04b8959ae82aa210372fa2dbff2ee78143d37fb408e7b7d61e0023e7ea31d5fa1f4873f371af8
checksum: b38f6a43f6f678e49f1b53226cc55654c23cf0fd1902cf3fcf98c0ae78f4c229518964f4cb31bc39da41925c806e7f4cc7ec14c511d387f07db3136b111bc744
languageName: node
linkType: hard

Expand Down Expand Up @@ -10852,7 +10851,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@langchain/anthropic@workspace:libs/langchain-anthropic"
dependencies:
"@anthropic-ai/sdk": ^0.22.0
"@anthropic-ai/sdk": ^0.25.2
"@jest/globals": ^29.5.0
"@langchain/core": ">=0.2.21 <0.3.0"
"@langchain/scripts": ~0.0.20
Expand Down
Loading