@langchain/core 1.0.0-alpha.5 → 1.0.0-alpha.6
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/caches/base.d.cts.map +1 -1
- package/dist/caches/base.d.ts.map +1 -1
- package/dist/callbacks/base.d.cts.map +1 -1
- package/dist/callbacks/base.d.ts.map +1 -1
- package/dist/language_models/chat_models.d.cts.map +1 -1
- package/dist/messages/ai.cjs +4 -4
- package/dist/messages/ai.cjs.map +1 -1
- package/dist/messages/ai.js +4 -4
- package/dist/messages/ai.js.map +1 -1
- package/dist/messages/base.cjs +1 -1
- package/dist/messages/base.cjs.map +1 -1
- package/dist/messages/base.d.cts +2 -2
- package/dist/messages/base.d.cts.map +1 -1
- package/dist/messages/base.d.ts +2 -2
- package/dist/messages/base.d.ts.map +1 -1
- package/dist/messages/base.js +1 -1
- package/dist/messages/base.js.map +1 -1
- package/dist/messages/block_translators/bedrock_converse.cjs +213 -0
- package/dist/messages/block_translators/bedrock_converse.cjs.map +1 -0
- package/dist/messages/block_translators/bedrock_converse.js +213 -0
- package/dist/messages/block_translators/bedrock_converse.js.map +1 -0
- package/dist/messages/block_translators/google_genai.cjs +73 -0
- package/dist/messages/block_translators/google_genai.cjs.map +1 -0
- package/dist/messages/block_translators/google_genai.js +73 -0
- package/dist/messages/block_translators/google_genai.js.map +1 -0
- package/dist/messages/block_translators/google_vertexai.cjs +74 -0
- package/dist/messages/block_translators/google_vertexai.cjs.map +1 -0
- package/dist/messages/block_translators/google_vertexai.js +74 -0
- package/dist/messages/block_translators/google_vertexai.js.map +1 -0
- package/dist/messages/block_translators/index.cjs +10 -1
- package/dist/messages/block_translators/index.cjs.map +1 -1
- package/dist/messages/block_translators/index.js +10 -1
- package/dist/messages/block_translators/index.js.map +1 -1
- package/dist/messages/block_translators/utils.cjs +4 -0
- package/dist/messages/block_translators/utils.cjs.map +1 -1
- package/dist/messages/block_translators/utils.js +4 -1
- package/dist/messages/block_translators/utils.js.map +1 -1
- package/dist/messages/content/index.cjs.map +1 -1
- package/dist/messages/content/index.d.cts +20 -1
- package/dist/messages/content/index.d.cts.map +1 -1
- package/dist/messages/content/index.d.ts +20 -1
- package/dist/messages/content/index.d.ts.map +1 -1
- package/dist/messages/content/index.js.map +1 -1
- package/dist/messages/content/tools.cjs +3 -0
- package/dist/messages/content/tools.cjs.map +1 -1
- package/dist/messages/content/tools.d.cts +67 -6
- package/dist/messages/content/tools.d.cts.map +1 -1
- package/dist/messages/content/tools.d.ts +67 -6
- package/dist/messages/content/tools.d.ts.map +1 -1
- package/dist/messages/content/tools.js +3 -0
- package/dist/messages/content/tools.js.map +1 -1
- package/dist/messages/index.cjs +4 -0
- package/dist/messages/index.cjs.map +1 -1
- package/dist/messages/index.d.cts +2 -2
- package/dist/messages/index.d.ts +2 -2
- package/dist/messages/index.js +4 -2
- package/dist/messages/index.js.map +1 -1
- package/dist/messages/message.cjs.map +1 -1
- package/dist/messages/message.d.cts +6 -6
- package/dist/messages/message.d.cts.map +1 -1
- package/dist/messages/message.d.ts +6 -6
- package/dist/messages/message.d.ts.map +1 -1
- package/dist/messages/message.js.map +1 -1
- package/dist/messages/tool.cjs.map +1 -1
- package/dist/messages/tool.d.cts +3 -1
- package/dist/messages/tool.d.cts.map +1 -1
- package/dist/messages/tool.d.ts +3 -1
- package/dist/messages/tool.d.ts.map +1 -1
- package/dist/messages/tool.js.map +1 -1
- package/dist/utils/types/index.cjs +2 -0
- package/dist/utils/types/index.d.cts +2 -2
- package/dist/utils/types/index.d.ts +2 -2
- package/dist/utils/types/index.js +3 -2
- package/dist/utils/types/zod.cjs +39 -3
- package/dist/utils/types/zod.cjs.map +1 -1
- package/dist/utils/types/zod.d.cts +18 -1
- package/dist/utils/types/zod.d.cts.map +1 -1
- package/dist/utils/types/zod.d.ts +18 -1
- package/dist/utils/types/zod.d.ts.map +1 -1
- package/dist/utils/types/zod.js +39 -4
- package/dist/utils/types/zod.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google_genai.js","names":["message: AIMessage","ChatGoogleGenAITranslator: StandardContentBlockTranslator"],"sources":["../../../src/messages/block_translators/google_genai.ts"],"sourcesContent":["import { AIMessage } from \"../ai.js\";\nimport { ContentBlock } from \"../content/index.js\";\nimport type { StandardContentBlockTranslator } from \"./index.js\";\nimport { _isContentBlock, _isObject, _isString } from \"./utils.js\";\n\nfunction convertToV1FromChatGoogleMessage(\n message: AIMessage\n): Array<ContentBlock.Standard> {\n // see `libs/providers/langchain-google-genai/src/utils/common.ts:mapGenerateContentResultToChatResult\n function* iterateContent(): Iterable<ContentBlock.Standard> {\n const content =\n typeof message.content === \"string\"\n ? [{ type: \"text\", text: message.content }]\n : message.content;\n for (const block of content) {\n if (_isContentBlock(block, \"text\") && _isString(block.text)) {\n yield { type: \"text\", text: block.text };\n continue;\n } else if (\n _isContentBlock(block, \"inlineData\") &&\n _isObject(block.inlineData) &&\n _isString(block.inlineData.mimeType) &&\n _isString(block.inlineData.data)\n ) {\n yield {\n type: \"file\",\n mimeType: block.inlineData.mimeType,\n data: block.inlineData.data,\n };\n continue;\n } else if (\n _isContentBlock(block, \"functionCall\") &&\n _isObject(block.functionCall) &&\n _isString(block.functionCall.name) &&\n _isObject(block.functionCall.args)\n ) {\n yield {\n type: \"tool_call\",\n id: message.id,\n name: block.functionCall.name,\n args: block.functionCall.args,\n };\n continue;\n } else if (_isContentBlock(block, \"functionResponse\")) {\n yield { type: \"non_standard\", value: block };\n continue;\n } else if (\n _isContentBlock(block, \"fileData\") &&\n _isObject(block.fileData) &&\n _isString(block.fileData.mimeType) &&\n _isString(block.fileData.fileUri)\n ) {\n yield {\n type: \"file\",\n mimeType: block.fileData.mimeType,\n fileId: block.fileData.fileUri,\n };\n continue;\n } else if (_isContentBlock(block, \"executableCode\")) {\n yield { type: \"non_standard\", value: block };\n continue;\n } else if (_isContentBlock(block, \"codeExecutionResult\")) {\n yield { type: \"non_standard\", value: block };\n continue;\n }\n yield { type: \"non_standard\", value: block };\n }\n }\n return Array.from(iterateContent());\n}\n\nexport const ChatGoogleGenAITranslator: StandardContentBlockTranslator = {\n translateContent: convertToV1FromChatGoogleMessage,\n translateContentChunk: convertToV1FromChatGoogleMessage,\n};\n"],"mappings":";;;AAKA,SAAS,iCACPA,SAC8B;CAE9B,UAAU,iBAAkD;EAC1D,MAAM,UACJ,OAAO,QAAQ,YAAY,WACvB,CAAC;GAAE,MAAM;GAAQ,MAAM,QAAQ;EAAS,CAAC,IACzC,QAAQ;AACd,OAAK,MAAM,SAAS,SAAS;AAC3B,OAAI,gBAAgB,OAAO,OAAO,IAAI,UAAU,MAAM,KAAK,EAAE;IAC3D,MAAM;KAAE,MAAM;KAAQ,MAAM,MAAM;IAAM;AACxC;GACD,WACC,gBAAgB,OAAO,aAAa,IACpC,UAAU,MAAM,WAAW,IAC3B,UAAU,MAAM,WAAW,SAAS,IACpC,UAAU,MAAM,WAAW,KAAK,EAChC;IACA,MAAM;KACJ,MAAM;KACN,UAAU,MAAM,WAAW;KAC3B,MAAM,MAAM,WAAW;IACxB;AACD;GACD,WACC,gBAAgB,OAAO,eAAe,IACtC,UAAU,MAAM,aAAa,IAC7B,UAAU,MAAM,aAAa,KAAK,IAClC,UAAU,MAAM,aAAa,KAAK,EAClC;IACA,MAAM;KACJ,MAAM;KACN,IAAI,QAAQ;KACZ,MAAM,MAAM,aAAa;KACzB,MAAM,MAAM,aAAa;IAC1B;AACD;GACD,WAAU,gBAAgB,OAAO,mBAAmB,EAAE;IACrD,MAAM;KAAE,MAAM;KAAgB,OAAO;IAAO;AAC5C;GACD,WACC,gBAAgB,OAAO,WAAW,IAClC,UAAU,MAAM,SAAS,IACzB,UAAU,MAAM,SAAS,SAAS,IAClC,UAAU,MAAM,SAAS,QAAQ,EACjC;IACA,MAAM;KACJ,MAAM;KACN,UAAU,MAAM,SAAS;KACzB,QAAQ,MAAM,SAAS;IACxB;AACD;GACD,WAAU,gBAAgB,OAAO,iBAAiB,EAAE;IACnD,MAAM;KAAE,MAAM;KAAgB,OAAO;IAAO;AAC5C;GACD,WAAU,gBAAgB,OAAO,sBAAsB,EAAE;IACxD,MAAM;KAAE,MAAM;KAAgB,OAAO;IAAO;AAC5C;GACD;GACD,MAAM;IAAE,MAAM;IAAgB,OAAO;GAAO;EAC7C;CACF;AACD,QAAO,MAAM,KAAK,gBAAgB,CAAC;AACpC;AAED,MAAaC,4BAA4D;CACvE,kBAAkB;CAClB,uBAAuB;AACxB"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const require_utils = require('./utils.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/messages/block_translators/google_vertexai.ts
|
|
4
|
+
function convertToV1FromChatVertexMessage(message) {
|
|
5
|
+
function* iterateContent() {
|
|
6
|
+
const content = typeof message.content === "string" ? [{
|
|
7
|
+
type: "text",
|
|
8
|
+
text: message.content
|
|
9
|
+
}] : message.content;
|
|
10
|
+
for (const block of content) {
|
|
11
|
+
if (require_utils._isContentBlock(block, "reasoning") && require_utils._isString(block.reasoning)) {
|
|
12
|
+
const signature = require_utils.iife(() => {
|
|
13
|
+
const reasoningIndex = content.indexOf(block);
|
|
14
|
+
if (require_utils._isArray(message.additional_kwargs?.signatures) && reasoningIndex >= 0) return message.additional_kwargs.signatures.at(reasoningIndex);
|
|
15
|
+
return void 0;
|
|
16
|
+
});
|
|
17
|
+
if (require_utils._isString(signature)) yield {
|
|
18
|
+
type: "reasoning",
|
|
19
|
+
reasoning: block.reasoning,
|
|
20
|
+
signature
|
|
21
|
+
};
|
|
22
|
+
else yield {
|
|
23
|
+
type: "reasoning",
|
|
24
|
+
reasoning: block.reasoning
|
|
25
|
+
};
|
|
26
|
+
continue;
|
|
27
|
+
} else if (require_utils._isContentBlock(block, "text") && require_utils._isString(block.text)) {
|
|
28
|
+
yield {
|
|
29
|
+
type: "text",
|
|
30
|
+
text: block.text
|
|
31
|
+
};
|
|
32
|
+
continue;
|
|
33
|
+
} else if (require_utils._isContentBlock(block, "image_url")) {
|
|
34
|
+
if (require_utils._isString(block.image_url)) if (block.image_url.startsWith("data:")) {
|
|
35
|
+
const dataUrlRegex = /^data:([^;]+);base64,(.+)$/;
|
|
36
|
+
const match = block.image_url.match(dataUrlRegex);
|
|
37
|
+
if (match) yield {
|
|
38
|
+
type: "image",
|
|
39
|
+
data: match[2],
|
|
40
|
+
mimeType: match[1]
|
|
41
|
+
};
|
|
42
|
+
else yield {
|
|
43
|
+
type: "image",
|
|
44
|
+
url: block.image_url
|
|
45
|
+
};
|
|
46
|
+
} else yield {
|
|
47
|
+
type: "image",
|
|
48
|
+
url: block.image_url
|
|
49
|
+
};
|
|
50
|
+
continue;
|
|
51
|
+
} else if (require_utils._isContentBlock(block, "media") && require_utils._isString(block.mimeType) && require_utils._isString(block.data)) {
|
|
52
|
+
yield {
|
|
53
|
+
type: "file",
|
|
54
|
+
mimeType: block.mimeType,
|
|
55
|
+
data: block.data
|
|
56
|
+
};
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
yield {
|
|
60
|
+
type: "non_standard",
|
|
61
|
+
value: block
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return Array.from(iterateContent());
|
|
66
|
+
}
|
|
67
|
+
const ChatVertexTranslator = {
|
|
68
|
+
translateContent: convertToV1FromChatVertexMessage,
|
|
69
|
+
translateContentChunk: convertToV1FromChatVertexMessage
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
exports.ChatVertexTranslator = ChatVertexTranslator;
|
|
74
|
+
//# sourceMappingURL=google_vertexai.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google_vertexai.cjs","names":["message: AIMessage","_isContentBlock","_isString","iife","_isArray","ChatVertexTranslator: StandardContentBlockTranslator"],"sources":["../../../src/messages/block_translators/google_vertexai.ts"],"sourcesContent":["import { AIMessage } from \"../ai.js\";\nimport { ContentBlock } from \"../content/index.js\";\nimport type { StandardContentBlockTranslator } from \"./index.js\";\nimport { _isArray, _isContentBlock, _isString, iife } from \"./utils.js\";\n\nfunction convertToV1FromChatVertexMessage(\n message: AIMessage\n): Array<ContentBlock.Standard> {\n // see `/libs/providers/langchain-google-common/src/utils/gemini.ts:partsToMessageContent`\n function* iterateContent(): Iterable<ContentBlock.Standard> {\n const content =\n typeof message.content === \"string\"\n ? [{ type: \"text\", text: message.content }]\n : message.content;\n for (const block of content) {\n if (_isContentBlock(block, \"reasoning\") && _isString(block.reasoning)) {\n const signature = iife(() => {\n const reasoningIndex = content.indexOf(block);\n if (\n _isArray(message.additional_kwargs?.signatures) &&\n reasoningIndex >= 0\n ) {\n return message.additional_kwargs.signatures.at(reasoningIndex);\n }\n return undefined;\n });\n if (_isString(signature)) {\n yield {\n type: \"reasoning\",\n reasoning: block.reasoning,\n signature,\n };\n } else {\n yield {\n type: \"reasoning\",\n reasoning: block.reasoning,\n };\n }\n continue;\n } else if (_isContentBlock(block, \"text\") && _isString(block.text)) {\n yield { type: \"text\", text: block.text };\n continue;\n } else if (_isContentBlock(block, \"image_url\")) {\n if (_isString(block.image_url)) {\n if (block.image_url.startsWith(\"data:\")) {\n const dataUrlRegex = /^data:([^;]+);base64,(.+)$/;\n const match = block.image_url.match(dataUrlRegex);\n if (match) {\n yield { type: \"image\", data: match[2], mimeType: match[1] };\n } else {\n yield { type: \"image\", url: block.image_url };\n }\n } else {\n yield { type: \"image\", url: block.image_url };\n }\n }\n continue;\n } else if (\n _isContentBlock(block, \"media\") &&\n _isString(block.mimeType) &&\n _isString(block.data)\n ) {\n yield { type: \"file\", mimeType: block.mimeType, data: block.data };\n continue;\n }\n yield { type: \"non_standard\", value: block };\n }\n }\n return Array.from(iterateContent());\n}\n\nexport const ChatVertexTranslator: StandardContentBlockTranslator = {\n translateContent: convertToV1FromChatVertexMessage,\n translateContentChunk: convertToV1FromChatVertexMessage,\n};\n"],"mappings":";;;AAKA,SAAS,iCACPA,SAC8B;CAE9B,UAAU,iBAAkD;EAC1D,MAAM,UACJ,OAAO,QAAQ,YAAY,WACvB,CAAC;GAAE,MAAM;GAAQ,MAAM,QAAQ;EAAS,CAAC,IACzC,QAAQ;AACd,OAAK,MAAM,SAAS,SAAS;AAC3B,OAAIC,8BAAgB,OAAO,YAAY,IAAIC,wBAAU,MAAM,UAAU,EAAE;IACrE,MAAM,YAAYC,mBAAK,MAAM;KAC3B,MAAM,iBAAiB,QAAQ,QAAQ,MAAM;AAC7C,SACEC,uBAAS,QAAQ,mBAAmB,WAAW,IAC/C,kBAAkB,EAElB,QAAO,QAAQ,kBAAkB,WAAW,GAAG,eAAe;AAEhE,YAAO;IACR,EAAC;AACF,QAAIF,wBAAU,UAAU,EACtB,MAAM;KACJ,MAAM;KACN,WAAW,MAAM;KACjB;IACD;SAED,MAAM;KACJ,MAAM;KACN,WAAW,MAAM;IAClB;AAEH;GACD,WAAUD,8BAAgB,OAAO,OAAO,IAAIC,wBAAU,MAAM,KAAK,EAAE;IAClE,MAAM;KAAE,MAAM;KAAQ,MAAM,MAAM;IAAM;AACxC;GACD,WAAUD,8BAAgB,OAAO,YAAY,EAAE;AAC9C,QAAIC,wBAAU,MAAM,UAAU,CAC5B,KAAI,MAAM,UAAU,WAAW,QAAQ,EAAE;KACvC,MAAM,eAAe;KACrB,MAAM,QAAQ,MAAM,UAAU,MAAM,aAAa;AACjD,SAAI,OACF,MAAM;MAAE,MAAM;MAAS,MAAM,MAAM;MAAI,UAAU,MAAM;KAAI;UAE3D,MAAM;MAAE,MAAM;MAAS,KAAK,MAAM;KAAW;IAEhD,OACC,MAAM;KAAE,MAAM;KAAS,KAAK,MAAM;IAAW;AAGjD;GACD,WACCD,8BAAgB,OAAO,QAAQ,IAC/BC,wBAAU,MAAM,SAAS,IACzBA,wBAAU,MAAM,KAAK,EACrB;IACA,MAAM;KAAE,MAAM;KAAQ,UAAU,MAAM;KAAU,MAAM,MAAM;IAAM;AAClE;GACD;GACD,MAAM;IAAE,MAAM;IAAgB,OAAO;GAAO;EAC7C;CACF;AACD,QAAO,MAAM,KAAK,gBAAgB,CAAC;AACpC;AAED,MAAaG,uBAAuD;CAClE,kBAAkB;CAClB,uBAAuB;AACxB"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { _isArray, _isContentBlock, _isString, iife } from "./utils.js";
|
|
2
|
+
|
|
3
|
+
//#region src/messages/block_translators/google_vertexai.ts
|
|
4
|
+
function convertToV1FromChatVertexMessage(message) {
|
|
5
|
+
function* iterateContent() {
|
|
6
|
+
const content = typeof message.content === "string" ? [{
|
|
7
|
+
type: "text",
|
|
8
|
+
text: message.content
|
|
9
|
+
}] : message.content;
|
|
10
|
+
for (const block of content) {
|
|
11
|
+
if (_isContentBlock(block, "reasoning") && _isString(block.reasoning)) {
|
|
12
|
+
const signature = iife(() => {
|
|
13
|
+
const reasoningIndex = content.indexOf(block);
|
|
14
|
+
if (_isArray(message.additional_kwargs?.signatures) && reasoningIndex >= 0) return message.additional_kwargs.signatures.at(reasoningIndex);
|
|
15
|
+
return void 0;
|
|
16
|
+
});
|
|
17
|
+
if (_isString(signature)) yield {
|
|
18
|
+
type: "reasoning",
|
|
19
|
+
reasoning: block.reasoning,
|
|
20
|
+
signature
|
|
21
|
+
};
|
|
22
|
+
else yield {
|
|
23
|
+
type: "reasoning",
|
|
24
|
+
reasoning: block.reasoning
|
|
25
|
+
};
|
|
26
|
+
continue;
|
|
27
|
+
} else if (_isContentBlock(block, "text") && _isString(block.text)) {
|
|
28
|
+
yield {
|
|
29
|
+
type: "text",
|
|
30
|
+
text: block.text
|
|
31
|
+
};
|
|
32
|
+
continue;
|
|
33
|
+
} else if (_isContentBlock(block, "image_url")) {
|
|
34
|
+
if (_isString(block.image_url)) if (block.image_url.startsWith("data:")) {
|
|
35
|
+
const dataUrlRegex = /^data:([^;]+);base64,(.+)$/;
|
|
36
|
+
const match = block.image_url.match(dataUrlRegex);
|
|
37
|
+
if (match) yield {
|
|
38
|
+
type: "image",
|
|
39
|
+
data: match[2],
|
|
40
|
+
mimeType: match[1]
|
|
41
|
+
};
|
|
42
|
+
else yield {
|
|
43
|
+
type: "image",
|
|
44
|
+
url: block.image_url
|
|
45
|
+
};
|
|
46
|
+
} else yield {
|
|
47
|
+
type: "image",
|
|
48
|
+
url: block.image_url
|
|
49
|
+
};
|
|
50
|
+
continue;
|
|
51
|
+
} else if (_isContentBlock(block, "media") && _isString(block.mimeType) && _isString(block.data)) {
|
|
52
|
+
yield {
|
|
53
|
+
type: "file",
|
|
54
|
+
mimeType: block.mimeType,
|
|
55
|
+
data: block.data
|
|
56
|
+
};
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
yield {
|
|
60
|
+
type: "non_standard",
|
|
61
|
+
value: block
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return Array.from(iterateContent());
|
|
66
|
+
}
|
|
67
|
+
const ChatVertexTranslator = {
|
|
68
|
+
translateContent: convertToV1FromChatVertexMessage,
|
|
69
|
+
translateContentChunk: convertToV1FromChatVertexMessage
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
export { ChatVertexTranslator };
|
|
74
|
+
//# sourceMappingURL=google_vertexai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google_vertexai.js","names":["message: AIMessage","ChatVertexTranslator: StandardContentBlockTranslator"],"sources":["../../../src/messages/block_translators/google_vertexai.ts"],"sourcesContent":["import { AIMessage } from \"../ai.js\";\nimport { ContentBlock } from \"../content/index.js\";\nimport type { StandardContentBlockTranslator } from \"./index.js\";\nimport { _isArray, _isContentBlock, _isString, iife } from \"./utils.js\";\n\nfunction convertToV1FromChatVertexMessage(\n message: AIMessage\n): Array<ContentBlock.Standard> {\n // see `/libs/providers/langchain-google-common/src/utils/gemini.ts:partsToMessageContent`\n function* iterateContent(): Iterable<ContentBlock.Standard> {\n const content =\n typeof message.content === \"string\"\n ? [{ type: \"text\", text: message.content }]\n : message.content;\n for (const block of content) {\n if (_isContentBlock(block, \"reasoning\") && _isString(block.reasoning)) {\n const signature = iife(() => {\n const reasoningIndex = content.indexOf(block);\n if (\n _isArray(message.additional_kwargs?.signatures) &&\n reasoningIndex >= 0\n ) {\n return message.additional_kwargs.signatures.at(reasoningIndex);\n }\n return undefined;\n });\n if (_isString(signature)) {\n yield {\n type: \"reasoning\",\n reasoning: block.reasoning,\n signature,\n };\n } else {\n yield {\n type: \"reasoning\",\n reasoning: block.reasoning,\n };\n }\n continue;\n } else if (_isContentBlock(block, \"text\") && _isString(block.text)) {\n yield { type: \"text\", text: block.text };\n continue;\n } else if (_isContentBlock(block, \"image_url\")) {\n if (_isString(block.image_url)) {\n if (block.image_url.startsWith(\"data:\")) {\n const dataUrlRegex = /^data:([^;]+);base64,(.+)$/;\n const match = block.image_url.match(dataUrlRegex);\n if (match) {\n yield { type: \"image\", data: match[2], mimeType: match[1] };\n } else {\n yield { type: \"image\", url: block.image_url };\n }\n } else {\n yield { type: \"image\", url: block.image_url };\n }\n }\n continue;\n } else if (\n _isContentBlock(block, \"media\") &&\n _isString(block.mimeType) &&\n _isString(block.data)\n ) {\n yield { type: \"file\", mimeType: block.mimeType, data: block.data };\n continue;\n }\n yield { type: \"non_standard\", value: block };\n }\n }\n return Array.from(iterateContent());\n}\n\nexport const ChatVertexTranslator: StandardContentBlockTranslator = {\n translateContent: convertToV1FromChatVertexMessage,\n translateContentChunk: convertToV1FromChatVertexMessage,\n};\n"],"mappings":";;;AAKA,SAAS,iCACPA,SAC8B;CAE9B,UAAU,iBAAkD;EAC1D,MAAM,UACJ,OAAO,QAAQ,YAAY,WACvB,CAAC;GAAE,MAAM;GAAQ,MAAM,QAAQ;EAAS,CAAC,IACzC,QAAQ;AACd,OAAK,MAAM,SAAS,SAAS;AAC3B,OAAI,gBAAgB,OAAO,YAAY,IAAI,UAAU,MAAM,UAAU,EAAE;IACrE,MAAM,YAAY,KAAK,MAAM;KAC3B,MAAM,iBAAiB,QAAQ,QAAQ,MAAM;AAC7C,SACE,SAAS,QAAQ,mBAAmB,WAAW,IAC/C,kBAAkB,EAElB,QAAO,QAAQ,kBAAkB,WAAW,GAAG,eAAe;AAEhE,YAAO;IACR,EAAC;AACF,QAAI,UAAU,UAAU,EACtB,MAAM;KACJ,MAAM;KACN,WAAW,MAAM;KACjB;IACD;SAED,MAAM;KACJ,MAAM;KACN,WAAW,MAAM;IAClB;AAEH;GACD,WAAU,gBAAgB,OAAO,OAAO,IAAI,UAAU,MAAM,KAAK,EAAE;IAClE,MAAM;KAAE,MAAM;KAAQ,MAAM,MAAM;IAAM;AACxC;GACD,WAAU,gBAAgB,OAAO,YAAY,EAAE;AAC9C,QAAI,UAAU,MAAM,UAAU,CAC5B,KAAI,MAAM,UAAU,WAAW,QAAQ,EAAE;KACvC,MAAM,eAAe;KACrB,MAAM,QAAQ,MAAM,UAAU,MAAM,aAAa;AACjD,SAAI,OACF,MAAM;MAAE,MAAM;MAAS,MAAM,MAAM;MAAI,UAAU,MAAM;KAAI;UAE3D,MAAM;MAAE,MAAM;MAAS,KAAK,MAAM;KAAW;IAEhD,OACC,MAAM;KAAE,MAAM;KAAS,KAAK,MAAM;IAAW;AAGjD;GACD,WACC,gBAAgB,OAAO,QAAQ,IAC/B,UAAU,MAAM,SAAS,IACzB,UAAU,MAAM,KAAK,EACrB;IACA,MAAM;KAAE,MAAM;KAAQ,UAAU,MAAM;KAAU,MAAM,MAAM;IAAM;AAClE;GACD;GACD,MAAM;IAAE,MAAM;IAAgB,OAAO;GAAO;EAC7C;CACF;AACD,QAAO,MAAM,KAAK,gBAAgB,CAAC;AACpC;AAED,MAAaC,uBAAuD;CAClE,kBAAkB;CAClB,uBAAuB;AACxB"}
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
const require_anthropic = require('./anthropic.cjs');
|
|
2
2
|
const require_openai = require('./openai.cjs');
|
|
3
|
+
const require_bedrock_converse = require('./bedrock_converse.cjs');
|
|
4
|
+
const require_google_genai = require('./google_genai.cjs');
|
|
5
|
+
const require_google_vertexai = require('./google_vertexai.cjs');
|
|
3
6
|
|
|
4
7
|
//#region src/messages/block_translators/index.ts
|
|
5
|
-
globalThis.lc_block_translators_registry ??= new Map([
|
|
8
|
+
globalThis.lc_block_translators_registry ??= new Map([
|
|
9
|
+
["anthropic", require_anthropic.anthropicTranslator],
|
|
10
|
+
["bedrock-converse", require_bedrock_converse.ChatBedrockConverseTranslator],
|
|
11
|
+
["google-genai", require_google_genai.ChatGoogleGenAITranslator],
|
|
12
|
+
["google-vertexai", require_google_vertexai.ChatVertexTranslator],
|
|
13
|
+
["openai", require_openai.openaiTranslator]
|
|
14
|
+
]);
|
|
6
15
|
function getTranslator(modelProvider) {
|
|
7
16
|
return globalThis.lc_block_translators_registry.get(modelProvider);
|
|
8
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["anthropicTranslator","openaiTranslator","modelProvider: string"],"sources":["../../../src/messages/block_translators/index.ts"],"sourcesContent":["import type { AIMessage, AIMessageChunk } from \"../ai.js\";\nimport type { ContentBlock } from \"../content/index.js\";\n\nimport { anthropicTranslator } from \"./anthropic.js\";\nimport { openaiTranslator } from \"./openai.js\";\n\nexport interface StandardContentBlockTranslator {\n translateContent(message: AIMessage): Array<ContentBlock.Standard>;\n translateContentChunk(chunk: AIMessageChunk): Array<ContentBlock.Standard>;\n}\n\ntype TranslatorRegistry = Map<string, StandardContentBlockTranslator>;\n\ndeclare global {\n
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["anthropicTranslator","ChatBedrockConverseTranslator","ChatGoogleGenAITranslator","ChatVertexTranslator","openaiTranslator","modelProvider: string"],"sources":["../../../src/messages/block_translators/index.ts"],"sourcesContent":["import type { AIMessage, AIMessageChunk } from \"../ai.js\";\nimport type { ContentBlock } from \"../content/index.js\";\n\nimport { anthropicTranslator } from \"./anthropic.js\";\nimport { ChatBedrockConverseTranslator } from \"./bedrock_converse.js\";\nimport { ChatGoogleGenAITranslator } from \"./google_genai.js\";\nimport { ChatVertexTranslator } from \"./google_vertexai.js\";\nimport { openaiTranslator } from \"./openai.js\";\n\nexport interface StandardContentBlockTranslator {\n translateContent(message: AIMessage): Array<ContentBlock.Standard>;\n translateContentChunk(chunk: AIMessageChunk): Array<ContentBlock.Standard>;\n}\n\ntype TranslatorRegistry = Map<string, StandardContentBlockTranslator>;\n\ndeclare global {\n var lc_block_translators_registry: TranslatorRegistry;\n}\n\nglobalThis.lc_block_translators_registry ??= new Map([\n [\"anthropic\", anthropicTranslator],\n [\"bedrock-converse\", ChatBedrockConverseTranslator],\n [\"google-genai\", ChatGoogleGenAITranslator],\n [\"google-vertexai\", ChatVertexTranslator],\n [\"openai\", openaiTranslator],\n]);\n\nexport function registerTranslator(\n modelProvider: string,\n translator: StandardContentBlockTranslator\n) {\n globalThis.lc_block_translators_registry.set(modelProvider, translator);\n}\n\nexport function getTranslator(\n modelProvider: string\n): StandardContentBlockTranslator | undefined {\n return globalThis.lc_block_translators_registry.get(modelProvider);\n}\n"],"mappings":";;;;;;;AAoBA,WAAW,kCAAkC,IAAI,IAAI;CACnD,CAAC,aAAaA,qCAAoB;CAClC,CAAC,oBAAoBC,sDAA8B;CACnD,CAAC,gBAAgBC,8CAA0B;CAC3C,CAAC,mBAAmBC,4CAAqB;CACzC,CAAC,UAAUC,+BAAiB;AAC7B;AASD,SAAgB,cACdC,eAC4C;AAC5C,QAAO,WAAW,8BAA8B,IAAI,cAAc;AACnE"}
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { anthropicTranslator } from "./anthropic.js";
|
|
2
2
|
import { openaiTranslator } from "./openai.js";
|
|
3
|
+
import { ChatBedrockConverseTranslator } from "./bedrock_converse.js";
|
|
4
|
+
import { ChatGoogleGenAITranslator } from "./google_genai.js";
|
|
5
|
+
import { ChatVertexTranslator } from "./google_vertexai.js";
|
|
3
6
|
|
|
4
7
|
//#region src/messages/block_translators/index.ts
|
|
5
|
-
globalThis.lc_block_translators_registry ??= new Map([
|
|
8
|
+
globalThis.lc_block_translators_registry ??= new Map([
|
|
9
|
+
["anthropic", anthropicTranslator],
|
|
10
|
+
["bedrock-converse", ChatBedrockConverseTranslator],
|
|
11
|
+
["google-genai", ChatGoogleGenAITranslator],
|
|
12
|
+
["google-vertexai", ChatVertexTranslator],
|
|
13
|
+
["openai", openaiTranslator]
|
|
14
|
+
]);
|
|
6
15
|
function getTranslator(modelProvider) {
|
|
7
16
|
return globalThis.lc_block_translators_registry.get(modelProvider);
|
|
8
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["modelProvider: string"],"sources":["../../../src/messages/block_translators/index.ts"],"sourcesContent":["import type { AIMessage, AIMessageChunk } from \"../ai.js\";\nimport type { ContentBlock } from \"../content/index.js\";\n\nimport { anthropicTranslator } from \"./anthropic.js\";\nimport { openaiTranslator } from \"./openai.js\";\n\nexport interface StandardContentBlockTranslator {\n translateContent(message: AIMessage): Array<ContentBlock.Standard>;\n translateContentChunk(chunk: AIMessageChunk): Array<ContentBlock.Standard>;\n}\n\ntype TranslatorRegistry = Map<string, StandardContentBlockTranslator>;\n\ndeclare global {\n
|
|
1
|
+
{"version":3,"file":"index.js","names":["modelProvider: string"],"sources":["../../../src/messages/block_translators/index.ts"],"sourcesContent":["import type { AIMessage, AIMessageChunk } from \"../ai.js\";\nimport type { ContentBlock } from \"../content/index.js\";\n\nimport { anthropicTranslator } from \"./anthropic.js\";\nimport { ChatBedrockConverseTranslator } from \"./bedrock_converse.js\";\nimport { ChatGoogleGenAITranslator } from \"./google_genai.js\";\nimport { ChatVertexTranslator } from \"./google_vertexai.js\";\nimport { openaiTranslator } from \"./openai.js\";\n\nexport interface StandardContentBlockTranslator {\n translateContent(message: AIMessage): Array<ContentBlock.Standard>;\n translateContentChunk(chunk: AIMessageChunk): Array<ContentBlock.Standard>;\n}\n\ntype TranslatorRegistry = Map<string, StandardContentBlockTranslator>;\n\ndeclare global {\n var lc_block_translators_registry: TranslatorRegistry;\n}\n\nglobalThis.lc_block_translators_registry ??= new Map([\n [\"anthropic\", anthropicTranslator],\n [\"bedrock-converse\", ChatBedrockConverseTranslator],\n [\"google-genai\", ChatGoogleGenAITranslator],\n [\"google-vertexai\", ChatVertexTranslator],\n [\"openai\", openaiTranslator],\n]);\n\nexport function registerTranslator(\n modelProvider: string,\n translator: StandardContentBlockTranslator\n) {\n globalThis.lc_block_translators_registry.set(modelProvider, translator);\n}\n\nexport function getTranslator(\n modelProvider: string\n): StandardContentBlockTranslator | undefined {\n return globalThis.lc_block_translators_registry.get(modelProvider);\n}\n"],"mappings":";;;;;;;AAoBA,WAAW,kCAAkC,IAAI,IAAI;CACnD,CAAC,aAAa,mBAAoB;CAClC,CAAC,oBAAoB,6BAA8B;CACnD,CAAC,gBAAgB,yBAA0B;CAC3C,CAAC,mBAAmB,oBAAqB;CACzC,CAAC,UAAU,gBAAiB;AAC7B;AASD,SAAgB,cACdA,eAC4C;AAC5C,QAAO,WAAW,8BAA8B,IAAI,cAAc;AACnE"}
|
|
@@ -15,6 +15,9 @@ function _isString(value) {
|
|
|
15
15
|
function _isNumber(value) {
|
|
16
16
|
return typeof value === "number";
|
|
17
17
|
}
|
|
18
|
+
function _isBytesArray(value) {
|
|
19
|
+
return value instanceof Uint8Array;
|
|
20
|
+
}
|
|
18
21
|
function safeParseJson(value) {
|
|
19
22
|
try {
|
|
20
23
|
return JSON.parse(value);
|
|
@@ -26,6 +29,7 @@ const iife = (fn) => fn();
|
|
|
26
29
|
|
|
27
30
|
//#endregion
|
|
28
31
|
exports._isArray = _isArray;
|
|
32
|
+
exports._isBytesArray = _isBytesArray;
|
|
29
33
|
exports._isContentBlock = _isContentBlock;
|
|
30
34
|
exports._isNumber = _isNumber;
|
|
31
35
|
exports._isObject = _isObject;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","names":["block: unknown","type: T","value: unknown","value: string","fn: () => T"],"sources":["../../../src/messages/block_translators/utils.ts"],"sourcesContent":["import type { ContentBlock } from \"../content/index.js\";\n\nexport function _isContentBlock<T extends string>(\n block: unknown,\n type: T\n): block is ContentBlock & { type: T } {\n return _isObject(block) && block.type === type;\n}\n\nexport function _isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\nexport function _isArray<T>(value: unknown): value is T[] {\n return Array.isArray(value);\n}\n\nexport function _isString(value: unknown): value is string {\n return typeof value === \"string\";\n}\n\nexport function _isNumber(value: unknown): value is number {\n return typeof value === \"number\";\n}\n\nexport function safeParseJson<T = unknown>(value: string): T | undefined {\n try {\n return JSON.parse(value);\n } catch {\n return undefined;\n }\n}\n\nexport const iife = <T>(fn: () => T): T => fn();\n"],"mappings":";;AAEA,SAAgB,gBACdA,OACAC,MACqC;AACrC,QAAO,UAAU,MAAM,IAAI,MAAM,SAAS;AAC3C;AAED,SAAgB,UAAUC,OAAkD;AAC1E,QAAO,OAAO,UAAU,YAAY,UAAU;AAC/C;AAED,SAAgB,SAAYA,OAA8B;AACxD,QAAO,MAAM,QAAQ,MAAM;AAC5B;AAED,SAAgB,UAAUA,OAAiC;AACzD,QAAO,OAAO,UAAU;AACzB;AAED,SAAgB,UAAUA,OAAiC;AACzD,QAAO,OAAO,UAAU;AACzB;AAED,SAAgB,cAA2BC,OAA8B;AACvE,KAAI;AACF,SAAO,KAAK,MAAM,MAAM;CACzB,QAAO;AACN,SAAO;CACR;AACF;AAED,MAAa,OAAO,CAAIC,OAAmB,IAAI"}
|
|
1
|
+
{"version":3,"file":"utils.cjs","names":["block: unknown","type: T","value: unknown","value: string","fn: () => T"],"sources":["../../../src/messages/block_translators/utils.ts"],"sourcesContent":["import type { ContentBlock } from \"../content/index.js\";\n\nexport function _isContentBlock<T extends string>(\n block: unknown,\n type: T\n): block is ContentBlock & { type: T } {\n return _isObject(block) && block.type === type;\n}\n\nexport function _isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\nexport function _isArray<T>(value: unknown): value is T[] {\n return Array.isArray(value);\n}\n\nexport function _isString(value: unknown): value is string {\n return typeof value === \"string\";\n}\n\nexport function _isNumber(value: unknown): value is number {\n return typeof value === \"number\";\n}\n\nexport function _isBytesArray(value: unknown): value is Uint8Array {\n // eslint-disable-next-line no-instanceof/no-instanceof\n return value instanceof Uint8Array;\n}\n\nexport function safeParseJson<T = unknown>(value: string): T | undefined {\n try {\n return JSON.parse(value);\n } catch {\n return undefined;\n }\n}\n\nexport const iife = <T>(fn: () => T): T => fn();\n"],"mappings":";;AAEA,SAAgB,gBACdA,OACAC,MACqC;AACrC,QAAO,UAAU,MAAM,IAAI,MAAM,SAAS;AAC3C;AAED,SAAgB,UAAUC,OAAkD;AAC1E,QAAO,OAAO,UAAU,YAAY,UAAU;AAC/C;AAED,SAAgB,SAAYA,OAA8B;AACxD,QAAO,MAAM,QAAQ,MAAM;AAC5B;AAED,SAAgB,UAAUA,OAAiC;AACzD,QAAO,OAAO,UAAU;AACzB;AAED,SAAgB,UAAUA,OAAiC;AACzD,QAAO,OAAO,UAAU;AACzB;AAED,SAAgB,cAAcA,OAAqC;AAEjE,QAAO,iBAAiB;AACzB;AAED,SAAgB,cAA2BC,OAA8B;AACvE,KAAI;AACF,SAAO,KAAK,MAAM,MAAM;CACzB,QAAO;AACN,SAAO;CACR;AACF;AAED,MAAa,OAAO,CAAIC,OAAmB,IAAI"}
|
|
@@ -14,6 +14,9 @@ function _isString(value) {
|
|
|
14
14
|
function _isNumber(value) {
|
|
15
15
|
return typeof value === "number";
|
|
16
16
|
}
|
|
17
|
+
function _isBytesArray(value) {
|
|
18
|
+
return value instanceof Uint8Array;
|
|
19
|
+
}
|
|
17
20
|
function safeParseJson(value) {
|
|
18
21
|
try {
|
|
19
22
|
return JSON.parse(value);
|
|
@@ -24,5 +27,5 @@ function safeParseJson(value) {
|
|
|
24
27
|
const iife = (fn) => fn();
|
|
25
28
|
|
|
26
29
|
//#endregion
|
|
27
|
-
export { _isArray, _isContentBlock, _isNumber, _isObject, _isString, iife, safeParseJson };
|
|
30
|
+
export { _isArray, _isBytesArray, _isContentBlock, _isNumber, _isObject, _isString, iife, safeParseJson };
|
|
28
31
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["block: unknown","type: T","value: unknown","value: string","fn: () => T"],"sources":["../../../src/messages/block_translators/utils.ts"],"sourcesContent":["import type { ContentBlock } from \"../content/index.js\";\n\nexport function _isContentBlock<T extends string>(\n block: unknown,\n type: T\n): block is ContentBlock & { type: T } {\n return _isObject(block) && block.type === type;\n}\n\nexport function _isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\nexport function _isArray<T>(value: unknown): value is T[] {\n return Array.isArray(value);\n}\n\nexport function _isString(value: unknown): value is string {\n return typeof value === \"string\";\n}\n\nexport function _isNumber(value: unknown): value is number {\n return typeof value === \"number\";\n}\n\nexport function safeParseJson<T = unknown>(value: string): T | undefined {\n try {\n return JSON.parse(value);\n } catch {\n return undefined;\n }\n}\n\nexport const iife = <T>(fn: () => T): T => fn();\n"],"mappings":";AAEA,SAAgB,gBACdA,OACAC,MACqC;AACrC,QAAO,UAAU,MAAM,IAAI,MAAM,SAAS;AAC3C;AAED,SAAgB,UAAUC,OAAkD;AAC1E,QAAO,OAAO,UAAU,YAAY,UAAU;AAC/C;AAED,SAAgB,SAAYA,OAA8B;AACxD,QAAO,MAAM,QAAQ,MAAM;AAC5B;AAED,SAAgB,UAAUA,OAAiC;AACzD,QAAO,OAAO,UAAU;AACzB;AAED,SAAgB,UAAUA,OAAiC;AACzD,QAAO,OAAO,UAAU;AACzB;AAED,SAAgB,cAA2BC,OAA8B;AACvE,KAAI;AACF,SAAO,KAAK,MAAM,MAAM;CACzB,QAAO;AACN,SAAO;CACR;AACF;AAED,MAAa,OAAO,CAAIC,OAAmB,IAAI"}
|
|
1
|
+
{"version":3,"file":"utils.js","names":["block: unknown","type: T","value: unknown","value: string","fn: () => T"],"sources":["../../../src/messages/block_translators/utils.ts"],"sourcesContent":["import type { ContentBlock } from \"../content/index.js\";\n\nexport function _isContentBlock<T extends string>(\n block: unknown,\n type: T\n): block is ContentBlock & { type: T } {\n return _isObject(block) && block.type === type;\n}\n\nexport function _isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\nexport function _isArray<T>(value: unknown): value is T[] {\n return Array.isArray(value);\n}\n\nexport function _isString(value: unknown): value is string {\n return typeof value === \"string\";\n}\n\nexport function _isNumber(value: unknown): value is number {\n return typeof value === \"number\";\n}\n\nexport function _isBytesArray(value: unknown): value is Uint8Array {\n // eslint-disable-next-line no-instanceof/no-instanceof\n return value instanceof Uint8Array;\n}\n\nexport function safeParseJson<T = unknown>(value: string): T | undefined {\n try {\n return JSON.parse(value);\n } catch {\n return undefined;\n }\n}\n\nexport const iife = <T>(fn: () => T): T => fn();\n"],"mappings":";AAEA,SAAgB,gBACdA,OACAC,MACqC;AACrC,QAAO,UAAU,MAAM,IAAI,MAAM,SAAS;AAC3C;AAED,SAAgB,UAAUC,OAAkD;AAC1E,QAAO,OAAO,UAAU,YAAY,UAAU;AAC/C;AAED,SAAgB,SAAYA,OAA8B;AACxD,QAAO,MAAM,QAAQ,MAAM;AAC5B;AAED,SAAgB,UAAUA,OAAiC;AACzD,QAAO,OAAO,UAAU;AACzB;AAED,SAAgB,UAAUA,OAAiC;AACzD,QAAO,OAAO,UAAU;AACzB;AAED,SAAgB,cAAcA,OAAqC;AAEjE,QAAO,iBAAiB;AACzB;AAED,SAAgB,cAA2BC,OAA8B;AACvE,KAAI;AACF,SAAO,KAAK,MAAM,MAAM;CACzB,QAAO;AACN,SAAO;CACR;AACF;AAED,MAAa,OAAO,CAAIC,OAAmB,IAAI"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["KNOWN_BLOCK_TYPES","KNOWN_TOOL_BLOCK_TYPES","KNOWN_MULTIMODAL_BLOCK_TYPES"],"sources":["../../../src/messages/content/index.ts"],"sourcesContent":["import type { BaseContentBlock } from \"./base.js\";\nimport {\n KNOWN_BLOCK_TYPES as KNOWN_TOOL_BLOCK_TYPES,\n type Tools,\n} from \"./tools.js\";\nimport {\n KNOWN_BLOCK_TYPES as KNOWN_MULTIMODAL_BLOCK_TYPES,\n type Multimodal,\n} from \"./multimodal.js\";\nimport { type Data } from \"./data.js\";\n\nexport interface ContentBlock extends BaseContentBlock {}\n\nexport const KNOWN_BLOCK_TYPES = [\n \"text\",\n \"reasoning\",\n ...KNOWN_TOOL_BLOCK_TYPES,\n ...KNOWN_MULTIMODAL_BLOCK_TYPES,\n];\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport declare namespace ContentBlock {\n /**\n * Annotation for citing data from a document.\n */\n export interface Citation {\n /**\n * Type of the content block\n */\n readonly type: \"citation\";\n /**\n * Source type for the citation.\n */\n source?: string;\n /**\n * URL of the document source\n */\n url?: string;\n /**\n * Source document title.\n *\n * For example, the page title for a web page or the title of a paper.\n */\n title?: string;\n /**\n * Start index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n startIndex?: number;\n /**\n * End index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n endIndex?: number;\n /**\n * Excerpt of source text being cited.\n */\n citedText?: string;\n }\n\n /**\n * Text output from a LLM.\n *\n * This typically represents the main text content of a message, such as the response\n * from a language model or the text of a user message.\n */\n export interface Text extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"text\";\n /**\n * Block text.\n */\n text: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: number;\n /**\n * Citations and other annotations.\n */\n annotations?: Array<Citation | BaseContentBlock>;\n }\n\n /**\n * Reasoning output from a LLM.\n */\n export interface Reasoning extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"reasoning\";\n /**\n * Reasoning text.\n *\n * Either the thought summary or the raw reasoning text itself.\n * This is often parsed from `<think>` tags in the model's response.\n */\n reasoning: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: number;\n }\n\n export { Tools };\n export { Multimodal };\n export { Data };\n\n export type Standard =\n | Text\n | Reasoning\n | Tools.Standard\n | Multimodal.Standard;\n}\n"],"mappings":";;;;AAaA,MAAaA,sBAAoB;CAC/B;CACA;CACA,GAAGC;CACH,GAAGC;AACJ"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["KNOWN_BLOCK_TYPES","KNOWN_TOOL_BLOCK_TYPES","KNOWN_MULTIMODAL_BLOCK_TYPES"],"sources":["../../../src/messages/content/index.ts"],"sourcesContent":["import type { BaseContentBlock } from \"./base.js\";\nimport {\n KNOWN_BLOCK_TYPES as KNOWN_TOOL_BLOCK_TYPES,\n type Tools,\n} from \"./tools.js\";\nimport {\n KNOWN_BLOCK_TYPES as KNOWN_MULTIMODAL_BLOCK_TYPES,\n type Multimodal,\n} from \"./multimodal.js\";\nimport { type Data } from \"./data.js\";\n\nexport interface ContentBlock extends BaseContentBlock {}\n\nexport const KNOWN_BLOCK_TYPES = [\n \"text\",\n \"reasoning\",\n ...KNOWN_TOOL_BLOCK_TYPES,\n ...KNOWN_MULTIMODAL_BLOCK_TYPES,\n];\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport declare namespace ContentBlock {\n /**\n * Annotation for citing data from a document.\n */\n export interface Citation {\n /**\n * Type of the content block\n */\n readonly type: \"citation\";\n /**\n * Source type for the citation.\n */\n source?: string;\n /**\n * URL of the document source\n */\n url?: string;\n /**\n * Source document title.\n *\n * For example, the page title for a web page or the title of a paper.\n */\n title?: string;\n /**\n * Start index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n startIndex?: number;\n /**\n * End index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n endIndex?: number;\n /**\n * Excerpt of source text being cited.\n */\n citedText?: string;\n }\n\n /**\n * Text output from a LLM.\n *\n * This typically represents the main text content of a message, such as the response\n * from a language model or the text of a user message.\n */\n export interface Text extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"text\";\n /**\n * Block text.\n */\n text: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: number;\n /**\n * Citations and other annotations.\n */\n annotations?: Array<Citation | BaseContentBlock>;\n }\n\n /**\n * Reasoning output from a LLM.\n */\n export interface Reasoning extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"reasoning\";\n /**\n * Reasoning text.\n *\n * Either the thought summary or the raw reasoning text itself.\n * This is often parsed from `<think>` tags in the model's response.\n */\n reasoning: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: number;\n }\n\n /**\n * Provider-specific content block.\n *\n * This is used to represent content blocks that are not part of the standard LangChain content model.\n * If a provider's non-standard output includes reasoning and tool calls, it should be\n * the adapter's job to parse that payload and emit the corresponding standard reasoning and tool call blocks.\n */\n export interface NonStandard<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TValue extends Record<string, any> = Record<string, any>\n > extends ContentBlock {\n /**\n * Type of the content block\n */\n type: \"non_standard\";\n /**\n * Provider-specific data\n */\n value: TValue;\n }\n\n export { Tools };\n export { Multimodal };\n export { Data };\n\n export type Standard =\n | Text\n | Reasoning\n | NonStandard\n | Tools.Standard\n | Multimodal.Standard;\n}\n"],"mappings":";;;;AAaA,MAAaA,sBAAoB;CAC/B;CACA;CACA,GAAGC;CACH,GAAGC;AACJ"}
|
|
@@ -91,10 +91,29 @@ declare namespace ContentBlock {
|
|
|
91
91
|
*/
|
|
92
92
|
index?: number;
|
|
93
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* Provider-specific content block.
|
|
96
|
+
*
|
|
97
|
+
* This is used to represent content blocks that are not part of the standard LangChain content model.
|
|
98
|
+
* If a provider's non-standard output includes reasoning and tool calls, it should be
|
|
99
|
+
* the adapter's job to parse that payload and emit the corresponding standard reasoning and tool call blocks.
|
|
100
|
+
*/
|
|
101
|
+
export interface NonStandard<
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
103
|
+
TValue extends Record<string, any> = Record<string, any>> extends ContentBlock {
|
|
104
|
+
/**
|
|
105
|
+
* Type of the content block
|
|
106
|
+
*/
|
|
107
|
+
type: "non_standard";
|
|
108
|
+
/**
|
|
109
|
+
* Provider-specific data
|
|
110
|
+
*/
|
|
111
|
+
value: TValue;
|
|
112
|
+
}
|
|
94
113
|
export { Tools };
|
|
95
114
|
export { Multimodal };
|
|
96
115
|
export { Data };
|
|
97
|
-
export type Standard = Text | Reasoning | Tools.Standard | Multimodal.Standard;
|
|
116
|
+
export type Standard = Text | Reasoning | NonStandard | Tools.Standard | Multimodal.Standard;
|
|
98
117
|
}
|
|
99
118
|
//#endregion
|
|
100
119
|
export { ContentBlock, KNOWN_BLOCK_TYPES };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":["BaseContentBlock","Tools","Multimodal","Data","ContentBlock","KNOWN_BLOCK_TYPES","Citation","Array","Text","Reasoning","Standard"],"sources":["../../../src/messages/content/index.d.ts"],"sourcesContent":["import type { BaseContentBlock } from \"./base.js\";\nimport { type Tools } from \"./tools.js\";\nimport { type Multimodal } from \"./multimodal.js\";\nimport { type Data } from \"./data.js\";\nexport interface ContentBlock extends BaseContentBlock {\n}\nexport declare const KNOWN_BLOCK_TYPES: string[];\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport declare namespace ContentBlock {\n /**\n * Annotation for citing data from a document.\n */\n export interface Citation {\n /**\n * Type of the content block\n */\n readonly type: \"citation\";\n /**\n * Source type for the citation.\n */\n source?: string;\n /**\n * URL of the document source\n */\n url?: string;\n /**\n * Source document title.\n *\n * For example, the page title for a web page or the title of a paper.\n */\n title?: string;\n /**\n * Start index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n startIndex?: number;\n /**\n * End index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n endIndex?: number;\n /**\n * Excerpt of source text being cited.\n */\n citedText?: string;\n }\n /**\n * Text output from a LLM.\n *\n * This typically represents the main text content of a message, such as the response\n * from a language model or the text of a user message.\n */\n export interface Text extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"text\";\n /**\n * Block text.\n */\n text: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: number;\n /**\n * Citations and other annotations.\n */\n annotations?: Array<Citation | BaseContentBlock>;\n }\n /**\n * Reasoning output from a LLM.\n */\n export interface Reasoning extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"reasoning\";\n /**\n * Reasoning text.\n *\n * Either the thought summary or the raw reasoning text itself.\n * This is often parsed from `<think>` tags in the model's response.\n */\n reasoning: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: number;\n }\n export { Tools };\n export { Multimodal };\n export { Data };\n export type Standard = Text | Reasoning | Tools.Standard | Multimodal.Standard;\n}\n"],"mappings":";;;;;;UAIiBI,YAAAA,SAAqBJ;AAArBI,cAEIC,iBAFiBL,EAAAA,MAAAA,EAAgB;AAEtD;AAEyBI,kBAAAA,YAAAA,CAAY;EAAA;;;EA8DkB,OAAjCG,UAAAA,QAAAA,CAAAA;IAhBYH;;;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":["BaseContentBlock","Tools","Multimodal","Data","ContentBlock","KNOWN_BLOCK_TYPES","Citation","Array","Record","TValue","Text","Reasoning","NonStandard","Standard"],"sources":["../../../src/messages/content/index.d.ts"],"sourcesContent":["import type { BaseContentBlock } from \"./base.js\";\nimport { type Tools } from \"./tools.js\";\nimport { type Multimodal } from \"./multimodal.js\";\nimport { type Data } from \"./data.js\";\nexport interface ContentBlock extends BaseContentBlock {\n}\nexport declare const KNOWN_BLOCK_TYPES: string[];\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport declare namespace ContentBlock {\n /**\n * Annotation for citing data from a document.\n */\n export interface Citation {\n /**\n * Type of the content block\n */\n readonly type: \"citation\";\n /**\n * Source type for the citation.\n */\n source?: string;\n /**\n * URL of the document source\n */\n url?: string;\n /**\n * Source document title.\n *\n * For example, the page title for a web page or the title of a paper.\n */\n title?: string;\n /**\n * Start index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n startIndex?: number;\n /**\n * End index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n endIndex?: number;\n /**\n * Excerpt of source text being cited.\n */\n citedText?: string;\n }\n /**\n * Text output from a LLM.\n *\n * This typically represents the main text content of a message, such as the response\n * from a language model or the text of a user message.\n */\n export interface Text extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"text\";\n /**\n * Block text.\n */\n text: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: number;\n /**\n * Citations and other annotations.\n */\n annotations?: Array<Citation | BaseContentBlock>;\n }\n /**\n * Reasoning output from a LLM.\n */\n export interface Reasoning extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"reasoning\";\n /**\n * Reasoning text.\n *\n * Either the thought summary or the raw reasoning text itself.\n * This is often parsed from `<think>` tags in the model's response.\n */\n reasoning: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: number;\n }\n /**\n * Provider-specific content block.\n *\n * This is used to represent content blocks that are not part of the standard LangChain content model.\n * If a provider's non-standard output includes reasoning and tool calls, it should be\n * the adapter's job to parse that payload and emit the corresponding standard reasoning and tool call blocks.\n */\n export interface NonStandard<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TValue extends Record<string, any> = Record<string, any>> extends ContentBlock {\n /**\n * Type of the content block\n */\n type: \"non_standard\";\n /**\n * Provider-specific data\n */\n value: TValue;\n }\n export { Tools };\n export { Multimodal };\n export { Data };\n export type Standard = Text | Reasoning | NonStandard | Tools.Standard | Multimodal.Standard;\n}\n"],"mappings":";;;;;;UAIiBI,YAAAA,SAAqBJ;AAArBI,cAEIC,iBAFiBL,EAAAA,MAAAA,EAAgB;AAEtD;AAEyBI,kBAAAA,YAAAA,CAAY;EAAA;;;EA8DkB,OAAjCG,UAAAA,QAAAA,CAAAA;IAhBYH;;;IA+COI,SAAAA,IAAAA,EAAAA,UAAAA;IAQ1BC;;;IAGFP,MAAAA,CAAAA,EAAAA,MAAAA;IACAC;;;IACiCS,GAAAA,CAAAA,EAAAA,MAAAA;IAAcX;;AAAoC;;;;;;;;;;;;;;;;;;;;;;;;;;;gCA5D9DG;;;;;;;;;;;;;;;;kBAgBZG,MAAMD,WAAWN;;;;;qCAKAI;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0BpBI,sBAAsBA,6BAA6BJ;;;;;;;;WAQvDK;;WAEFR;WACAC;WACAC;yBACcO,OAAOC,YAAYC,cAAcX,KAAAA,CAAMY,WAAWX,UAAAA,CAAWW"}
|
|
@@ -91,10 +91,29 @@ declare namespace ContentBlock {
|
|
|
91
91
|
*/
|
|
92
92
|
index?: number;
|
|
93
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* Provider-specific content block.
|
|
96
|
+
*
|
|
97
|
+
* This is used to represent content blocks that are not part of the standard LangChain content model.
|
|
98
|
+
* If a provider's non-standard output includes reasoning and tool calls, it should be
|
|
99
|
+
* the adapter's job to parse that payload and emit the corresponding standard reasoning and tool call blocks.
|
|
100
|
+
*/
|
|
101
|
+
export interface NonStandard<
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
103
|
+
TValue extends Record<string, any> = Record<string, any>> extends ContentBlock {
|
|
104
|
+
/**
|
|
105
|
+
* Type of the content block
|
|
106
|
+
*/
|
|
107
|
+
type: "non_standard";
|
|
108
|
+
/**
|
|
109
|
+
* Provider-specific data
|
|
110
|
+
*/
|
|
111
|
+
value: TValue;
|
|
112
|
+
}
|
|
94
113
|
export { Tools };
|
|
95
114
|
export { Multimodal };
|
|
96
115
|
export { Data };
|
|
97
|
-
export type Standard = Text | Reasoning | Tools.Standard | Multimodal.Standard;
|
|
116
|
+
export type Standard = Text | Reasoning | NonStandard | Tools.Standard | Multimodal.Standard;
|
|
98
117
|
}
|
|
99
118
|
//#endregion
|
|
100
119
|
export { ContentBlock, KNOWN_BLOCK_TYPES };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["BaseContentBlock","Tools","Multimodal","Data","ContentBlock","KNOWN_BLOCK_TYPES","Citation","Array","Text","Reasoning","Standard"],"sources":["../../../src/messages/content/index.d.ts"],"sourcesContent":["import type { BaseContentBlock } from \"./base.js\";\nimport { type Tools } from \"./tools.js\";\nimport { type Multimodal } from \"./multimodal.js\";\nimport { type Data } from \"./data.js\";\nexport interface ContentBlock extends BaseContentBlock {\n}\nexport declare const KNOWN_BLOCK_TYPES: string[];\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport declare namespace ContentBlock {\n /**\n * Annotation for citing data from a document.\n */\n export interface Citation {\n /**\n * Type of the content block\n */\n readonly type: \"citation\";\n /**\n * Source type for the citation.\n */\n source?: string;\n /**\n * URL of the document source\n */\n url?: string;\n /**\n * Source document title.\n *\n * For example, the page title for a web page or the title of a paper.\n */\n title?: string;\n /**\n * Start index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n startIndex?: number;\n /**\n * End index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n endIndex?: number;\n /**\n * Excerpt of source text being cited.\n */\n citedText?: string;\n }\n /**\n * Text output from a LLM.\n *\n * This typically represents the main text content of a message, such as the response\n * from a language model or the text of a user message.\n */\n export interface Text extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"text\";\n /**\n * Block text.\n */\n text: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: number;\n /**\n * Citations and other annotations.\n */\n annotations?: Array<Citation | BaseContentBlock>;\n }\n /**\n * Reasoning output from a LLM.\n */\n export interface Reasoning extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"reasoning\";\n /**\n * Reasoning text.\n *\n * Either the thought summary or the raw reasoning text itself.\n * This is often parsed from `<think>` tags in the model's response.\n */\n reasoning: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: number;\n }\n export { Tools };\n export { Multimodal };\n export { Data };\n export type Standard = Text | Reasoning | Tools.Standard | Multimodal.Standard;\n}\n"],"mappings":";;;;;;UAIiBI,YAAAA,SAAqBJ;AAArBI,cAEIC,iBAFiBL,EAAAA,MAAAA,EAAgB;AAEtD;AAEyBI,kBAAAA,YAAAA,CAAY;EAAA;;;EA8DkB,OAAjCG,UAAAA,QAAAA,CAAAA;IAhBYH;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["BaseContentBlock","Tools","Multimodal","Data","ContentBlock","KNOWN_BLOCK_TYPES","Citation","Array","Record","TValue","Text","Reasoning","NonStandard","Standard"],"sources":["../../../src/messages/content/index.d.ts"],"sourcesContent":["import type { BaseContentBlock } from \"./base.js\";\nimport { type Tools } from \"./tools.js\";\nimport { type Multimodal } from \"./multimodal.js\";\nimport { type Data } from \"./data.js\";\nexport interface ContentBlock extends BaseContentBlock {\n}\nexport declare const KNOWN_BLOCK_TYPES: string[];\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport declare namespace ContentBlock {\n /**\n * Annotation for citing data from a document.\n */\n export interface Citation {\n /**\n * Type of the content block\n */\n readonly type: \"citation\";\n /**\n * Source type for the citation.\n */\n source?: string;\n /**\n * URL of the document source\n */\n url?: string;\n /**\n * Source document title.\n *\n * For example, the page title for a web page or the title of a paper.\n */\n title?: string;\n /**\n * Start index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n startIndex?: number;\n /**\n * End index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n endIndex?: number;\n /**\n * Excerpt of source text being cited.\n */\n citedText?: string;\n }\n /**\n * Text output from a LLM.\n *\n * This typically represents the main text content of a message, such as the response\n * from a language model or the text of a user message.\n */\n export interface Text extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"text\";\n /**\n * Block text.\n */\n text: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: number;\n /**\n * Citations and other annotations.\n */\n annotations?: Array<Citation | BaseContentBlock>;\n }\n /**\n * Reasoning output from a LLM.\n */\n export interface Reasoning extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"reasoning\";\n /**\n * Reasoning text.\n *\n * Either the thought summary or the raw reasoning text itself.\n * This is often parsed from `<think>` tags in the model's response.\n */\n reasoning: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: number;\n }\n /**\n * Provider-specific content block.\n *\n * This is used to represent content blocks that are not part of the standard LangChain content model.\n * If a provider's non-standard output includes reasoning and tool calls, it should be\n * the adapter's job to parse that payload and emit the corresponding standard reasoning and tool call blocks.\n */\n export interface NonStandard<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TValue extends Record<string, any> = Record<string, any>> extends ContentBlock {\n /**\n * Type of the content block\n */\n type: \"non_standard\";\n /**\n * Provider-specific data\n */\n value: TValue;\n }\n export { Tools };\n export { Multimodal };\n export { Data };\n export type Standard = Text | Reasoning | NonStandard | Tools.Standard | Multimodal.Standard;\n}\n"],"mappings":";;;;;;UAIiBI,YAAAA,SAAqBJ;AAArBI,cAEIC,iBAFiBL,EAAAA,MAAAA,EAAgB;AAEtD;AAEyBI,kBAAAA,YAAAA,CAAY;EAAA;;;EA8DkB,OAAjCG,UAAAA,QAAAA,CAAAA;IAhBYH;;;IA+COI,SAAAA,IAAAA,EAAAA,UAAAA;IAQ1BC;;;IAGFP,MAAAA,CAAAA,EAAAA,MAAAA;IACAC;;;IACiCS,GAAAA,CAAAA,EAAAA,MAAAA;IAAcX;;AAAoC;;;;;;;;;;;;;;;;;;;;;;;;;;;gCA5D9DG;;;;;;;;;;;;;;;;kBAgBZG,MAAMD,WAAWN;;;;;qCAKAI;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0BpBI,sBAAsBA,6BAA6BJ;;;;;;;;WAQvDK;;WAEFR;WACAC;WACAC;yBACcO,OAAOC,YAAYC,cAAcX,KAAAA,CAAMY,WAAWX,UAAAA,CAAWW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["KNOWN_BLOCK_TYPES","KNOWN_TOOL_BLOCK_TYPES","KNOWN_MULTIMODAL_BLOCK_TYPES"],"sources":["../../../src/messages/content/index.ts"],"sourcesContent":["import type { BaseContentBlock } from \"./base.js\";\nimport {\n KNOWN_BLOCK_TYPES as KNOWN_TOOL_BLOCK_TYPES,\n type Tools,\n} from \"./tools.js\";\nimport {\n KNOWN_BLOCK_TYPES as KNOWN_MULTIMODAL_BLOCK_TYPES,\n type Multimodal,\n} from \"./multimodal.js\";\nimport { type Data } from \"./data.js\";\n\nexport interface ContentBlock extends BaseContentBlock {}\n\nexport const KNOWN_BLOCK_TYPES = [\n \"text\",\n \"reasoning\",\n ...KNOWN_TOOL_BLOCK_TYPES,\n ...KNOWN_MULTIMODAL_BLOCK_TYPES,\n];\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport declare namespace ContentBlock {\n /**\n * Annotation for citing data from a document.\n */\n export interface Citation {\n /**\n * Type of the content block\n */\n readonly type: \"citation\";\n /**\n * Source type for the citation.\n */\n source?: string;\n /**\n * URL of the document source\n */\n url?: string;\n /**\n * Source document title.\n *\n * For example, the page title for a web page or the title of a paper.\n */\n title?: string;\n /**\n * Start index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n startIndex?: number;\n /**\n * End index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n endIndex?: number;\n /**\n * Excerpt of source text being cited.\n */\n citedText?: string;\n }\n\n /**\n * Text output from a LLM.\n *\n * This typically represents the main text content of a message, such as the response\n * from a language model or the text of a user message.\n */\n export interface Text extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"text\";\n /**\n * Block text.\n */\n text: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: number;\n /**\n * Citations and other annotations.\n */\n annotations?: Array<Citation | BaseContentBlock>;\n }\n\n /**\n * Reasoning output from a LLM.\n */\n export interface Reasoning extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"reasoning\";\n /**\n * Reasoning text.\n *\n * Either the thought summary or the raw reasoning text itself.\n * This is often parsed from `<think>` tags in the model's response.\n */\n reasoning: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: number;\n }\n\n export { Tools };\n export { Multimodal };\n export { Data };\n\n export type Standard =\n | Text\n | Reasoning\n | Tools.Standard\n | Multimodal.Standard;\n}\n"],"mappings":";;;;AAaA,MAAaA,sBAAoB;CAC/B;CACA;CACA,GAAGC;CACH,GAAGC;AACJ"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["KNOWN_BLOCK_TYPES","KNOWN_TOOL_BLOCK_TYPES","KNOWN_MULTIMODAL_BLOCK_TYPES"],"sources":["../../../src/messages/content/index.ts"],"sourcesContent":["import type { BaseContentBlock } from \"./base.js\";\nimport {\n KNOWN_BLOCK_TYPES as KNOWN_TOOL_BLOCK_TYPES,\n type Tools,\n} from \"./tools.js\";\nimport {\n KNOWN_BLOCK_TYPES as KNOWN_MULTIMODAL_BLOCK_TYPES,\n type Multimodal,\n} from \"./multimodal.js\";\nimport { type Data } from \"./data.js\";\n\nexport interface ContentBlock extends BaseContentBlock {}\n\nexport const KNOWN_BLOCK_TYPES = [\n \"text\",\n \"reasoning\",\n ...KNOWN_TOOL_BLOCK_TYPES,\n ...KNOWN_MULTIMODAL_BLOCK_TYPES,\n];\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport declare namespace ContentBlock {\n /**\n * Annotation for citing data from a document.\n */\n export interface Citation {\n /**\n * Type of the content block\n */\n readonly type: \"citation\";\n /**\n * Source type for the citation.\n */\n source?: string;\n /**\n * URL of the document source\n */\n url?: string;\n /**\n * Source document title.\n *\n * For example, the page title for a web page or the title of a paper.\n */\n title?: string;\n /**\n * Start index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n startIndex?: number;\n /**\n * End index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n endIndex?: number;\n /**\n * Excerpt of source text being cited.\n */\n citedText?: string;\n }\n\n /**\n * Text output from a LLM.\n *\n * This typically represents the main text content of a message, such as the response\n * from a language model or the text of a user message.\n */\n export interface Text extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"text\";\n /**\n * Block text.\n */\n text: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: number;\n /**\n * Citations and other annotations.\n */\n annotations?: Array<Citation | BaseContentBlock>;\n }\n\n /**\n * Reasoning output from a LLM.\n */\n export interface Reasoning extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"reasoning\";\n /**\n * Reasoning text.\n *\n * Either the thought summary or the raw reasoning text itself.\n * This is often parsed from `<think>` tags in the model's response.\n */\n reasoning: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: number;\n }\n\n /**\n * Provider-specific content block.\n *\n * This is used to represent content blocks that are not part of the standard LangChain content model.\n * If a provider's non-standard output includes reasoning and tool calls, it should be\n * the adapter's job to parse that payload and emit the corresponding standard reasoning and tool call blocks.\n */\n export interface NonStandard<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TValue extends Record<string, any> = Record<string, any>\n > extends ContentBlock {\n /**\n * Type of the content block\n */\n type: \"non_standard\";\n /**\n * Provider-specific data\n */\n value: TValue;\n }\n\n export { Tools };\n export { Multimodal };\n export { Data };\n\n export type Standard =\n | Text\n | Reasoning\n | NonStandard\n | Tools.Standard\n | Multimodal.Standard;\n}\n"],"mappings":";;;;AAaA,MAAaA,sBAAoB;CAC/B;CACA;CACA,GAAGC;CACH,GAAGC;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.cjs","names":[],"sources":["../../../src/messages/content/tools.ts"],"sourcesContent":["import { BaseContentBlock } from \"./base.js\";\n\nexport type Tools = never;\n\nexport const KNOWN_BLOCK_TYPES = [\n \"tool_call\",\n \"tool_call_chunk\",\n \"invalid_tool_call\",\n \"web_search_call\",\n \"web_search_result\",\n \"code_interpreter\",\n \"code_interpreter_result\",\n];\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport declare namespace Tools {\n /**\n * Represents a request to call a tool.\n *\n * @example\n * ```ts\n * const toolCall: ToolCall = {\n * type: \"tool_call\",\n * name: \"foo\",\n * args: { a: 1 },\n * callId: \"123\"\n * };\n * ```\n * This represents a request to call the tool named \"foo\" with arguments {\"a\": 1}\n * and an identifier of \"123\".\n */\n export interface ToolCall<TName extends string = string, TArgs = unknown>\n extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"tool_call\";\n /**\n * The name of the tool being called\n */\n name: TName;\n /**\n * The arguments to the tool call\n */\n args: TArgs;\n }\n\n /** Content block to represent partial data of a tool call */\n export interface ToolCallChunk<TName extends string = string>\n extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"tool_call_chunk\";\n /**\n * The name of the tool being called\n */\n name?: TName;\n /**\n * The arguments to the tool call\n */\n args?: string;\n /**\n * The index of the tool call chunk\n */\n index?: number;\n }\n\n /** Content block to represent an invalid tool call */\n export interface InvalidToolCall<TName extends string = string>\n extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"invalid_tool_call\";\n /**\n * The name of the tool being called\n */\n name?: TName;\n /**\n * The arguments to the tool call\n */\n args?: string;\n /**\n * An error message associated with the tool call\n */\n error?: string;\n /**\n * Index of block in aggregate response\n */\n index?: string | number;\n }\n\n
|
|
1
|
+
{"version":3,"file":"tools.cjs","names":[],"sources":["../../../src/messages/content/tools.ts"],"sourcesContent":["import { BaseContentBlock } from \"./base.js\";\n\nexport type Tools = never;\n\nexport const KNOWN_BLOCK_TYPES = [\n \"tool_call\",\n \"tool_call_chunk\",\n \"invalid_tool_call\",\n \"server_tool_call\",\n \"server_tool_call_chunk\",\n \"server_tool_call_result\",\n \"web_search_call\",\n \"web_search_result\",\n \"code_interpreter\",\n \"code_interpreter_result\",\n];\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport declare namespace Tools {\n /**\n * Represents a request to call a tool.\n *\n * @example\n * ```ts\n * const toolCall: ToolCall = {\n * type: \"tool_call\",\n * name: \"foo\",\n * args: { a: 1 },\n * callId: \"123\"\n * };\n * ```\n * This represents a request to call the tool named \"foo\" with arguments {\"a\": 1}\n * and an identifier of \"123\".\n */\n export interface ToolCall<TName extends string = string, TArgs = unknown>\n extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"tool_call\";\n /**\n * The name of the tool being called\n */\n name: TName;\n /**\n * The arguments to the tool call\n */\n args: TArgs;\n }\n\n /** Content block to represent partial data of a tool call */\n export interface ToolCallChunk<TName extends string = string>\n extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"tool_call_chunk\";\n /**\n * The name of the tool being called\n */\n name?: TName;\n /**\n * The arguments to the tool call\n */\n args?: string;\n /**\n * The index of the tool call chunk\n */\n index?: number;\n }\n\n /** Content block to represent an invalid tool call */\n export interface InvalidToolCall<TName extends string = string>\n extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"invalid_tool_call\";\n /**\n * The name of the tool being called\n */\n name?: TName;\n /**\n * The arguments to the tool call\n */\n args?: string;\n /**\n * An error message associated with the tool call\n */\n error?: string;\n /**\n * Index of block in aggregate response\n */\n index?: string | number;\n }\n\n export interface ServerToolCall<\n TName extends string = string,\n TArgs = unknown\n > extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"server_tool_call\";\n /**\n * The name of the tool being called\n */\n name: TName;\n /**\n * The arguments to the tool call\n */\n args: TArgs;\n }\n\n export interface ServerToolCallChunk<TName extends string = string>\n extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"server_tool_call_chunk\";\n /**\n * The name of the tool being called\n */\n name?: TName;\n /**\n * The arguments to the tool call\n */\n args?: string;\n }\n\n export interface ServerToolCallResult<TOutput = Record<string, unknown>>\n extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"server_tool_call_result\";\n /**\n * The unique identifier of the tool call that this result corresponds to\n */\n toolCallId: string;\n /**\n * The status of the server tool call\n */\n status: \"success\" | \"error\";\n /**\n * The output of the server tool call\n */\n output: TOutput;\n }\n\n /**\n * Content block for a built-in web search tool call.\n * @deprecated Use ServerToolCall instead\n */\n export interface WebSearchCall extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"web_search_call\";\n /**\n * The search query used in the web search tool call\n */\n query?: string;\n }\n\n /**\n * Content block for the result of a built-in search tool call\n * @deprecated Use ServerToolCallResult instead\n */\n export interface WebSearchResult extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"web_search_result\";\n /**\n * List of URLs returned by the web search tool call\n */\n urls?: string[];\n }\n\n /**\n * Content block for a built-in code interpreter tool call.\n * @deprecated Use ServerToolCall instead\n */\n export interface CodeInterpreterCall extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"code_interpreter_call\";\n /**\n * The language of the code executed by the code interpreter tool call\n */\n language?: string;\n /**\n * The code to be executed by the code interpreter\n */\n code?: string;\n }\n\n /**\n * Content block for the output of a singular code interpreter tool call\n * @deprecated Use ServerToolCallResult instead\n */\n export interface CodeInterpreterOutput {\n readonly type: \"code_interpreter_output\";\n /**\n * The return code of the code interpreter tool call\n * Example: 0 for success, non-zero for failure\n */\n returnCode?: number;\n /**\n * Standard error output of the executed code\n */\n stderr?: string;\n /**\n * Standard output of the executed code\n */\n stdout?: string;\n /**\n * File IDs of the files created by the code interpreter tool call\n */\n fileIds?: string[];\n }\n\n /**\n * Content block for the result of a code interpreter tool call\n * @deprecated Use ServerToolCallResult instead\n */\n export interface CodeInterpreterResult extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"code_interpreter_result\";\n /**\n * The result of the code interpreter tool call\n */\n output: CodeInterpreterOutput[];\n }\n\n export type Standard =\n | ToolCall\n | ToolCallChunk\n | InvalidToolCall\n | ServerToolCall\n | ServerToolCallChunk\n | ServerToolCallResult\n | WebSearchCall\n | WebSearchResult\n | CodeInterpreterCall\n | CodeInterpreterResult;\n}\n"],"mappings":";;AAIA,MAAa,oBAAoB;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD"}
|
|
@@ -75,7 +75,56 @@ declare namespace Tools {
|
|
|
75
75
|
*/
|
|
76
76
|
index?: string | number;
|
|
77
77
|
}
|
|
78
|
-
|
|
78
|
+
interface ServerToolCall<TName extends string = string, TArgs = unknown> extends BaseContentBlock {
|
|
79
|
+
/**
|
|
80
|
+
* Type of the content block
|
|
81
|
+
*/
|
|
82
|
+
readonly type: "server_tool_call";
|
|
83
|
+
/**
|
|
84
|
+
* The name of the tool being called
|
|
85
|
+
*/
|
|
86
|
+
name: TName;
|
|
87
|
+
/**
|
|
88
|
+
* The arguments to the tool call
|
|
89
|
+
*/
|
|
90
|
+
args: TArgs;
|
|
91
|
+
}
|
|
92
|
+
interface ServerToolCallChunk<TName extends string = string> extends BaseContentBlock {
|
|
93
|
+
/**
|
|
94
|
+
* Type of the content block
|
|
95
|
+
*/
|
|
96
|
+
readonly type: "server_tool_call_chunk";
|
|
97
|
+
/**
|
|
98
|
+
* The name of the tool being called
|
|
99
|
+
*/
|
|
100
|
+
name?: TName;
|
|
101
|
+
/**
|
|
102
|
+
* The arguments to the tool call
|
|
103
|
+
*/
|
|
104
|
+
args?: string;
|
|
105
|
+
}
|
|
106
|
+
interface ServerToolCallResult<TOutput = Record<string, unknown>> extends BaseContentBlock {
|
|
107
|
+
/**
|
|
108
|
+
* Type of the content block
|
|
109
|
+
*/
|
|
110
|
+
readonly type: "server_tool_call_result";
|
|
111
|
+
/**
|
|
112
|
+
* The unique identifier of the tool call that this result corresponds to
|
|
113
|
+
*/
|
|
114
|
+
toolCallId: string;
|
|
115
|
+
/**
|
|
116
|
+
* The status of the server tool call
|
|
117
|
+
*/
|
|
118
|
+
status: "success" | "error";
|
|
119
|
+
/**
|
|
120
|
+
* The output of the server tool call
|
|
121
|
+
*/
|
|
122
|
+
output: TOutput;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Content block for a built-in web search tool call.
|
|
126
|
+
* @deprecated Use ServerToolCall instead
|
|
127
|
+
*/
|
|
79
128
|
interface WebSearchCall extends BaseContentBlock {
|
|
80
129
|
/**
|
|
81
130
|
* Type of the content block
|
|
@@ -86,7 +135,10 @@ declare namespace Tools {
|
|
|
86
135
|
*/
|
|
87
136
|
query?: string;
|
|
88
137
|
}
|
|
89
|
-
/**
|
|
138
|
+
/**
|
|
139
|
+
* Content block for the result of a built-in search tool call
|
|
140
|
+
* @deprecated Use ServerToolCallResult instead
|
|
141
|
+
*/
|
|
90
142
|
interface WebSearchResult extends BaseContentBlock {
|
|
91
143
|
/**
|
|
92
144
|
* Type of the content block
|
|
@@ -97,7 +149,10 @@ declare namespace Tools {
|
|
|
97
149
|
*/
|
|
98
150
|
urls?: string[];
|
|
99
151
|
}
|
|
100
|
-
/**
|
|
152
|
+
/**
|
|
153
|
+
* Content block for a built-in code interpreter tool call.
|
|
154
|
+
* @deprecated Use ServerToolCall instead
|
|
155
|
+
*/
|
|
101
156
|
interface CodeInterpreterCall extends BaseContentBlock {
|
|
102
157
|
/**
|
|
103
158
|
* Type of the content block
|
|
@@ -112,7 +167,10 @@ declare namespace Tools {
|
|
|
112
167
|
*/
|
|
113
168
|
code?: string;
|
|
114
169
|
}
|
|
115
|
-
/**
|
|
170
|
+
/**
|
|
171
|
+
* Content block for the output of a singular code interpreter tool call
|
|
172
|
+
* @deprecated Use ServerToolCallResult instead
|
|
173
|
+
*/
|
|
116
174
|
interface CodeInterpreterOutput {
|
|
117
175
|
readonly type: "code_interpreter_output";
|
|
118
176
|
/**
|
|
@@ -133,7 +191,10 @@ declare namespace Tools {
|
|
|
133
191
|
*/
|
|
134
192
|
fileIds?: string[];
|
|
135
193
|
}
|
|
136
|
-
/**
|
|
194
|
+
/**
|
|
195
|
+
* Content block for the result of a code interpreter tool call
|
|
196
|
+
* @deprecated Use ServerToolCallResult instead
|
|
197
|
+
*/
|
|
137
198
|
interface CodeInterpreterResult extends BaseContentBlock {
|
|
138
199
|
/**
|
|
139
200
|
* Type of the content block
|
|
@@ -144,7 +205,7 @@ declare namespace Tools {
|
|
|
144
205
|
*/
|
|
145
206
|
output: CodeInterpreterOutput[];
|
|
146
207
|
}
|
|
147
|
-
type Standard = ToolCall | ToolCallChunk | InvalidToolCall | WebSearchCall | WebSearchResult | CodeInterpreterCall | CodeInterpreterResult;
|
|
208
|
+
type Standard = ToolCall | ToolCallChunk | InvalidToolCall | ServerToolCall | ServerToolCallChunk | ServerToolCallResult | WebSearchCall | WebSearchResult | CodeInterpreterCall | CodeInterpreterResult;
|
|
148
209
|
}
|
|
149
210
|
//#endregion
|
|
150
211
|
export { Tools };
|