@langchain/anthropic 0.3.31 → 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/README.md +8 -8
- package/dist/_virtual/rolldown_runtime.cjs +25 -0
- package/dist/chat_models.cjs +781 -1012
- package/dist/chat_models.cjs.map +1 -0
- package/dist/chat_models.d.cts +620 -0
- package/dist/chat_models.d.cts.map +1 -0
- package/dist/chat_models.d.ts +227 -211
- package/dist/chat_models.d.ts.map +1 -0
- package/dist/chat_models.js +775 -1003
- package/dist/chat_models.js.map +1 -0
- package/dist/index.cjs +6 -20
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.js +4 -2
- package/dist/output_parsers.cjs +65 -104
- package/dist/output_parsers.cjs.map +1 -0
- package/dist/output_parsers.js +64 -100
- package/dist/output_parsers.js.map +1 -0
- package/dist/types.d.cts +33 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.ts +30 -32
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/content.cjs +151 -0
- package/dist/utils/content.cjs.map +1 -0
- package/dist/utils/content.js +146 -0
- package/dist/utils/content.js.map +1 -0
- package/dist/utils/errors.cjs +16 -27
- package/dist/utils/errors.cjs.map +1 -0
- package/dist/utils/errors.js +17 -25
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/index.cjs +7 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.js +6 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/message_inputs.cjs +223 -534
- package/dist/utils/message_inputs.cjs.map +1 -0
- package/dist/utils/message_inputs.js +224 -532
- package/dist/utils/message_inputs.js.map +1 -0
- package/dist/utils/message_outputs.cjs +186 -250
- package/dist/utils/message_outputs.cjs.map +1 -0
- package/dist/utils/message_outputs.js +185 -247
- package/dist/utils/message_outputs.js.map +1 -0
- package/dist/utils/prompts.cjs +46 -45
- package/dist/utils/prompts.cjs.map +1 -0
- package/dist/utils/prompts.d.cts +45 -0
- package/dist/utils/prompts.d.cts.map +1 -0
- package/dist/utils/prompts.d.ts +8 -2
- package/dist/utils/prompts.d.ts.map +1 -0
- package/dist/utils/prompts.js +46 -42
- package/dist/utils/prompts.js.map +1 -0
- package/dist/utils/standard.cjs +285 -0
- package/dist/utils/standard.cjs.map +1 -0
- package/dist/utils/standard.js +285 -0
- package/dist/utils/standard.js.map +1 -0
- package/dist/utils/tools.cjs +15 -30
- package/dist/utils/tools.cjs.map +1 -0
- package/dist/utils/tools.js +15 -28
- package/dist/utils/tools.js.map +1 -0
- package/package.json +45 -71
- package/dist/experimental/index.cjs +0 -17
- package/dist/experimental/index.d.ts +0 -1
- package/dist/experimental/index.js +0 -1
- package/dist/experimental/tool_calling.cjs +0 -318
- package/dist/experimental/tool_calling.d.ts +0 -57
- package/dist/experimental/tool_calling.js +0 -314
- package/dist/experimental/utils/tool_calling.cjs +0 -106
- package/dist/experimental/utils/tool_calling.d.ts +0 -10
- package/dist/experimental/utils/tool_calling.js +0 -101
- package/dist/load/import_constants.cjs +0 -5
- package/dist/load/import_constants.d.ts +0 -1
- package/dist/load/import_constants.js +0 -2
- package/dist/load/import_map.cjs +0 -39
- package/dist/load/import_map.d.ts +0 -2
- package/dist/load/import_map.js +0 -3
- package/dist/load/import_type.cjs +0 -3
- package/dist/load/import_type.d.ts +0 -5
- package/dist/load/import_type.js +0 -2
- package/dist/load/index.cjs +0 -63
- package/dist/load/index.d.ts +0 -14
- package/dist/load/index.js +0 -25
- package/dist/load/map_keys.cjs +0 -2
- package/dist/load/map_keys.d.ts +0 -3
- package/dist/load/map_keys.js +0 -1
- package/dist/load/serializable.cjs +0 -17
- package/dist/load/serializable.d.ts +0 -1
- package/dist/load/serializable.js +0 -1
- package/dist/output_parsers.d.ts +0 -22
- package/dist/types.cjs +0 -48
- package/dist/types.js +0 -45
- package/dist/utils/errors.d.ts +0 -3
- package/dist/utils/message_inputs.d.ts +0 -14
- package/dist/utils/message_outputs.d.ts +0 -14
- package/dist/utils/tools.d.ts +0 -3
- package/experimental.cjs +0 -1
- package/experimental.d.cts +0 -1
- package/experimental.d.ts +0 -1
- package/experimental.js +0 -1
- package/index.cjs +0 -1
- package/index.d.cts +0 -1
- package/index.d.ts +0 -1
- package/index.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","names":["BasePromptValue","Anthropic","convertPromptToAnthropic","Messages","MessageCreateParams"],"sources":["../../src/utils/prompts.d.ts"],"sourcesContent":["import type { BasePromptValue } from \"@langchain/core/prompt_values\";\nimport Anthropic from \"@anthropic-ai/sdk\";\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 declare function convertPromptToAnthropic(formattedPrompt: BasePromptValue): Anthropic.Messages.MessageCreateParams;\n"],"mappings":";;;;;;;AAsCA;;;;AAA0H;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAlGE,wBAAAA,kBAA0CF,kBAAkBC,SAAAA,CAAUE,QAAAA,CAASC"}
|
package/dist/utils/prompts.js
CHANGED
|
@@ -1,45 +1,49 @@
|
|
|
1
1
|
import { _convertMessagesToAnthropicPayload } from "./message_inputs.js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/prompts.ts
|
|
2
4
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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,285 @@
|
|
|
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
|
+
file_id: annotation.url ?? "",
|
|
13
|
+
start_char_index: annotation.startIndex ?? 0,
|
|
14
|
+
end_char_index: annotation.endIndex ?? 0,
|
|
15
|
+
document_title: annotation.title ?? null,
|
|
16
|
+
document_index: 0,
|
|
17
|
+
cited_text: annotation.citedText ?? ""
|
|
18
|
+
};
|
|
19
|
+
else if (annotation.source === "page") yield {
|
|
20
|
+
type: "page_location",
|
|
21
|
+
file_id: annotation.url ?? "",
|
|
22
|
+
start_page_number: annotation.startIndex ?? 0,
|
|
23
|
+
end_page_number: annotation.endIndex ?? 0,
|
|
24
|
+
document_title: annotation.title ?? null,
|
|
25
|
+
document_index: 0,
|
|
26
|
+
cited_text: annotation.citedText ?? ""
|
|
27
|
+
};
|
|
28
|
+
else if (annotation.source === "block") yield {
|
|
29
|
+
type: "content_block_location",
|
|
30
|
+
file_id: annotation.url ?? "",
|
|
31
|
+
start_block_index: annotation.startIndex ?? 0,
|
|
32
|
+
end_block_index: annotation.endIndex ?? 0,
|
|
33
|
+
document_title: annotation.title ?? null,
|
|
34
|
+
document_index: 0,
|
|
35
|
+
cited_text: annotation.citedText ?? ""
|
|
36
|
+
};
|
|
37
|
+
else if (annotation.source === "url") yield {
|
|
38
|
+
type: "web_search_result_location",
|
|
39
|
+
url: annotation.url ?? "",
|
|
40
|
+
title: annotation.title ?? null,
|
|
41
|
+
encrypted_index: String(annotation.startIndex ?? 0),
|
|
42
|
+
cited_text: annotation.citedText ?? ""
|
|
43
|
+
};
|
|
44
|
+
else if (annotation.source === "search") yield {
|
|
45
|
+
type: "search_result_location",
|
|
46
|
+
title: annotation.title ?? null,
|
|
47
|
+
start_block_index: annotation.startIndex ?? 0,
|
|
48
|
+
end_block_index: annotation.endIndex ?? 0,
|
|
49
|
+
search_result_index: 0,
|
|
50
|
+
source: annotation.source ?? "",
|
|
51
|
+
cited_text: annotation.citedText ?? ""
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return Array.from(iterateAnnotations());
|
|
56
|
+
}
|
|
57
|
+
function _formatBase64Data(data) {
|
|
58
|
+
if (typeof data === "string") return data;
|
|
59
|
+
else return _encodeUint8Array(data);
|
|
60
|
+
}
|
|
61
|
+
function _encodeUint8Array(data) {
|
|
62
|
+
const output = [];
|
|
63
|
+
for (let i = 0, { length } = data; i < length; i++) output.push(String.fromCharCode(data[i]));
|
|
64
|
+
return btoa(output.join(""));
|
|
65
|
+
}
|
|
66
|
+
function _normalizeMimeType(mimeType) {
|
|
67
|
+
return (mimeType ?? "").split(";")[0].toLowerCase();
|
|
68
|
+
}
|
|
69
|
+
function _extractMetadataValue(metadata, key) {
|
|
70
|
+
if (metadata !== void 0 && metadata !== null && typeof metadata === "object" && key in metadata) return metadata[key];
|
|
71
|
+
return void 0;
|
|
72
|
+
}
|
|
73
|
+
function _applyDocumentMetadata(block, metadata) {
|
|
74
|
+
const cacheControl = _extractMetadataValue(metadata, "cache_control");
|
|
75
|
+
if (cacheControl !== void 0) block.cache_control = cacheControl;
|
|
76
|
+
const citations = _extractMetadataValue(metadata, "citations");
|
|
77
|
+
if (citations !== void 0) block.citations = citations;
|
|
78
|
+
const context = _extractMetadataValue(metadata, "context");
|
|
79
|
+
if (context !== void 0) block.context = context;
|
|
80
|
+
const title = _extractMetadataValue(metadata, "title");
|
|
81
|
+
if (title !== void 0) block.title = title;
|
|
82
|
+
return block;
|
|
83
|
+
}
|
|
84
|
+
function _applyImageMetadata(block, metadata) {
|
|
85
|
+
const cacheControl = _extractMetadataValue(metadata, "cache_control");
|
|
86
|
+
if (cacheControl !== void 0) block.cache_control = cacheControl;
|
|
87
|
+
return block;
|
|
88
|
+
}
|
|
89
|
+
function _hasAllowedImageMimeType(mimeType) {
|
|
90
|
+
const ALLOWED_IMAGE_MIME_TYPES = new Set([
|
|
91
|
+
"image/jpeg",
|
|
92
|
+
"image/png",
|
|
93
|
+
"image/gif",
|
|
94
|
+
"image/webp"
|
|
95
|
+
]);
|
|
96
|
+
return ALLOWED_IMAGE_MIME_TYPES.has(mimeType);
|
|
97
|
+
}
|
|
98
|
+
function _formatStandardContent(message) {
|
|
99
|
+
const result = [];
|
|
100
|
+
const responseMetadata = message.response_metadata;
|
|
101
|
+
const isAnthropicMessage = "model_provider" in responseMetadata && responseMetadata?.model_provider === "anthropic";
|
|
102
|
+
for (const block of message.contentBlocks) if (block.type === "text") if (block.annotations) result.push({
|
|
103
|
+
type: "text",
|
|
104
|
+
text: block.text,
|
|
105
|
+
citations: _formatStandardCitations(block.annotations)
|
|
106
|
+
});
|
|
107
|
+
else result.push({
|
|
108
|
+
type: "text",
|
|
109
|
+
text: block.text
|
|
110
|
+
});
|
|
111
|
+
else if (block.type === "tool_call") result.push({
|
|
112
|
+
type: "tool_use",
|
|
113
|
+
id: block.id ?? "",
|
|
114
|
+
name: block.name,
|
|
115
|
+
input: block.args
|
|
116
|
+
});
|
|
117
|
+
else if (block.type === "tool_call_chunk") {
|
|
118
|
+
const input = require_index.iife(() => {
|
|
119
|
+
if (typeof block.args !== "string") return block.args;
|
|
120
|
+
try {
|
|
121
|
+
return JSON.parse(block.args);
|
|
122
|
+
} catch {
|
|
123
|
+
return {};
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
result.push({
|
|
127
|
+
type: "tool_use",
|
|
128
|
+
id: block.id ?? "",
|
|
129
|
+
name: block.name ?? "",
|
|
130
|
+
input
|
|
131
|
+
});
|
|
132
|
+
} else if (block.type === "reasoning" && isAnthropicMessage) result.push({
|
|
133
|
+
type: "thinking",
|
|
134
|
+
thinking: block.reasoning,
|
|
135
|
+
signature: String(block.signature)
|
|
136
|
+
});
|
|
137
|
+
else if (block.type === "server_tool_call" && isAnthropicMessage) {
|
|
138
|
+
if (block.name === "web_search") result.push({
|
|
139
|
+
type: "server_tool_use",
|
|
140
|
+
name: block.name,
|
|
141
|
+
id: block.id ?? "",
|
|
142
|
+
input: block.args
|
|
143
|
+
});
|
|
144
|
+
else if (block.name === "code_execution") result.push({
|
|
145
|
+
type: "server_tool_use",
|
|
146
|
+
name: block.name,
|
|
147
|
+
id: block.id ?? "",
|
|
148
|
+
input: block.args
|
|
149
|
+
});
|
|
150
|
+
} else if (block.type === "server_tool_call_result" && isAnthropicMessage) {
|
|
151
|
+
if (block.name === "web_search" && Array.isArray(block.output.urls)) {
|
|
152
|
+
const content = block.output.urls.map((url) => ({
|
|
153
|
+
type: "web_search_result",
|
|
154
|
+
title: "",
|
|
155
|
+
encrypted_content: "",
|
|
156
|
+
url
|
|
157
|
+
}));
|
|
158
|
+
result.push({
|
|
159
|
+
type: "web_search_tool_result",
|
|
160
|
+
tool_use_id: block.toolCallId ?? "",
|
|
161
|
+
content
|
|
162
|
+
});
|
|
163
|
+
} else if (block.name === "code_execution") result.push({
|
|
164
|
+
type: "code_execution_tool_result",
|
|
165
|
+
tool_use_id: block.toolCallId ?? "",
|
|
166
|
+
content: block.output
|
|
167
|
+
});
|
|
168
|
+
else if (block.name === "mcp_tool_result") result.push({
|
|
169
|
+
type: "mcp_tool_result",
|
|
170
|
+
tool_use_id: block.toolCallId ?? "",
|
|
171
|
+
content: block.output
|
|
172
|
+
});
|
|
173
|
+
} else if (block.type === "audio") throw new Error("Anthropic does not support audio content blocks.");
|
|
174
|
+
else if (block.type === "file") {
|
|
175
|
+
const metadata = block.metadata;
|
|
176
|
+
if (block.fileId) {
|
|
177
|
+
result.push(_applyDocumentMetadata({
|
|
178
|
+
type: "document",
|
|
179
|
+
source: {
|
|
180
|
+
type: "file",
|
|
181
|
+
file_id: block.fileId
|
|
182
|
+
}
|
|
183
|
+
}, metadata));
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
if (block.url) {
|
|
187
|
+
const mimeType = _normalizeMimeType(block.mimeType);
|
|
188
|
+
if (mimeType === "application/pdf" || mimeType === "") {
|
|
189
|
+
result.push(_applyDocumentMetadata({
|
|
190
|
+
type: "document",
|
|
191
|
+
source: {
|
|
192
|
+
type: "url",
|
|
193
|
+
url: block.url
|
|
194
|
+
}
|
|
195
|
+
}, metadata));
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (block.data) {
|
|
200
|
+
const mimeType = _normalizeMimeType(block.mimeType);
|
|
201
|
+
if (mimeType === "" || mimeType === "application/pdf") result.push(_applyDocumentMetadata({
|
|
202
|
+
type: "document",
|
|
203
|
+
source: {
|
|
204
|
+
type: "base64",
|
|
205
|
+
data: _formatBase64Data(block.data),
|
|
206
|
+
media_type: "application/pdf"
|
|
207
|
+
}
|
|
208
|
+
}, metadata));
|
|
209
|
+
else if (mimeType === "text/plain") result.push(_applyDocumentMetadata({
|
|
210
|
+
type: "document",
|
|
211
|
+
source: {
|
|
212
|
+
type: "text",
|
|
213
|
+
data: _formatBase64Data(block.data),
|
|
214
|
+
media_type: "text/plain"
|
|
215
|
+
}
|
|
216
|
+
}, metadata));
|
|
217
|
+
else if (_hasAllowedImageMimeType(mimeType)) result.push(_applyDocumentMetadata({
|
|
218
|
+
type: "document",
|
|
219
|
+
source: {
|
|
220
|
+
type: "content",
|
|
221
|
+
content: [{
|
|
222
|
+
type: "image",
|
|
223
|
+
source: {
|
|
224
|
+
type: "base64",
|
|
225
|
+
data: _formatBase64Data(block.data),
|
|
226
|
+
media_type: mimeType
|
|
227
|
+
}
|
|
228
|
+
}]
|
|
229
|
+
}
|
|
230
|
+
}, metadata));
|
|
231
|
+
else throw new Error(`Unsupported file mime type for Anthropic base64 source: ${mimeType}`);
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
throw new Error("File content block must include a fileId, url, or data property.");
|
|
235
|
+
} else if (block.type === "image") {
|
|
236
|
+
const metadata = block.metadata;
|
|
237
|
+
if (block.fileId) {
|
|
238
|
+
result.push(_applyImageMetadata({
|
|
239
|
+
type: "image",
|
|
240
|
+
source: {
|
|
241
|
+
type: "file",
|
|
242
|
+
file_id: block.fileId
|
|
243
|
+
}
|
|
244
|
+
}, metadata));
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
if (block.url) {
|
|
248
|
+
result.push(_applyImageMetadata({
|
|
249
|
+
type: "image",
|
|
250
|
+
source: {
|
|
251
|
+
type: "url",
|
|
252
|
+
url: block.url
|
|
253
|
+
}
|
|
254
|
+
}, metadata));
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
if (block.data) {
|
|
258
|
+
const mimeType = _normalizeMimeType(block.mimeType) || "image/png";
|
|
259
|
+
if (_hasAllowedImageMimeType(mimeType)) result.push(_applyImageMetadata({
|
|
260
|
+
type: "image",
|
|
261
|
+
source: {
|
|
262
|
+
type: "base64",
|
|
263
|
+
data: _formatBase64Data(block.data),
|
|
264
|
+
media_type: mimeType
|
|
265
|
+
}
|
|
266
|
+
}, metadata));
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
throw new Error("Image content block must include a fileId, url, or data property.");
|
|
270
|
+
} else if (block.type === "video") {} else if (block.type === "text-plain") {
|
|
271
|
+
if (block.data) result.push(_applyDocumentMetadata({
|
|
272
|
+
type: "document",
|
|
273
|
+
source: {
|
|
274
|
+
type: "text",
|
|
275
|
+
data: _formatBase64Data(block.data),
|
|
276
|
+
media_type: "text/plain"
|
|
277
|
+
}
|
|
278
|
+
}, block.metadata));
|
|
279
|
+
} else if (block.type === "non_standard" && isAnthropicMessage) result.push(block.value);
|
|
280
|
+
return result;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
//#endregion
|
|
284
|
+
exports._formatStandardContent = _formatStandardContent;
|
|
285
|
+
//# sourceMappingURL=standard.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standard.cjs","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[]","iife"],"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,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,SAAS,WAAW,OAAO;IAC3B,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,SAAS,WAAW,OAAO;IAC3B,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,SAAS,WAAW,OAAO;IAC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