@langchain/anthropic 0.3.25 → 1.0.0-alpha.1

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.
Files changed (101) hide show
  1. package/README.md +8 -8
  2. package/dist/_virtual/rolldown_runtime.cjs +25 -0
  3. package/dist/chat_models.cjs +772 -989
  4. package/dist/chat_models.cjs.map +1 -0
  5. package/dist/chat_models.d.cts +615 -0
  6. package/dist/chat_models.d.cts.map +1 -0
  7. package/dist/chat_models.d.ts +222 -199
  8. package/dist/chat_models.d.ts.map +1 -0
  9. package/dist/chat_models.js +766 -980
  10. package/dist/chat_models.js.map +1 -0
  11. package/dist/index.cjs +6 -20
  12. package/dist/index.d.cts +4 -0
  13. package/dist/index.d.ts +4 -3
  14. package/dist/index.js +4 -2
  15. package/dist/output_parsers.cjs +65 -104
  16. package/dist/output_parsers.cjs.map +1 -0
  17. package/dist/output_parsers.js +64 -100
  18. package/dist/output_parsers.js.map +1 -0
  19. package/dist/types.d.cts +32 -0
  20. package/dist/types.d.cts.map +1 -0
  21. package/dist/types.d.ts +29 -31
  22. package/dist/types.d.ts.map +1 -0
  23. package/dist/utils/content.cjs +153 -0
  24. package/dist/utils/content.cjs.map +1 -0
  25. package/dist/utils/content.js +148 -0
  26. package/dist/utils/content.js.map +1 -0
  27. package/dist/utils/errors.cjs +16 -27
  28. package/dist/utils/errors.cjs.map +1 -0
  29. package/dist/utils/errors.js +17 -25
  30. package/dist/utils/errors.js.map +1 -0
  31. package/dist/utils/index.cjs +7 -0
  32. package/dist/utils/index.cjs.map +1 -0
  33. package/dist/utils/index.js +6 -0
  34. package/dist/utils/index.js.map +1 -0
  35. package/dist/utils/message_inputs.cjs +218 -535
  36. package/dist/utils/message_inputs.cjs.map +1 -0
  37. package/dist/utils/message_inputs.js +219 -533
  38. package/dist/utils/message_inputs.js.map +1 -0
  39. package/dist/utils/message_outputs.cjs +185 -246
  40. package/dist/utils/message_outputs.cjs.map +1 -0
  41. package/dist/utils/message_outputs.js +184 -243
  42. package/dist/utils/message_outputs.js.map +1 -0
  43. package/dist/utils/prompts.cjs +46 -45
  44. package/dist/utils/prompts.cjs.map +1 -0
  45. package/dist/utils/prompts.d.cts +45 -0
  46. package/dist/utils/prompts.d.cts.map +1 -0
  47. package/dist/utils/prompts.d.ts +8 -2
  48. package/dist/utils/prompts.d.ts.map +1 -0
  49. package/dist/utils/prompts.js +46 -42
  50. package/dist/utils/prompts.js.map +1 -0
  51. package/dist/utils/standard.cjs +127 -0
  52. package/dist/utils/standard.cjs.map +1 -0
  53. package/dist/utils/standard.js +127 -0
  54. package/dist/utils/standard.js.map +1 -0
  55. package/dist/utils/tools.cjs +14 -25
  56. package/dist/utils/tools.cjs.map +1 -0
  57. package/dist/utils/tools.js +14 -23
  58. package/dist/utils/tools.js.map +1 -0
  59. package/package.json +30 -53
  60. package/dist/experimental/index.cjs +0 -17
  61. package/dist/experimental/index.d.ts +0 -1
  62. package/dist/experimental/index.js +0 -1
  63. package/dist/experimental/tool_calling.cjs +0 -318
  64. package/dist/experimental/tool_calling.d.ts +0 -57
  65. package/dist/experimental/tool_calling.js +0 -314
  66. package/dist/experimental/utils/tool_calling.cjs +0 -106
  67. package/dist/experimental/utils/tool_calling.d.ts +0 -10
  68. package/dist/experimental/utils/tool_calling.js +0 -101
  69. package/dist/load/import_constants.cjs +0 -5
  70. package/dist/load/import_constants.d.ts +0 -1
  71. package/dist/load/import_constants.js +0 -2
  72. package/dist/load/import_map.cjs +0 -39
  73. package/dist/load/import_map.d.ts +0 -2
  74. package/dist/load/import_map.js +0 -3
  75. package/dist/load/import_type.cjs +0 -3
  76. package/dist/load/import_type.d.ts +0 -5
  77. package/dist/load/import_type.js +0 -2
  78. package/dist/load/index.cjs +0 -63
  79. package/dist/load/index.d.ts +0 -14
  80. package/dist/load/index.js +0 -25
  81. package/dist/load/map_keys.cjs +0 -2
  82. package/dist/load/map_keys.d.ts +0 -3
  83. package/dist/load/map_keys.js +0 -1
  84. package/dist/load/serializable.cjs +0 -17
  85. package/dist/load/serializable.d.ts +0 -1
  86. package/dist/load/serializable.js +0 -1
  87. package/dist/output_parsers.d.ts +0 -22
  88. package/dist/types.cjs +0 -48
  89. package/dist/types.js +0 -45
  90. package/dist/utils/errors.d.ts +0 -3
  91. package/dist/utils/message_inputs.d.ts +0 -14
  92. package/dist/utils/message_outputs.d.ts +0 -14
  93. package/dist/utils/tools.d.ts +0 -3
  94. package/experimental.cjs +0 -1
  95. package/experimental.d.cts +0 -1
  96. package/experimental.d.ts +0 -1
  97. package/experimental.js +0 -1
  98. package/index.cjs +0 -1
  99. package/index.d.cts +0 -1
  100. package/index.d.ts +0 -1
  101. package/index.js +0 -1
