@langchain/anthropic 1.0.0-alpha.1 → 1.0.0-alpha.2
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.
- package/dist/chat_models.cjs +23 -14
- package/dist/chat_models.cjs.map +1 -1
- package/dist/chat_models.d.cts +12 -7
- package/dist/chat_models.d.cts.map +1 -1
- package/dist/chat_models.d.ts +12 -7
- package/dist/chat_models.d.ts.map +1 -1
- package/dist/chat_models.js +23 -14
- package/dist/chat_models.js.map +1 -1
- package/dist/types.d.cts +5 -4
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.ts +5 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/content.cjs +2 -4
- package/dist/utils/content.cjs.map +1 -1
- package/dist/utils/content.js +2 -4
- package/dist/utils/content.js.map +1 -1
- package/dist/utils/message_inputs.cjs +11 -6
- package/dist/utils/message_inputs.cjs.map +1 -1
- package/dist/utils/message_inputs.js +11 -6
- package/dist/utils/message_inputs.js.map +1 -1
- package/dist/utils/message_outputs.cjs +2 -1
- package/dist/utils/message_outputs.cjs.map +1 -1
- package/dist/utils/message_outputs.js +2 -1
- package/dist/utils/message_outputs.js.map +1 -1
- package/dist/utils/standard.cjs +189 -31
- package/dist/utils/standard.cjs.map +1 -1
- package/dist/utils/standard.js +189 -31
- package/dist/utils/standard.js.map +1 -1
- package/dist/utils/tools.cjs +1 -0
- package/dist/utils/tools.cjs.map +1 -1
- package/dist/utils/tools.js +1 -0
- package/dist/utils/tools.js.map +1 -1
- package/package.json +28 -31
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standard.js","names":["annotation: unknown","annotations: ContentBlock.Citation[]","message: BaseMessage","result: Anthropic.Beta.BetaContentBlockParam[]","fileId: string"],"sources":["../../src/utils/standard.ts"],"sourcesContent":["import type Anthropic from \"@anthropic-ai/sdk\";\nimport type { BaseMessage, ContentBlock } from \"@langchain/core/messages\";\nimport { iife } from \"./index.js\";\n\nfunction _isStandardAnnotation(\n annotation: unknown\n): annotation is ContentBlock.Citation {\n return (\n typeof annotation === \"object\" &&\n annotation !== null &&\n \"type\" in annotation &&\n annotation.type === \"citation\"\n );\n}\n\nfunction _formatStandardCitations(\n annotations: ContentBlock.Citation[]\n): Anthropic.Beta.BetaTextCitation[] {\n function* iterateAnnotations() {\n for (const annotation of annotations) {\n if (_isStandardAnnotation(annotation)) {\n if (annotation.source === \"char\") {\n yield {\n type: \"char_location\",\n start_char_index: annotation.startIndex ?? 0,\n end_char_index: annotation.endIndex ?? 0,\n document_title: annotation.title ?? null,\n document_index: 0,\n cited_text: annotation.citedText ?? \"\",\n };\n } else if (annotation.source === \"page\") {\n yield {\n type: \"page_location\",\n start_page_number: annotation.startIndex ?? 0,\n end_page_number: annotation.endIndex ?? 0,\n document_title: annotation.title ?? null,\n document_index: 0,\n cited_text: annotation.citedText ?? \"\",\n };\n } else if (annotation.source === \"block\") {\n yield {\n type: \"content_block_location\",\n start_block_index: annotation.startIndex ?? 0,\n end_block_index: annotation.endIndex ?? 0,\n document_title: annotation.title ?? null,\n document_index: 0,\n cited_text: annotation.citedText ?? \"\",\n };\n } else if (annotation.source === \"url\") {\n yield {\n type: \"web_search_result_location\",\n url: annotation.url ?? \"\",\n title: annotation.title ?? null,\n encrypted_index: String(annotation.startIndex ?? 0),\n cited_text: annotation.citedText ?? \"\",\n };\n } else if (annotation.source === \"search\") {\n yield {\n type: \"search_result_location\",\n title: annotation.title ?? null,\n start_block_index: annotation.startIndex ?? 0,\n end_block_index: annotation.endIndex ?? 0,\n search_result_index: 0,\n source: annotation.source ?? \"\",\n cited_text: annotation.citedText ?? \"\",\n };\n }\n }\n }\n }\n return Array.from(iterateAnnotations());\n}\n\nexport function _formatStandardContent(\n message: BaseMessage\n): Anthropic.Beta.BetaContentBlockParam[] {\n const result: Anthropic.Beta.BetaContentBlockParam[] = [];\n const modelProvider = message.response_metadata?.model_provider;\n for (const block of message.contentBlocks) {\n if (block.type === \"text\") {\n if (block.annotations) {\n result.push({\n type: \"text\",\n text: block.text,\n citations: _formatStandardCitations(\n block.annotations as ContentBlock.Citation[]\n ),\n });\n } else {\n result.push({\n type: \"text\",\n text: block.text,\n });\n }\n } else if (block.type === \"tool_call\") {\n result.push({\n type: \"tool_use\",\n id: block.id ?? \"\",\n name: block.name,\n input: block.args,\n });\n } else if (block.type === \"tool_call_chunk\") {\n const input = iife(() => {\n if (typeof block.args !== \"string\") {\n return block.args;\n }\n try {\n return JSON.parse(block.args);\n } catch {\n return {};\n }\n });\n result.push({\n type: \"tool_use\",\n id: block.id ?? \"\",\n name: block.name ?? \"\",\n input,\n });\n } else if (block.type === \"reasoning\" && modelProvider === \"anthropic\") {\n result.push({\n type: \"thinking\",\n thinking: block.reasoning,\n signature: String(block.signature),\n });\n } else if (\n block.type === \"web_search_call\" &&\n modelProvider === \"anthropic\"\n ) {\n result.push({\n id: block.id ?? \"\",\n type: \"server_tool_use\",\n name: \"web_search\",\n input: block.input ?? { query: block.query },\n });\n } else if (\n block.type === \"web_search_result\" &&\n modelProvider === \"anthropic\"\n ) {\n result.push({\n id: block.id,\n type: \"web_search_tool_result\",\n content: block.content,\n });\n } else if (\n block.type === \"code_interpreter_call\" &&\n modelProvider === \"anthropic\"\n ) {\n result.push({\n type: \"server_tool_use\",\n name: \"code_execution\",\n id: block.id,\n input: { code: block.code },\n });\n } else if (\n block.type === \"code_interpreter_result\" &&\n modelProvider === \"anthropic\" &&\n Array.isArray(block.fileIds)\n ) {\n result.push({\n type: \"code_execution_tool_result\",\n content: {\n type: \"code_execution_result\",\n stderr: block.stderr as string,\n stdout: block.stdout as string,\n return_code: block.returnCode as number,\n fileIds: block.fileIds.map((fileId: string) => ({\n type: \"code_execution_output\",\n file_id: fileId,\n })),\n },\n });\n }\n }\n return result;\n}\n"],"mappings":";;;AAIA,SAAS,sBACPA,YACqC;AACrC,QACE,OAAO,eAAe,YACtB,eAAe,QACf,UAAU,cACV,WAAW,SAAS;AAEvB;AAED,SAAS,yBACP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AAS;GACV,GAAE;EACJ;CACF,EAAC;AAGN,QAAO;AACR"}
|
|
1
|
+
{"version":3,"file":"standard.js","names":["annotation: unknown","annotations: ContentBlock.Citation[]","data: string | Uint8Array","data: Uint8Array","mimeType?: string | null","metadata: unknown","key: string","block: Anthropic.Beta.BetaRequestDocumentBlock","block: Anthropic.Beta.BetaImageBlockParam","mimeType: string","message: BaseMessage","result: Anthropic.Beta.BetaContentBlockParam[]"],"sources":["../../src/utils/standard.ts"],"sourcesContent":["import type Anthropic from \"@anthropic-ai/sdk\";\nimport type {\n BaseMessage,\n ContentBlock,\n ResponseMetadata,\n} from \"@langchain/core/messages\";\nimport { iife } from \"./index.js\";\n\nfunction _isStandardAnnotation(\n annotation: unknown\n): annotation is ContentBlock.Citation {\n return (\n typeof annotation === \"object\" &&\n annotation !== null &&\n \"type\" in annotation &&\n annotation.type === \"citation\"\n );\n}\n\nfunction _formatStandardCitations(\n annotations: ContentBlock.Citation[]\n): Anthropic.Beta.BetaTextCitation[] {\n function* iterateAnnotations() {\n for (const annotation of annotations) {\n if (_isStandardAnnotation(annotation)) {\n if (annotation.source === \"char\") {\n yield {\n type: \"char_location\" as const,\n file_id: annotation.url ?? \"\",\n start_char_index: annotation.startIndex ?? 0,\n end_char_index: annotation.endIndex ?? 0,\n document_title: annotation.title ?? null,\n document_index: 0,\n cited_text: annotation.citedText ?? \"\",\n };\n } else if (annotation.source === \"page\") {\n yield {\n type: \"page_location\" as const,\n file_id: annotation.url ?? \"\",\n start_page_number: annotation.startIndex ?? 0,\n end_page_number: annotation.endIndex ?? 0,\n document_title: annotation.title ?? null,\n document_index: 0,\n cited_text: annotation.citedText ?? \"\",\n };\n } else if (annotation.source === \"block\") {\n yield {\n type: \"content_block_location\" as const,\n file_id: annotation.url ?? \"\",\n start_block_index: annotation.startIndex ?? 0,\n end_block_index: annotation.endIndex ?? 0,\n document_title: annotation.title ?? null,\n document_index: 0,\n cited_text: annotation.citedText ?? \"\",\n };\n } else if (annotation.source === \"url\") {\n yield {\n type: \"web_search_result_location\" as const,\n url: annotation.url ?? \"\",\n title: annotation.title ?? null,\n encrypted_index: String(annotation.startIndex ?? 0),\n cited_text: annotation.citedText ?? \"\",\n };\n } else if (annotation.source === \"search\") {\n yield {\n type: \"search_result_location\" as const,\n title: annotation.title ?? null,\n start_block_index: annotation.startIndex ?? 0,\n end_block_index: annotation.endIndex ?? 0,\n search_result_index: 0,\n source: annotation.source ?? \"\",\n cited_text: annotation.citedText ?? \"\",\n };\n }\n }\n }\n }\n return Array.from(iterateAnnotations());\n}\n\nfunction _formatBase64Data(data: string | Uint8Array): string {\n if (typeof data === \"string\") return data;\n else return _encodeUint8Array(data);\n}\n\nfunction _encodeUint8Array(data: Uint8Array): string {\n const output = [];\n for (let i = 0, { length } = data; i < length; i++) {\n output.push(String.fromCharCode(data[i]));\n }\n return btoa(output.join(\"\"));\n}\n\nfunction _normalizeMimeType(mimeType?: string | null): string {\n return (mimeType ?? \"\").split(\";\")[0].toLowerCase();\n}\n\nfunction _extractMetadataValue<T>(\n metadata: unknown,\n key: string\n): T | undefined {\n if (\n metadata !== undefined &&\n metadata !== null &&\n typeof metadata === \"object\" &&\n key in metadata\n ) {\n return (metadata as Record<string, unknown>)[key] as T;\n }\n return undefined;\n}\n\nfunction _applyDocumentMetadata(\n block: Anthropic.Beta.BetaRequestDocumentBlock,\n metadata: unknown\n): Anthropic.Beta.BetaRequestDocumentBlock {\n const cacheControl =\n _extractMetadataValue<Anthropic.Beta.BetaCacheControlEphemeral | null>(\n metadata,\n \"cache_control\"\n );\n if (cacheControl !== undefined) {\n block.cache_control = cacheControl;\n }\n const citations =\n _extractMetadataValue<Anthropic.Beta.BetaCitationsConfigParam | null>(\n metadata,\n \"citations\"\n );\n if (citations !== undefined) {\n block.citations = citations;\n }\n const context = _extractMetadataValue<string | null>(metadata, \"context\");\n if (context !== undefined) {\n block.context = context;\n }\n const title = _extractMetadataValue<string | null>(metadata, \"title\");\n if (title !== undefined) {\n block.title = title;\n }\n return block;\n}\n\nfunction _applyImageMetadata(\n block: Anthropic.Beta.BetaImageBlockParam,\n metadata: unknown\n): Anthropic.Beta.BetaImageBlockParam {\n const cacheControl =\n _extractMetadataValue<Anthropic.Beta.BetaCacheControlEphemeral | null>(\n metadata,\n \"cache_control\"\n );\n if (cacheControl !== undefined) {\n block.cache_control = cacheControl;\n }\n return block;\n}\n\nfunction _hasAllowedImageMimeType(\n mimeType: string\n): mimeType is \"image/jpeg\" | \"image/png\" | \"image/gif\" | \"image/webp\" {\n const ALLOWED_IMAGE_MIME_TYPES = new Set([\n \"image/jpeg\",\n \"image/png\",\n \"image/gif\",\n \"image/webp\",\n ]);\n return ALLOWED_IMAGE_MIME_TYPES.has(mimeType);\n}\n\nexport function _formatStandardContent(\n message: BaseMessage\n): Anthropic.Beta.BetaContentBlockParam[] {\n const result: Anthropic.Beta.BetaContentBlockParam[] = [];\n const responseMetadata = message.response_metadata as ResponseMetadata;\n const isAnthropicMessage =\n \"model_provider\" in responseMetadata &&\n responseMetadata?.model_provider === \"anthropic\";\n for (const block of message.contentBlocks) {\n if (block.type === \"text\") {\n if (block.annotations) {\n result.push({\n type: \"text\",\n text: block.text,\n citations: _formatStandardCitations(\n block.annotations as ContentBlock.Citation[]\n ),\n });\n } else {\n result.push({\n type: \"text\",\n text: block.text,\n });\n }\n } else if (block.type === \"tool_call\") {\n result.push({\n type: \"tool_use\",\n id: block.id ?? \"\",\n name: block.name,\n input: block.args,\n });\n } else if (block.type === \"tool_call_chunk\") {\n const input = iife(() => {\n if (typeof block.args !== \"string\") {\n return block.args;\n }\n try {\n return JSON.parse(block.args);\n } catch {\n return {};\n }\n });\n result.push({\n type: \"tool_use\",\n id: block.id ?? \"\",\n name: block.name ?? \"\",\n input,\n });\n } else if (block.type === \"reasoning\" && isAnthropicMessage) {\n result.push({\n type: \"thinking\",\n thinking: block.reasoning,\n signature: String(block.signature),\n });\n } else if (block.type === \"server_tool_call\" && isAnthropicMessage) {\n if (block.name === \"web_search\") {\n result.push({\n type: \"server_tool_use\",\n name: block.name,\n id: block.id ?? \"\",\n input: block.args,\n });\n } else if (block.name === \"code_execution\") {\n result.push({\n type: \"server_tool_use\",\n name: block.name,\n id: block.id ?? \"\",\n input: block.args,\n });\n }\n } else if (block.type === \"server_tool_call_result\" && isAnthropicMessage) {\n if (block.name === \"web_search\" && Array.isArray(block.output.urls)) {\n const content = block.output.urls.map((url) => ({\n type: \"web_search_result\" as const,\n title: \"\",\n encrypted_content: \"\",\n url,\n }));\n result.push({\n type: \"web_search_tool_result\",\n tool_use_id: block.toolCallId ?? \"\",\n content,\n });\n } else if (block.name === \"code_execution\") {\n result.push({\n type: \"code_execution_tool_result\",\n tool_use_id: block.toolCallId ?? \"\",\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n content: block.output as any,\n });\n } else if (block.name === \"mcp_tool_result\") {\n result.push({\n type: \"mcp_tool_result\",\n tool_use_id: block.toolCallId ?? \"\",\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n content: block.output as any,\n });\n }\n } else if (block.type === \"audio\") {\n throw new Error(\"Anthropic does not support audio content blocks.\");\n } else if (block.type === \"file\") {\n const metadata = block.metadata;\n if (block.fileId) {\n result.push(\n _applyDocumentMetadata(\n {\n type: \"document\",\n source: {\n type: \"file\",\n file_id: block.fileId,\n },\n },\n metadata\n )\n );\n continue;\n }\n if (block.url) {\n const mimeType = _normalizeMimeType(block.mimeType);\n if (mimeType === \"application/pdf\" || mimeType === \"\") {\n result.push(\n _applyDocumentMetadata(\n {\n type: \"document\",\n source: {\n type: \"url\",\n url: block.url,\n },\n },\n metadata\n )\n );\n continue;\n }\n }\n if (block.data) {\n const mimeType = _normalizeMimeType(block.mimeType);\n if (mimeType === \"\" || mimeType === \"application/pdf\") {\n result.push(\n _applyDocumentMetadata(\n {\n type: \"document\",\n source: {\n type: \"base64\",\n data: _formatBase64Data(block.data),\n media_type: \"application/pdf\",\n },\n },\n metadata\n )\n );\n } else if (mimeType === \"text/plain\") {\n result.push(\n _applyDocumentMetadata(\n {\n type: \"document\",\n source: {\n type: \"text\",\n data: _formatBase64Data(block.data),\n media_type: \"text/plain\",\n },\n },\n metadata\n )\n );\n } else {\n if (_hasAllowedImageMimeType(mimeType)) {\n result.push(\n _applyDocumentMetadata(\n {\n type: \"document\",\n source: {\n type: \"content\",\n content: [\n {\n type: \"image\",\n source: {\n type: \"base64\",\n data: _formatBase64Data(block.data),\n media_type: mimeType,\n },\n },\n ],\n },\n },\n metadata\n )\n );\n } else {\n throw new Error(\n `Unsupported file mime type for Anthropic base64 source: ${mimeType}`\n );\n }\n }\n continue;\n }\n throw new Error(\n \"File content block must include a fileId, url, or data property.\"\n );\n } else if (block.type === \"image\") {\n const metadata = block.metadata;\n if (block.fileId) {\n result.push(\n _applyImageMetadata(\n {\n type: \"image\",\n source: {\n type: \"file\",\n file_id: block.fileId,\n },\n },\n metadata\n )\n );\n continue;\n }\n if (block.url) {\n result.push(\n _applyImageMetadata(\n {\n type: \"image\",\n source: {\n type: \"url\",\n url: block.url,\n },\n },\n metadata\n )\n );\n continue;\n }\n if (block.data) {\n const mimeType = _normalizeMimeType(block.mimeType) || \"image/png\";\n if (_hasAllowedImageMimeType(mimeType)) {\n result.push(\n _applyImageMetadata(\n {\n type: \"image\",\n source: {\n type: \"base64\",\n data: _formatBase64Data(block.data),\n media_type: mimeType,\n },\n },\n metadata\n )\n );\n }\n continue;\n }\n throw new Error(\n \"Image content block must include a fileId, url, or data property.\"\n );\n } else if (block.type === \"video\") {\n // no-op\n } else if (block.type === \"text-plain\") {\n if (block.data) {\n result.push(\n _applyDocumentMetadata(\n {\n type: \"document\",\n source: {\n type: \"text\",\n data: _formatBase64Data(block.data),\n media_type: \"text/plain\",\n },\n },\n block.metadata\n )\n );\n }\n } else if (block.type === \"non_standard\" && isAnthropicMessage) {\n result.push(block.value as Anthropic.Beta.BetaContentBlockParam);\n }\n }\n return result;\n}\n"],"mappings":";;;AAQA,SAAS,sBACPA,YACqC;AACrC,QACE,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UAAU;AAI3E;EACD;AACD,QAAM,IAAI,MACR;CAEH,WAAU,MAAM,SAAS,SAAS;EACjC,MAAM,WAAW,MAAM;AACvB,MAAI,MAAM,QAAQ;GAChB,OAAO,KACL,oBACE;IACE,MAAM;IACN,QAAQ;KACN,MAAM;KACN,SAAS,MAAM;IAChB;GACF,GACD,SACD,CACF;AACD;EACD;AACD,MAAI,MAAM,KAAK;GACb,OAAO,KACL,oBACE;IACE,MAAM;IACN,QAAQ;KACN,MAAM;KACN,KAAK,MAAM;IACZ;GACF,GACD,SACD,CACF;AACD;EACD;AACD,MAAI,MAAM,MAAM;GACd,MAAM,WAAW,mBAAmB,MAAM,SAAS,IAAI;AACvD,OAAI,yBAAyB,SAAS,EACpC,OAAO,KACL,oBACE;IACE,MAAM;IACN,QAAQ;KACN,MAAM;KACN,MAAM,kBAAkB,MAAM,KAAK;KACnC,YAAY;IACb;GACF,GACD,SACD,CACF;AAEH;EACD;AACD,QAAM,IAAI,MACR;CAEH,WAAU,MAAM,SAAS,SAAS,CAElC,WAAU,MAAM,SAAS,cACxB;MAAI,MAAM,MACR,OAAO,KACL,uBACE;GACE,MAAM;GACN,QAAQ;IACN,MAAM;IACN,MAAM,kBAAkB,MAAM,KAAK;IACnC,YAAY;GACb;EACF,GACD,MAAM,SACP,CACF;CACF,WACQ,MAAM,SAAS,kBAAkB,oBAC1C,OAAO,KAAK,MAAM,MAA8C;AAGpE,QAAO;AACR"}
|
package/dist/utils/tools.cjs
CHANGED
|
@@ -4,6 +4,7 @@ function handleToolChoice(toolChoice) {
|
|
|
4
4
|
if (!toolChoice) return void 0;
|
|
5
5
|
else if (toolChoice === "any") return { type: "any" };
|
|
6
6
|
else if (toolChoice === "auto") return { type: "auto" };
|
|
7
|
+
else if (toolChoice === "none") return { type: "none" };
|
|
7
8
|
else if (typeof toolChoice === "string") return {
|
|
8
9
|
type: "tool",
|
|
9
10
|
name: toolChoice
|
package/dist/utils/tools.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.cjs","names":["toolChoice?: AnthropicToolChoice"],"sources":["../../src/utils/tools.ts"],"sourcesContent":["import type { Anthropic } from \"@anthropic-ai/sdk\";\nimport { AnthropicToolChoice } from \"../types.js\";\n\nexport function handleToolChoice(\n toolChoice?: AnthropicToolChoice\n):\n | Anthropic.Messages.ToolChoiceAuto\n | Anthropic.Messages.ToolChoiceAny\n | Anthropic.Messages.ToolChoiceTool\n | undefined {\n if (!toolChoice) {\n return undefined;\n } else if (toolChoice === \"any\") {\n return {\n type: \"any\",\n };\n } else if (toolChoice === \"auto\") {\n return {\n type: \"auto\",\n };\n } else if (typeof toolChoice === \"string\") {\n return {\n type: \"tool\",\n name: toolChoice,\n };\n } else {\n return toolChoice;\n }\n}\n"],"mappings":";;AAGA,SAAgB,iBACdA,
|
|
1
|
+
{"version":3,"file":"tools.cjs","names":["toolChoice?: AnthropicToolChoice"],"sources":["../../src/utils/tools.ts"],"sourcesContent":["import type { Anthropic } from \"@anthropic-ai/sdk\";\nimport { AnthropicToolChoice } from \"../types.js\";\n\nexport function handleToolChoice(\n toolChoice?: AnthropicToolChoice\n):\n | Anthropic.Messages.ToolChoiceAuto\n | Anthropic.Messages.ToolChoiceAny\n | Anthropic.Messages.ToolChoiceTool\n | Anthropic.Messages.ToolChoiceNone\n | undefined {\n if (!toolChoice) {\n return undefined;\n } else if (toolChoice === \"any\") {\n return {\n type: \"any\",\n };\n } else if (toolChoice === \"auto\") {\n return {\n type: \"auto\",\n };\n } else if (toolChoice === \"none\") {\n return {\n type: \"none\",\n };\n } else if (typeof toolChoice === \"string\") {\n return {\n type: \"tool\",\n name: toolChoice,\n };\n } else {\n return toolChoice;\n }\n}\n"],"mappings":";;AAGA,SAAgB,iBACdA,YAMY;AACZ,KAAI,CAAC,WACH,QAAO;UACE,eAAe,MACxB,QAAO,EACL,MAAM,MACP;UACQ,eAAe,OACxB,QAAO,EACL,MAAM,OACP;UACQ,eAAe,OACxB,QAAO,EACL,MAAM,OACP;UACQ,OAAO,eAAe,SAC/B,QAAO;EACL,MAAM;EACN,MAAM;CACP;KAED,QAAO;AAEV"}
|
package/dist/utils/tools.js
CHANGED
|
@@ -3,6 +3,7 @@ function handleToolChoice(toolChoice) {
|
|
|
3
3
|
if (!toolChoice) return void 0;
|
|
4
4
|
else if (toolChoice === "any") return { type: "any" };
|
|
5
5
|
else if (toolChoice === "auto") return { type: "auto" };
|
|
6
|
+
else if (toolChoice === "none") return { type: "none" };
|
|
6
7
|
else if (typeof toolChoice === "string") return {
|
|
7
8
|
type: "tool",
|
|
8
9
|
name: toolChoice
|
package/dist/utils/tools.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","names":["toolChoice?: AnthropicToolChoice"],"sources":["../../src/utils/tools.ts"],"sourcesContent":["import type { Anthropic } from \"@anthropic-ai/sdk\";\nimport { AnthropicToolChoice } from \"../types.js\";\n\nexport function handleToolChoice(\n toolChoice?: AnthropicToolChoice\n):\n | Anthropic.Messages.ToolChoiceAuto\n | Anthropic.Messages.ToolChoiceAny\n | Anthropic.Messages.ToolChoiceTool\n | undefined {\n if (!toolChoice) {\n return undefined;\n } else if (toolChoice === \"any\") {\n return {\n type: \"any\",\n };\n } else if (toolChoice === \"auto\") {\n return {\n type: \"auto\",\n };\n } else if (typeof toolChoice === \"string\") {\n return {\n type: \"tool\",\n name: toolChoice,\n };\n } else {\n return toolChoice;\n }\n}\n"],"mappings":";AAGA,SAAgB,iBACdA,
|
|
1
|
+
{"version":3,"file":"tools.js","names":["toolChoice?: AnthropicToolChoice"],"sources":["../../src/utils/tools.ts"],"sourcesContent":["import type { Anthropic } from \"@anthropic-ai/sdk\";\nimport { AnthropicToolChoice } from \"../types.js\";\n\nexport function handleToolChoice(\n toolChoice?: AnthropicToolChoice\n):\n | Anthropic.Messages.ToolChoiceAuto\n | Anthropic.Messages.ToolChoiceAny\n | Anthropic.Messages.ToolChoiceTool\n | Anthropic.Messages.ToolChoiceNone\n | undefined {\n if (!toolChoice) {\n return undefined;\n } else if (toolChoice === \"any\") {\n return {\n type: \"any\",\n };\n } else if (toolChoice === \"auto\") {\n return {\n type: \"auto\",\n };\n } else if (toolChoice === \"none\") {\n return {\n type: \"none\",\n };\n } else if (typeof toolChoice === \"string\") {\n return {\n type: \"tool\",\n name: toolChoice,\n };\n } else {\n return toolChoice;\n }\n}\n"],"mappings":";AAGA,SAAgB,iBACdA,YAMY;AACZ,KAAI,CAAC,WACH,QAAO;UACE,eAAe,MACxB,QAAO,EACL,MAAM,MACP;UACQ,eAAe,OACxB,QAAO,EACL,MAAM,OACP;UACQ,eAAe,OACxB,QAAO,EACL,MAAM,OACP;UACQ,OAAO,eAAe,SAC/B,QAAO;EACL,MAAM;EACN,MAAM;CACP;KAED,QAAO;AAEV"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langchain/anthropic",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.2",
|
|
4
4
|
"description": "Anthropic integrations for LangChain.js",
|
|
5
5
|
"author": "LangChain",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,48 +13,29 @@
|
|
|
13
13
|
"url": "git@github.com:langchain-ai/langchainjs.git"
|
|
14
14
|
},
|
|
15
15
|
"homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-anthropic/",
|
|
16
|
-
"scripts": {
|
|
17
|
-
"build": "pnpm --filter @langchain/build compile @langchain/anthropic",
|
|
18
|
-
"lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/",
|
|
19
|
-
"lint:dpdm": "dpdm --skip-dynamic-imports circular --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts",
|
|
20
|
-
"lint": "pnpm lint:eslint && pnpm lint:dpdm",
|
|
21
|
-
"lint:fix": "pnpm lint:eslint --fix && pnpm lint:dpdm",
|
|
22
|
-
"clean": "rm -rf .turbo dist/",
|
|
23
|
-
"test": "vitest run",
|
|
24
|
-
"test:watch": "vitest",
|
|
25
|
-
"test:int": "vitest run --mode int",
|
|
26
|
-
"test:standard:unit": "vitest run --mode standard-unit",
|
|
27
|
-
"test:standard:int": "vitest run --mode standard-int",
|
|
28
|
-
"test:standard": "pnpm test:standard:unit && pnpm test:standard:int",
|
|
29
|
-
"format": "prettier --config .prettierrc --write \"src\"",
|
|
30
|
-
"format:check": "prettier --config .prettierrc --check \"src\""
|
|
31
|
-
},
|
|
32
16
|
"dependencies": {
|
|
33
|
-
"@anthropic-ai/sdk": "^0.
|
|
17
|
+
"@anthropic-ai/sdk": "^0.65.0"
|
|
34
18
|
},
|
|
35
19
|
"peerDependencies": {
|
|
36
|
-
"@langchain/core": "
|
|
20
|
+
"@langchain/core": "^1.0.0-alpha.6"
|
|
37
21
|
},
|
|
38
22
|
"devDependencies": {
|
|
39
23
|
"@anthropic-ai/vertex-sdk": "^0.11.5",
|
|
40
|
-
"@langchain/core": "workspace:*",
|
|
41
|
-
"@langchain/standard-tests": "workspace:*",
|
|
42
24
|
"@tsconfig/recommended": "^1.0.10",
|
|
43
25
|
"@vitest/coverage-v8": "^3.2.4",
|
|
44
26
|
"dotenv": "^17.2.1",
|
|
45
27
|
"dpdm": "^3.14.0",
|
|
46
|
-
"eslint": "^
|
|
47
|
-
"eslint-config-airbnb-base": "^15.0.0",
|
|
48
|
-
"eslint-config-prettier": "^8.6.0",
|
|
49
|
-
"eslint-plugin-import": "^2.27.5",
|
|
50
|
-
"eslint-plugin-no-instanceof": "^1.0.1",
|
|
51
|
-
"eslint-plugin-prettier": "^4.2.1",
|
|
28
|
+
"eslint": "^9.34.0",
|
|
52
29
|
"prettier": "^2.8.3",
|
|
53
|
-
"release-it": "^
|
|
30
|
+
"release-it": "^19.0.4",
|
|
31
|
+
"release-it-pnpm": "^4.6.6",
|
|
54
32
|
"rimraf": "^5.0.1",
|
|
55
33
|
"typescript": "~5.8.3",
|
|
56
34
|
"vitest": "^3.2.4",
|
|
57
|
-
"zod": "
|
|
35
|
+
"zod": "3.25.76",
|
|
36
|
+
"@langchain/standard-tests": "0.0.0",
|
|
37
|
+
"@langchain/eslint": "0.1.0",
|
|
38
|
+
"@langchain/core": "1.0.0-alpha.6"
|
|
58
39
|
},
|
|
59
40
|
"publishConfig": {
|
|
60
41
|
"access": "public"
|
|
@@ -91,5 +72,21 @@
|
|
|
91
72
|
},
|
|
92
73
|
"files": [
|
|
93
74
|
"dist/"
|
|
94
|
-
]
|
|
95
|
-
|
|
75
|
+
],
|
|
76
|
+
"scripts": {
|
|
77
|
+
"build": "pnpm --filter @langchain/build compile @langchain/anthropic",
|
|
78
|
+
"lint:eslint": "eslint --cache src/",
|
|
79
|
+
"lint:dpdm": "dpdm --skip-dynamic-imports circular --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts",
|
|
80
|
+
"lint": "pnpm lint:eslint && pnpm lint:dpdm",
|
|
81
|
+
"lint:fix": "pnpm lint:eslint --fix && pnpm lint:dpdm",
|
|
82
|
+
"clean": "rm -rf .turbo dist/",
|
|
83
|
+
"test": "vitest run",
|
|
84
|
+
"test:watch": "vitest",
|
|
85
|
+
"test:int": "vitest run --mode int",
|
|
86
|
+
"test:standard:unit": "vitest run --mode standard-unit",
|
|
87
|
+
"test:standard:int": "vitest run --mode standard-int",
|
|
88
|
+
"test:standard": "pnpm test:standard:unit && pnpm test:standard:int",
|
|
89
|
+
"format": "prettier --config .prettierrc --write \"src\"",
|
|
90
|
+
"format:check": "prettier --config .prettierrc --check \"src\""
|
|
91
|
+
}
|
|
92
|
+
}
|