@@ -1,45 +1,49 @@
1
1
  import { _convertMessagesToAnthropicPayload } from "./message_inputs.js";
2
+
3
+ //#region src/utils/prompts.ts
2
4
  /**
3
- * Convert a formatted LangChain prompt (e.g. pulled from the hub) into
4
- * a format expected by Anthropic's JS SDK.
5
- *
6
- * Requires the "@langchain/anthropic" package to be installed in addition
7
- * to the Anthropic SDK.
8
- *
9
- * @example
10
- * ```ts
11
- * import { convertPromptToAnthropic } from "langsmith/utils/hub/anthropic";
12
- * import { pull } from "langchain/hub";
13
- *
14
- * import Anthropic from '@anthropic-ai/sdk';
15
- *
16
- * const prompt = await pull("jacob/joke-generator");
17
- * const formattedPrompt = await prompt.invoke({
18
- * topic: "cats",
19
- * });
20
- *
21
- * const { system, messages } = convertPromptToAnthropic(formattedPrompt);
22
- *
23
- * const anthropicClient = new Anthropic({
24
- * apiKey: 'your_api_key',
25
- * });
26
- *
27
- * const anthropicResponse = await anthropicClient.messages.create({
28
- * model: "claude-3-5-sonnet-20240620",
29
- * max_tokens: 1024,
30
- * stream: false,
31
- * system,
32
- * messages,
33
- * });
34
- * ```
35
- * @param formattedPrompt
36
- * @returns A partial Anthropic payload.
37
- */
38
- export function convertPromptToAnthropic(formattedPrompt) {
39
- const messages = formattedPrompt.toChatMessages();
40
- const anthropicBody = _convertMessagesToAnthropicPayload(messages);
41
- if (anthropicBody.messages === undefined) {
42
- anthropicBody.messages = [];
43
- }
44
- return anthropicBody;
5
+ * Convert a formatted LangChain prompt (e.g. pulled from the hub) into
6
+ * a format expected by Anthropic's JS SDK.
7
+ *
8
+ * Requires the "@langchain/anthropic" package to be installed in addition
9
+ * to the Anthropic SDK.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * import { convertPromptToAnthropic } from "langsmith/utils/hub/anthropic";
14
+ * import { pull } from "langchain/hub";
15
+ *
16
+ * import Anthropic from '@anthropic-ai/sdk';
17
+ *
18
+ * const prompt = await pull("jacob/joke-generator");
19
+ * const formattedPrompt = await prompt.invoke({
20
+ * topic: "cats",
21
+ * });
22
+ *
23
+ * const { system, messages } = convertPromptToAnthropic(formattedPrompt);
24
+ *
25
+ * const anthropicClient = new Anthropic({
26
+ * apiKey: 'your_api_key',
27
+ * });
28
+ *
29
+ * const anthropicResponse = await anthropicClient.messages.create({
30
+ * model: "claude-3-5-sonnet-20240620",
31
+ * max_tokens: 1024,
32
+ * stream: false,
33
+ * system,
34
+ * messages,
35
+ * });
36
+ * ```
37
+ * @param formattedPrompt
38
+ * @returns A partial Anthropic payload.
39
+ */
40
+ function convertPromptToAnthropic(formattedPrompt) {
41
+ const messages = formattedPrompt.toChatMessages();
42
+ const anthropicBody = _convertMessagesToAnthropicPayload(messages);
43
+ if (anthropicBody.messages === void 0) anthropicBody.messages = [];
44
+ return anthropicBody;
45
45
  }
46
+
47
+ //#endregion
48
+ export { convertPromptToAnthropic };
49
+ //# sourceMappingURL=prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.js","names":["formattedPrompt: BasePromptValue"],"sources":["../../src/utils/prompts.ts"],"sourcesContent":["import type { BasePromptValue } from \"@langchain/core/prompt_values\";\nimport Anthropic from \"@anthropic-ai/sdk\";\n\nimport { _convertMessagesToAnthropicPayload } from \"./message_inputs.js\";\n\n/**\n * Convert a formatted LangChain prompt (e.g. pulled from the hub) into\n * a format expected by Anthropic's JS SDK.\n *\n * Requires the \"@langchain/anthropic\" package to be installed in addition\n * to the Anthropic SDK.\n *\n * @example\n * ```ts\n * import { convertPromptToAnthropic } from \"langsmith/utils/hub/anthropic\";\n * import { pull } from \"langchain/hub\";\n *\n * import Anthropic from '@anthropic-ai/sdk';\n *\n * const prompt = await pull(\"jacob/joke-generator\");\n * const formattedPrompt = await prompt.invoke({\n * topic: \"cats\",\n * });\n *\n * const { system, messages } = convertPromptToAnthropic(formattedPrompt);\n *\n * const anthropicClient = new Anthropic({\n * apiKey: 'your_api_key',\n * });\n *\n * const anthropicResponse = await anthropicClient.messages.create({\n * model: \"claude-3-5-sonnet-20240620\",\n * max_tokens: 1024,\n * stream: false,\n * system,\n * messages,\n * });\n * ```\n * @param formattedPrompt\n * @returns A partial Anthropic payload.\n */\nexport function convertPromptToAnthropic(\n formattedPrompt: BasePromptValue\n): Anthropic.Messages.MessageCreateParams {\n const messages = formattedPrompt.toChatMessages();\n const anthropicBody = _convertMessagesToAnthropicPayload(messages);\n if (anthropicBody.messages === undefined) {\n anthropicBody.messages = [];\n }\n return anthropicBody;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,SAAgB,yBACdA,iBACwC;CACxC,MAAM,WAAW,gBAAgB,gBAAgB;CACjD,MAAM,gBAAgB,mCAAmC,SAAS;AAClE,KAAI,cAAc,aAAa,QAC7B,cAAc,WAAW,CAAE;AAE7B,QAAO;AACR"}
@@ -0,0 +1,127 @@
1
+ const require_index = require('./index.cjs');
2
+
3
+ //#region src/utils/standard.ts
4
+ function _isStandardAnnotation(annotation) {
5
+ return typeof annotation === "object" && annotation !== null && "type" in annotation && annotation.type === "citation";
6
+ }
7
+ function _formatStandardCitations(annotations) {
8
+ function* iterateAnnotations() {
9
+ for (const annotation of annotations) if (_isStandardAnnotation(annotation)) {
10
+ if (annotation.source === "char") yield {
11
+ type: "char_location",
12
+ start_char_index: annotation.startIndex ?? 0,
13
+ end_char_index: annotation.endIndex ?? 0,
14
+ document_title: annotation.title ?? null,
15
+ document_index: 0,
16
+ cited_text: annotation.citedText ?? ""
17
+ };
18
+ else if (annotation.source === "page") yield {
19
+ type: "page_location",
20
+ start_page_number: annotation.startIndex ?? 0,
21
+ end_page_number: annotation.endIndex ?? 0,
22
+ document_title: annotation.title ?? null,
23
+ document_index: 0,
24
+ cited_text: annotation.citedText ?? ""
25
+ };
26
+ else if (annotation.source === "block") yield {
27
+ type: "content_block_location",
28
+ start_block_index: annotation.startIndex ?? 0,
29
+ end_block_index: annotation.endIndex ?? 0,
30
+ document_title: annotation.title ?? null,
31
+ document_index: 0,
32
+ cited_text: annotation.citedText ?? ""
33
+ };
34
+ else if (annotation.source === "url") yield {
35
+ type: "web_search_result_location",
36
+ url: annotation.url ?? "",
37
+ title: annotation.title ?? null,
38
+ encrypted_index: String(annotation.startIndex ?? 0),
39
+ cited_text: annotation.citedText ?? ""
40
+ };
41
+ else if (annotation.source === "search") yield {
42
+ type: "search_result_location",
43
+ title: annotation.title ?? null,
44
+ start_block_index: annotation.startIndex ?? 0,
45
+ end_block_index: annotation.endIndex ?? 0,
46
+ search_result_index: 0,
47
+ source: annotation.source ?? "",
48
+ cited_text: annotation.citedText ?? ""
49
+ };
50
+ }
51
+ }
52
+ return Array.from(iterateAnnotations());
53
+ }
54
+ function _formatStandardContent(message) {
55
+ const result = [];
56
+ const modelProvider = message.response_metadata?.model_provider;
57
+ for (const block of message.contentBlocks) if (block.type === "text") if (block.annotations) result.push({
58
+ type: "text",
59
+ text: block.text,
60
+ citations: _formatStandardCitations(block.annotations)
61
+ });
62
+ else result.push({
63
+ type: "text",
64
+ text: block.text
65
+ });
66
+ else if (block.type === "tool_call") result.push({
67
+ type: "tool_use",
68
+ id: block.id ?? "",
69
+ name: block.name,
70
+ input: block.args
71
+ });
72
+ else if (block.type === "tool_call_chunk") {
73
+ const input = require_index.iife(() => {
74
+ if (typeof block.args !== "string") return block.args;
75
+ try {
76
+ return JSON.parse(block.args);
77
+ } catch {
78
+ return {};
79
+ }
80
+ });
81
+ result.push({
82
+ type: "tool_use",
83
+ id: block.id ?? "",
84
+ name: block.name ?? "",
85
+ input
86
+ });
87
+ } else if (block.type === "reasoning" && modelProvider === "anthropic") result.push({
88
+ type: "thinking",
89
+ thinking: block.reasoning,
90
+ signature: String(block.signature)
91
+ });
92
+ else if (block.type === "web_search_call" && modelProvider === "anthropic") result.push({
93
+ id: block.id ?? "",
94
+ type: "server_tool_use",
95
+ name: "web_search",
96
+ input: block.input ?? { query: block.query }
97
+ });
98
+ else if (block.type === "web_search_result" && modelProvider === "anthropic") result.push({
99
+ id: block.id,
100
+ type: "web_search_tool_result",
101
+ content: block.content
102
+ });
103
+ else if (block.type === "code_interpreter_call" && modelProvider === "anthropic") result.push({
104
+ type: "server_tool_use",
105
+ name: "code_execution",
106
+ id: block.id,
107
+ input: { code: block.code }
108
+ });
109
+ else if (block.type === "code_interpreter_result" && modelProvider === "anthropic" && Array.isArray(block.fileIds)) result.push({
110
+ type: "code_execution_tool_result",
111
+ content: {
112
+ type: "code_execution_result",
113
+ stderr: block.stderr,
114
+ stdout: block.stdout,
115
+ return_code: block.returnCode,
116
+ fileIds: block.fileIds.map((fileId) => ({
117
+ type: "code_execution_output",
118
+ file_id: fileId
119
+ }))
120
+ }
121
+ });
122
+ return result;
123
+ }
124
+
125
+ //#endregion
126
+ exports._formatStandardContent = _formatStandardContent;
127
+ //# sourceMappingURL=standard.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standard.cjs","names":["annotation: unknown","annotations: ContentBlock.Citation[]","message: BaseMessage","result: Anthropic.Beta.BetaContentBlockParam[]","iife","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,yBACPC,aACmC;CACnC,UAAU,qBAAqB;AAC7B,OAA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QAAO;AACR"}
@@ -0,0 +1,127 @@
1
+ import { iife } from "./index.js";
2
+
3
+ //#region src/utils/standard.ts
4
+ function _isStandardAnnotation(annotation) {
5
+ return typeof annotation === "object" && annotation !== null && "type" in annotation && annotation.type === "citation";
6
+ }
7
+ function _formatStandardCitations(annotations) {
8
+ function* iterateAnnotations() {
9
+ for (const annotation of annotations) if (_isStandardAnnotation(annotation)) {
10
+ if (annotation.source === "char") yield {
11
+ type: "char_location",
12
+ start_char_index: annotation.startIndex ?? 0,
13
+ end_char_index: annotation.endIndex ?? 0,
14
+ document_title: annotation.title ?? null,
15
+ document_index: 0,
16
+ cited_text: annotation.citedText ?? ""
17
+ };
18
+ else if (annotation.source === "page") yield {
19
+ type: "page_location",
20
+ start_page_number: annotation.startIndex ?? 0,
21
+ end_page_number: annotation.endIndex ?? 0,
22
+ document_title: annotation.title ?? null,
23
+ document_index: 0,
24
+ cited_text: annotation.citedText ?? ""
25
+ };
26
+ else if (annotation.source === "block") yield {
27
+ type: "content_block_location",
28
+ start_block_index: annotation.startIndex ?? 0,
29
+ end_block_index: annotation.endIndex ?? 0,
30
+ document_title: annotation.title ?? null,
31
+ document_index: 0,
32
+ cited_text: annotation.citedText ?? ""
33
+ };
34
+ else if (annotation.source === "url") yield {
35
+ type: "web_search_result_location",
36
+ url: annotation.url ?? "",
37
+ title: annotation.title ?? null,
38
+ encrypted_index: String(annotation.startIndex ?? 0),
39
+ cited_text: annotation.citedText ?? ""
40
+ };
41
+ else if (annotation.source === "search") yield {
42
+ type: "search_result_location",
43
+ title: annotation.title ?? null,
44
+ start_block_index: annotation.startIndex ?? 0,
45
+ end_block_index: annotation.endIndex ?? 0,
46
+ search_result_index: 0,
47
+ source: annotation.source ?? "",
48
+ cited_text: annotation.citedText ?? ""
49
+ };
50
+ }
51
+ }
52
+ return Array.from(iterateAnnotations());
53
+ }
54
+ function _formatStandardContent(message) {
55
+ const result = [];
56
+ const modelProvider = message.response_metadata?.model_provider;
57
+ for (const block of message.contentBlocks) if (block.type === "text") if (block.annotations) result.push({
58
+ type: "text",
59
+ text: block.text,
60
+ citations: _formatStandardCitations(block.annotations)
61
+ });
62
+ else result.push({
63
+ type: "text",
64
+ text: block.text
65
+ });
66
+ else if (block.type === "tool_call") result.push({
67
+ type: "tool_use",
68
+ id: block.id ?? "",
69
+ name: block.name,
70
+ input: block.args
71
+ });
72
+ else if (block.type === "tool_call_chunk") {
73
+ const input = iife(() => {
74
+ if (typeof block.args !== "string") return block.args;
75
+ try {
76
+ return JSON.parse(block.args);
77
+ } catch {
78
+ return {};
79
+ }
80
+ });
81
+ result.push({
82
+ type: "tool_use",
83
+ id: block.id ?? "",
84
+ name: block.name ?? "",
85
+ input
86
+ });
87
+ } else if (block.type === "reasoning" && modelProvider === "anthropic") result.push({
88
+ type: "thinking",
89
+ thinking: block.reasoning,
90
+ signature: String(block.signature)
91
+ });
92
+ else if (block.type === "web_search_call" && modelProvider === "anthropic") result.push({
93
+ id: block.id ?? "",
94
+ type: "server_tool_use",
95
+ name: "web_search",
96
+ input: block.input ?? { query: block.query }
97
+ });
98
+ else if (block.type === "web_search_result" && modelProvider === "anthropic") result.push({
99
+ id: block.id,
100
+ type: "web_search_tool_result",
101
+ content: block.content
102
+ });
103
+ else if (block.type === "code_interpreter_call" && modelProvider === "anthropic") result.push({
104
+ type: "server_tool_use",
105
+ name: "code_execution",
106
+ id: block.id,
107
+ input: { code: block.code }
108
+ });
109
+ else if (block.type === "code_interpreter_result" && modelProvider === "anthropic" && Array.isArray(block.fileIds)) result.push({
110
+ type: "code_execution_tool_result",
111
+ content: {
112
+ type: "code_execution_result",
113
+ stderr: block.stderr,
114
+ stdout: block.stdout,
115
+ return_code: block.returnCode,
116
+ fileIds: block.fileIds.map((fileId) => ({
117
+ type: "code_execution_output",
118
+ file_id: fileId
119
+ }))
120
+ }
121
+ });
122
+ return result;
123
+ }
124
+
125
+ //#endregion
126
+ export { _formatStandardContent };
127
+ //# sourceMappingURL=standard.js.map
@@ -0,0 +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,yBACPC,aACmC;CACnC,UAAU,qBAAqB;AAC7B,OAAK,MAAM,cAAc,YACvB,KAAI,sBAAsB,WAAW,EACnC;OAAI,WAAW,WAAW,QACxB,MAAM;IACJ,MAAM;IACN,kBAAkB,WAAW,cAAc;IAC3C,gBAAgB,WAAW,YAAY;IACvC,gBAAgB,WAAW,SAAS;IACpC,gBAAgB;IAChB,YAAY,WAAW,aAAa;GACrC;YACQ,WAAW,WAAW,QAC/B,MAAM;IACJ,MAAM;IACN,mBAAmB,WAAW,cAAc;IAC5C,iBAAiB,WAAW,YAAY;IACxC,gBAAgB,WAAW,SAAS;IACpC,gBAAgB;IAChB,YAAY,WAAW,aAAa;GACrC;YACQ,WAAW,WAAW,SAC/B,MAAM;IACJ,MAAM;IACN,mBAAmB,WAAW,cAAc;IAC5C,iBAAiB,WAAW,YAAY;IACxC,gBAAgB,WAAW,SAAS;IACpC,gBAAgB;IAChB,YAAY,WAAW,aAAa;GACrC;YACQ,WAAW,WAAW,OAC/B,MAAM;IACJ,MAAM;IACN,KAAK,WAAW,OAAO;IACvB,OAAO,WAAW,SAAS;IAC3B,iBAAiB,OAAO,WAAW,cAAc,EAAE;IACnD,YAAY,WAAW,aAAa;GACrC;YACQ,WAAW,WAAW,UAC/B,MAAM;IACJ,MAAM;IACN,OAAO,WAAW,SAAS;IAC3B,mBAAmB,WAAW,cAAc;IAC5C,iBAAiB,WAAW,YAAY;IACxC,qBAAqB;IACrB,QAAQ,WAAW,UAAU;IAC7B,YAAY,WAAW,aAAa;GACrC;EACF;CAGN;AACD,QAAO,MAAM,KAAK,oBAAoB,CA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;CAC5B,EAAC;UAEF,MAAM,SAAS,6BACf,kBAAkB,eAClB,MAAM,QAAQ,MAAM,QAAQ,EAE5B,OAAO,KAAK;EACV,MAAM;EACN,SAAS;GACP,MAAM;GACN,QAAQ,MAAM;GACd,QAAQ,MAAM;GACd,aAAa,MAAM;GACnB,SAAS,MAAM,QAAQ,IAAI,CAACC,YAAoB;IAC9C,MAAM;IACN,SAAS;GACV,GAAE;EACJ;CACF,EAAC;AAGN,QAAO;AACR"}
@@ -1,27 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handleToolChoice = handleToolChoice;
1
+
2
+ //#region src/utils/tools.ts
4
3
  function handleToolChoice(toolChoice) {
5
- if (!toolChoice) {
6
- return undefined;
7
- }
8
- else if (toolChoice === "any") {
9
- return {
10
- type: "any",
11
- };
12
- }
13
- else if (toolChoice === "auto") {
14
- return {
15
- type: "auto",
16
- };
17
- }
18
- else if (typeof toolChoice === "string") {
19
- return {
20
- type: "tool",
21
- name: toolChoice,
22
- };
23
- }
24
- else {
25
- return toolChoice;
26
- }
4
+ if (!toolChoice) return void 0;
5
+ else if (toolChoice === "any") return { type: "any" };
6
+ else if (toolChoice === "auto") return { type: "auto" };
7
+ else if (typeof toolChoice === "string") return {
8
+ type: "tool",
9
+ name: toolChoice
10
+ };
11
+ else return toolChoice;
27
12
  }
13
+
14
+ //#endregion
15
+ exports.handleToolChoice = handleToolChoice;
16
+ //# sourceMappingURL=tools.cjs.map
@@ -0,0 +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,YAKY;AACZ,KAAI,CAAC,WACH,QAAO;UACE,eAAe,MACxB,QAAO,EACL,MAAM,MACP;UACQ,eAAe,OACxB,QAAO,EACL,MAAM,OACP;UACQ,OAAO,eAAe,SAC/B,QAAO;EACL,MAAM;EACN,MAAM;CACP;KAED,QAAO;AAEV"}
@@ -1,24 +1,15 @@
1
- export function handleToolChoice(toolChoice) {
2
- if (!toolChoice) {
3
- return undefined;
4
- }
5
- else if (toolChoice === "any") {
6
- return {
7
- type: "any",
8
- };
9
- }
10
- else if (toolChoice === "auto") {
11
- return {
12
- type: "auto",
13
- };
14
- }
15
- else if (typeof toolChoice === "string") {
16
- return {
17
- type: "tool",
18
- name: toolChoice,
19
- };
20
- }
21
- else {
22
- return toolChoice;
23
- }
1
+ //#region src/utils/tools.ts
2
+ function handleToolChoice(toolChoice) {
3
+ if (!toolChoice) return void 0;
4
+ else if (toolChoice === "any") return { type: "any" };
5
+ else if (toolChoice === "auto") return { type: "auto" };
6
+ else if (typeof toolChoice === "string") return {
7
+ type: "tool",
8
+ name: toolChoice
9
+ };
10
+ else return toolChoice;
24
11
  }
12
+
13
+ //#endregion
14
+ export { handleToolChoice };
15
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +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,YAKY;AACZ,KAAI,CAAC,WACH,QAAO;UACE,eAAe,MACxB,QAAO,EACL,MAAM,MACP;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,69 +1,59 @@
1
1
  {
2
2
  "name": "@langchain/anthropic",
3
- "version": "0.3.25",
3
+ "version": "1.0.0-alpha.1",
4
4
  "description": "Anthropic integrations for LangChain.js",
5
+ "author": "LangChain",
6
+ "license": "MIT",
5
7
  "type": "module",
6
8
  "engines": {
7
- "node": ">=18"
9
+ "node": ">=20"
8
10
  },
9
- "main": "./index.js",
10
- "types": "./index.d.ts",
11
11
  "repository": {
12
12
  "type": "git",
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
16
  "scripts": {
17
- "build": "yarn turbo:command build:internal --filter=@langchain/anthropic",
18
- "build:internal": "yarn lc_build --create-entrypoints --pre --tree-shaking --gen-maps",
17
+ "build": "pnpm --filter @langchain/build compile @langchain/anthropic",
19
18
  "lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/",
20
19
  "lint:dpdm": "dpdm --skip-dynamic-imports circular --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts",
21
- "lint": "yarn lint:eslint && yarn lint:dpdm",
22
- "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm",
20
+ "lint": "pnpm lint:eslint && pnpm lint:dpdm",
21
+ "lint:fix": "pnpm lint:eslint --fix && pnpm lint:dpdm",
23
22
  "clean": "rm -rf .turbo dist/",
24
- "prepack": "yarn build",
25
- "test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%",
26
- "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts",
27
- "test:single": "NODE_OPTIONS=--experimental-vm-modules yarn run jest --config jest.config.cjs --testTimeout 100000",
28
- "test:int": "NODE_OPTIONS=--experimental-vm-modules jest --testPathPattern=\\.int\\.test.ts --testTimeout 100000 --maxWorkers=50%",
29
- "test:standard:unit": "NODE_OPTIONS=--experimental-vm-modules jest --testPathPattern=\\.standard\\.test.ts --testTimeout 100000 --maxWorkers=50%",
30
- "test:standard:int": "NODE_OPTIONS=--experimental-vm-modules jest --testPathPattern=\\.standard\\.int\\.test.ts --testTimeout 100000 --maxWorkers=50%",
31
- "test:standard": "yarn test:standard:unit && yarn test:standard:int",
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",
32
29
  "format": "prettier --config .prettierrc --write \"src\"",
33
30
  "format:check": "prettier --config .prettierrc --check \"src\""
34
31
  },
35
- "author": "LangChain",
36
- "license": "MIT",
37
32
  "dependencies": {
38
- "@anthropic-ai/sdk": "^0.56.0",
39
- "fast-xml-parser": "^4.4.1"
33
+ "@anthropic-ai/sdk": "^0.56.0"
40
34
  },
41
35
  "peerDependencies": {
42
- "@langchain/core": ">=0.3.58 <0.4.0"
36
+ "@langchain/core": ">=1.0.0-alpha <2.0.0"
43
37
  },
44
38
  "devDependencies": {
45
39
  "@anthropic-ai/vertex-sdk": "^0.11.5",
46
- "@jest/globals": "^29.5.0",
47
40
  "@langchain/core": "workspace:*",
48
- "@langchain/scripts": ">=0.1.0 <0.2.0",
49
- "@langchain/standard-tests": "0.0.0",
50
- "@swc/core": "^1.3.90",
51
- "@swc/jest": "^0.2.29",
41
+ "@langchain/standard-tests": "workspace:*",
42
+ "@tsconfig/recommended": "^1.0.10",
43
+ "@vitest/coverage-v8": "^3.2.4",
44
+ "dotenv": "^17.2.1",
52
45
  "dpdm": "^3.14.0",
53
46
  "eslint": "^8.33.0",
54
47
  "eslint-config-airbnb-base": "^15.0.0",
55
48
  "eslint-config-prettier": "^8.6.0",
56
49
  "eslint-plugin-import": "^2.27.5",
57
- "eslint-plugin-jest": "^27.6.0",
58
50
  "eslint-plugin-no-instanceof": "^1.0.1",
59
51
  "eslint-plugin-prettier": "^4.2.1",
60
- "jest": "^29.5.0",
61
- "jest-environment-node": "^29.6.4",
62
52
  "prettier": "^2.8.3",
63
53
  "release-it": "^18.1.2",
64
54
  "rimraf": "^5.0.1",
65
- "ts-jest": "^29.1.0",
66
55
  "typescript": "~5.8.3",
56
+ "vitest": "^3.2.4",
67
57
  "zod": "^3.25.32"
68
58
  },
69
59
  "publishConfig": {
@@ -83,36 +73,23 @@
83
73
  "embeddings",
84
74
  "vectorstores"
85
75
  ],
76
+ "main": "./dist/index.js",
77
+ "types": "./dist/index.d.ts",
86
78
  "exports": {
87
79
  ".": {
88
- "types": {
89
- "import": "./index.d.ts",
90
- "require": "./index.d.cts",
91
- "default": "./index.d.ts"
80
+ "import": {
81
+ "types": "./dist/index.d.ts",
82
+ "default": "./dist/index.js"
92
83
  },
93
- "import": "./index.js",
94
- "require": "./index.cjs"
95
- },
96
- "./experimental": {
97
- "types": {
98
- "import": "./experimental.d.ts",
99
- "require": "./experimental.d.cts",
100
- "default": "./experimental.d.ts"
84
+ "require": {
85
+ "types": "./dist/index.d.cts",
86
+ "default": "./dist/index.cjs"
101
87
  },
102
- "import": "./experimental.js",
103
- "require": "./experimental.cjs"
88
+ "input": "./src/index.ts"
104
89
  },
105
90
  "./package.json": "./package.json"
106
91
  },
107
92
  "files": [
108
- "dist/",
109
- "index.cjs",
110
- "index.js",
111
- "index.d.ts",
112
- "index.d.cts",
113
- "experimental.cjs",
114
- "experimental.js",
115
- "experimental.d.ts",
116
- "experimental.d.cts"
93
+ "dist/"
117
94
  ]
118
95
  }
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./tool_calling.cjs"), exports);
@@ -1 +0,0 @@
1
- export * from "./tool_calling.js";
@@ -1 +0,0 @@
1
- export * from "./tool_calling.js";