@langchain/openai 1.0.0-alpha.3 → 1.1.0
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/CHANGELOG.md +53 -0
- package/dist/azure/chat_models/common.cjs +130 -0
- package/dist/azure/chat_models/common.cjs.map +1 -0
- package/dist/azure/chat_models/common.d.cts +16 -0
- package/dist/azure/chat_models/common.d.cts.map +1 -0
- package/dist/azure/chat_models/common.d.ts +16 -0
- package/dist/azure/chat_models/common.d.ts.map +1 -0
- package/dist/azure/chat_models/common.js +124 -0
- package/dist/azure/chat_models/common.js.map +1 -0
- package/dist/azure/chat_models/completions.cjs +50 -0
- package/dist/azure/chat_models/completions.cjs.map +1 -0
- package/dist/azure/chat_models/completions.d.cts +29 -0
- package/dist/azure/chat_models/completions.d.cts.map +1 -0
- package/dist/azure/chat_models/completions.d.ts +29 -0
- package/dist/azure/chat_models/completions.d.ts.map +1 -0
- package/dist/azure/chat_models/completions.js +50 -0
- package/dist/azure/chat_models/completions.js.map +1 -0
- package/dist/azure/{chat_models.cjs → chat_models/index.cjs} +14 -214
- package/dist/azure/chat_models/index.cjs.map +1 -0
- package/dist/azure/{chat_models.d.ts → chat_models/index.d.cts} +6 -11
- package/dist/azure/chat_models/index.d.cts.map +1 -0
- package/dist/azure/{chat_models.d.cts → chat_models/index.d.ts} +6 -11
- package/dist/azure/chat_models/index.d.ts.map +1 -0
- package/dist/azure/{chat_models.js → chat_models/index.js} +6 -205
- package/dist/azure/chat_models/index.js.map +1 -0
- package/dist/azure/chat_models/responses.cjs +50 -0
- package/dist/azure/chat_models/responses.cjs.map +1 -0
- package/dist/azure/chat_models/responses.d.cts +29 -0
- package/dist/azure/chat_models/responses.d.cts.map +1 -0
- package/dist/azure/chat_models/responses.d.ts +29 -0
- package/dist/azure/chat_models/responses.d.ts.map +1 -0
- package/dist/azure/chat_models/responses.js +50 -0
- package/dist/azure/chat_models/responses.js.map +1 -0
- package/dist/chat_models/base.cjs +533 -0
- package/dist/chat_models/base.cjs.map +1 -0
- package/dist/chat_models/base.d.cts +272 -0
- package/dist/chat_models/base.d.cts.map +1 -0
- package/dist/chat_models/base.d.ts +272 -0
- package/dist/chat_models/base.d.ts.map +1 -0
- package/dist/chat_models/base.js +532 -0
- package/dist/chat_models/base.js.map +1 -0
- package/dist/chat_models/completions.cjs +258 -0
- package/dist/chat_models/completions.cjs.map +1 -0
- package/dist/chat_models/completions.d.cts +44 -0
- package/dist/chat_models/completions.d.cts.map +1 -0
- package/dist/chat_models/completions.d.ts +44 -0
- package/dist/chat_models/completions.d.ts.map +1 -0
- package/dist/chat_models/completions.js +257 -0
- package/dist/chat_models/completions.js.map +1 -0
- package/dist/chat_models/index.cjs +608 -0
- package/dist/chat_models/index.cjs.map +1 -0
- package/dist/chat_models/index.d.cts +593 -0
- package/dist/chat_models/index.d.cts.map +1 -0
- package/dist/chat_models/index.d.ts +593 -0
- package/dist/chat_models/index.d.ts.map +1 -0
- package/dist/chat_models/index.js +608 -0
- package/dist/chat_models/index.js.map +1 -0
- package/dist/chat_models/responses.cjs +189 -0
- package/dist/chat_models/responses.cjs.map +1 -0
- package/dist/chat_models/responses.d.cts +62 -0
- package/dist/chat_models/responses.d.cts.map +1 -0
- package/dist/chat_models/responses.d.ts +62 -0
- package/dist/chat_models/responses.d.ts.map +1 -0
- package/dist/chat_models/responses.js +188 -0
- package/dist/chat_models/responses.js.map +1 -0
- package/dist/converters/completions.cjs +603 -0
- package/dist/converters/completions.cjs.map +1 -0
- package/dist/converters/completions.js +599 -0
- package/dist/converters/completions.js.map +1 -0
- package/dist/converters/responses.cjs +892 -0
- package/dist/converters/responses.cjs.map +1 -0
- package/dist/converters/responses.js +889 -0
- package/dist/converters/responses.js.map +1 -0
- package/dist/index.cjs +14 -9
- package/dist/index.d.cts +9 -4
- package/dist/index.d.ts +9 -4
- package/dist/index.js +8 -4
- package/dist/langchain-core/dist/callbacks/base.d.ts +1 -0
- package/dist/langchain-core/dist/callbacks/manager.d.ts +2 -0
- package/dist/langchain-core/dist/language_models/base.d.ts +5 -0
- package/dist/langchain-core/dist/language_models/chat_models.d.cts +13 -0
- package/dist/langchain-core/dist/language_models/chat_models.d.cts.map +1 -0
- package/dist/langchain-core/dist/language_models/chat_models.d.ts +20 -0
- package/dist/langchain-core/dist/language_models/chat_models.d.ts.map +1 -0
- package/dist/langchain-core/dist/runnables/base.d.ts +7 -0
- package/dist/langchain-core/dist/runnables/graph.d.ts +1 -0
- package/dist/langchain-core/dist/runnables/types.d.ts +2 -0
- package/dist/langchain-core/dist/tools/types.d.ts +5 -0
- package/dist/langchain-core/dist/tracers/base.d.ts +2 -0
- package/dist/langchain-core/dist/tracers/event_stream.d.ts +1 -0
- package/dist/langchain-core/dist/tracers/log_stream.d.ts +3 -0
- package/dist/langchain-core/dist/utils/types/index.d.ts +1 -0
- package/dist/langchain-core/dist/utils/types/zod.d.ts +1 -0
- package/dist/llms.cjs +1 -1
- package/dist/llms.d.cts +1 -1
- package/dist/llms.js +1 -1
- package/dist/utils/errors.cjs +1 -1
- package/dist/utils/errors.cjs.map +1 -1
- package/dist/utils/errors.js +1 -1
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/misc.js +2 -2
- package/dist/utils/misc.js.map +1 -1
- package/dist/utils/output.cjs +0 -12
- package/dist/utils/output.cjs.map +1 -1
- package/dist/utils/output.js +1 -12
- package/dist/utils/output.js.map +1 -1
- package/dist/utils/prompts.cjs +2 -2
- package/dist/utils/prompts.cjs.map +1 -1
- package/dist/utils/prompts.d.cts +1 -0
- package/dist/utils/prompts.d.cts.map +1 -1
- package/dist/utils/prompts.d.ts +1 -0
- package/dist/utils/prompts.d.ts.map +1 -1
- package/dist/utils/prompts.js +2 -2
- package/dist/utils/prompts.js.map +1 -1
- package/package.json +10 -7
- package/dist/azure/chat_models.cjs.map +0 -1
- package/dist/azure/chat_models.d.cts.map +0 -1
- package/dist/azure/chat_models.d.ts.map +0 -1
- package/dist/azure/chat_models.js.map +0 -1
- package/dist/chat_models.cjs +0 -1967
- package/dist/chat_models.cjs.map +0 -1
- package/dist/chat_models.d.cts +0 -933
- package/dist/chat_models.d.cts.map +0 -1
- package/dist/chat_models.d.ts +0 -933
- package/dist/chat_models.d.ts.map +0 -1
- package/dist/chat_models.js +0 -1963
- package/dist/chat_models.js.map +0 -1
- package/dist/utils/message_inputs.cjs +0 -139
- package/dist/utils/message_inputs.cjs.map +0 -1
- package/dist/utils/message_inputs.d.cts +0 -9
- package/dist/utils/message_inputs.d.cts.map +0 -1
- package/dist/utils/message_inputs.d.ts +0 -9
- package/dist/utils/message_inputs.d.ts.map +0 -1
- package/dist/utils/message_inputs.js +0 -137
- package/dist/utils/message_inputs.js.map +0 -1
- package/dist/utils/standard.cjs +0 -315
- package/dist/utils/standard.cjs.map +0 -1
- package/dist/utils/standard.js +0 -313
- package/dist/utils/standard.js.map +0 -1
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { isReasoningModel, messageToOpenAIRole } from "./misc.js";
|
|
2
|
-
import { _convertToCompletionsMessageFromV1 } from "./standard.js";
|
|
3
|
-
import { convertToProviderContentBlock, isAIMessage, isDataContentBlock, parseBase64DataUrl, parseMimeType } from "@langchain/core/messages";
|
|
4
|
-
import { convertLangChainToolCallToOpenAI } from "@langchain/core/output_parsers/openai_tools";
|
|
5
|
-
|
|
6
|
-
//#region src/utils/message_inputs.ts
|
|
7
|
-
const completionsApiContentBlockConverter = {
|
|
8
|
-
providerName: "ChatOpenAI",
|
|
9
|
-
fromStandardTextBlock(block) {
|
|
10
|
-
return {
|
|
11
|
-
type: "text",
|
|
12
|
-
text: block.text
|
|
13
|
-
};
|
|
14
|
-
},
|
|
15
|
-
fromStandardImageBlock(block) {
|
|
16
|
-
if (block.source_type === "url") return {
|
|
17
|
-
type: "image_url",
|
|
18
|
-
image_url: {
|
|
19
|
-
url: block.url,
|
|
20
|
-
...block.metadata?.detail ? { detail: block.metadata.detail } : {}
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
if (block.source_type === "base64") {
|
|
24
|
-
const url = `data:${block.mime_type ?? ""};base64,${block.data}`;
|
|
25
|
-
return {
|
|
26
|
-
type: "image_url",
|
|
27
|
-
image_url: {
|
|
28
|
-
url,
|
|
29
|
-
...block.metadata?.detail ? { detail: block.metadata.detail } : {}
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
throw new Error(`Image content blocks with source_type ${block.source_type} are not supported for ChatOpenAI`);
|
|
34
|
-
},
|
|
35
|
-
fromStandardAudioBlock(block) {
|
|
36
|
-
if (block.source_type === "url") {
|
|
37
|
-
const data = parseBase64DataUrl({ dataUrl: block.url });
|
|
38
|
-
if (!data) throw new Error(`URL audio blocks with source_type ${block.source_type} must be formatted as a data URL for ChatOpenAI`);
|
|
39
|
-
const rawMimeType = data.mime_type || block.mime_type || "";
|
|
40
|
-
let mimeType;
|
|
41
|
-
try {
|
|
42
|
-
mimeType = parseMimeType(rawMimeType);
|
|
43
|
-
} catch {
|
|
44
|
-
throw new Error(`Audio blocks with source_type ${block.source_type} must have mime type of audio/wav or audio/mp3`);
|
|
45
|
-
}
|
|
46
|
-
if (mimeType.type !== "audio" || mimeType.subtype !== "wav" && mimeType.subtype !== "mp3") throw new Error(`Audio blocks with source_type ${block.source_type} must have mime type of audio/wav or audio/mp3`);
|
|
47
|
-
return {
|
|
48
|
-
type: "input_audio",
|
|
49
|
-
input_audio: {
|
|
50
|
-
format: mimeType.subtype,
|
|
51
|
-
data: data.data
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
if (block.source_type === "base64") {
|
|
56
|
-
let mimeType;
|
|
57
|
-
try {
|
|
58
|
-
mimeType = parseMimeType(block.mime_type ?? "");
|
|
59
|
-
} catch {
|
|
60
|
-
throw new Error(`Audio blocks with source_type ${block.source_type} must have mime type of audio/wav or audio/mp3`);
|
|
61
|
-
}
|
|
62
|
-
if (mimeType.type !== "audio" || mimeType.subtype !== "wav" && mimeType.subtype !== "mp3") throw new Error(`Audio blocks with source_type ${block.source_type} must have mime type of audio/wav or audio/mp3`);
|
|
63
|
-
return {
|
|
64
|
-
type: "input_audio",
|
|
65
|
-
input_audio: {
|
|
66
|
-
format: mimeType.subtype,
|
|
67
|
-
data: block.data
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
throw new Error(`Audio content blocks with source_type ${block.source_type} are not supported for ChatOpenAI`);
|
|
72
|
-
},
|
|
73
|
-
fromStandardFileBlock(block) {
|
|
74
|
-
if (block.source_type === "url") {
|
|
75
|
-
const data = parseBase64DataUrl({ dataUrl: block.url });
|
|
76
|
-
if (!data) throw new Error(`URL file blocks with source_type ${block.source_type} must be formatted as a data URL for ChatOpenAI`);
|
|
77
|
-
return {
|
|
78
|
-
type: "file",
|
|
79
|
-
file: {
|
|
80
|
-
file_data: block.url,
|
|
81
|
-
...block.metadata?.filename || block.metadata?.name ? { filename: block.metadata?.filename || block.metadata?.name } : {}
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
if (block.source_type === "base64") return {
|
|
86
|
-
type: "file",
|
|
87
|
-
file: {
|
|
88
|
-
file_data: `data:${block.mime_type ?? ""};base64,${block.data}`,
|
|
89
|
-
...block.metadata?.filename || block.metadata?.name || block.metadata?.title ? { filename: block.metadata?.filename || block.metadata?.name || block.metadata?.title } : {}
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
if (block.source_type === "id") return {
|
|
93
|
-
type: "file",
|
|
94
|
-
file: { file_id: block.id }
|
|
95
|
-
};
|
|
96
|
-
throw new Error(`File content blocks with source_type ${block.source_type} are not supported for ChatOpenAI`);
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
function _convertMessagesToOpenAIParams(messages, model) {
|
|
100
|
-
return messages.flatMap((message) => {
|
|
101
|
-
if ("output_version" in message.response_metadata && message.response_metadata?.output_version === "v1") return _convertToCompletionsMessageFromV1(message);
|
|
102
|
-
let role = messageToOpenAIRole(message);
|
|
103
|
-
if (role === "system" && isReasoningModel(model)) role = "developer";
|
|
104
|
-
const content = typeof message.content === "string" ? message.content : message.content.map((m) => {
|
|
105
|
-
if (isDataContentBlock(m)) return convertToProviderContentBlock(m, completionsApiContentBlockConverter);
|
|
106
|
-
return m;
|
|
107
|
-
});
|
|
108
|
-
const completionParam = {
|
|
109
|
-
role,
|
|
110
|
-
content
|
|
111
|
-
};
|
|
112
|
-
if (message.name != null) completionParam.name = message.name;
|
|
113
|
-
if (message.additional_kwargs.function_call != null) {
|
|
114
|
-
completionParam.function_call = message.additional_kwargs.function_call;
|
|
115
|
-
completionParam.content = "";
|
|
116
|
-
}
|
|
117
|
-
if (isAIMessage(message) && !!message.tool_calls?.length) {
|
|
118
|
-
completionParam.tool_calls = message.tool_calls.map(convertLangChainToolCallToOpenAI);
|
|
119
|
-
completionParam.content = "";
|
|
120
|
-
} else {
|
|
121
|
-
if (message.additional_kwargs.tool_calls != null) completionParam.tool_calls = message.additional_kwargs.tool_calls;
|
|
122
|
-
if (message.tool_call_id != null) completionParam.tool_call_id = message.tool_call_id;
|
|
123
|
-
}
|
|
124
|
-
if (message.additional_kwargs.audio && typeof message.additional_kwargs.audio === "object" && "id" in message.additional_kwargs.audio) {
|
|
125
|
-
const audioMessage = {
|
|
126
|
-
role: "assistant",
|
|
127
|
-
audio: { id: message.additional_kwargs.audio.id }
|
|
128
|
-
};
|
|
129
|
-
return [completionParam, audioMessage];
|
|
130
|
-
}
|
|
131
|
-
return completionParam;
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
//#endregion
|
|
136
|
-
export { _convertMessagesToOpenAIParams, completionsApiContentBlockConverter };
|
|
137
|
-
//# sourceMappingURL=message_inputs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"message_inputs.js","names":["completionsApiContentBlockConverter: StandardContentBlockConverter<{\n text: ChatCompletionContentPartText;\n image: ChatCompletionContentPartImage;\n audio: ChatCompletionContentPartInputAudio;\n file: ChatCompletionContentPart.File;\n}>","mimeType: { type: string; subtype: string }","messages: BaseMessage[]","model?: string","completionParam: Record<string, any>"],"sources":["../../src/utils/message_inputs.ts"],"sourcesContent":["import {\n BaseMessage,\n convertToProviderContentBlock,\n isAIMessage,\n isDataContentBlock,\n parseBase64DataUrl,\n parseMimeType,\n StandardContentBlockConverter,\n ToolMessage,\n} from \"@langchain/core/messages\";\nimport { convertLangChainToolCallToOpenAI } from \"@langchain/core/output_parsers/openai_tools\";\nimport type { OpenAI as OpenAIClient } from \"openai\";\nimport type {\n ChatCompletionContentPartText,\n ChatCompletionContentPartImage,\n ChatCompletionContentPartInputAudio,\n ChatCompletionContentPart,\n} from \"openai/resources/chat/completions\";\nimport { _convertToCompletionsMessageFromV1 } from \"./standard.js\";\nimport { isReasoningModel, messageToOpenAIRole } from \"./misc.js\";\n\nexport const completionsApiContentBlockConverter: StandardContentBlockConverter<{\n text: ChatCompletionContentPartText;\n image: ChatCompletionContentPartImage;\n audio: ChatCompletionContentPartInputAudio;\n file: ChatCompletionContentPart.File;\n}> = {\n providerName: \"ChatOpenAI\",\n\n fromStandardTextBlock(block): ChatCompletionContentPartText {\n return { type: \"text\", text: block.text };\n },\n\n fromStandardImageBlock(block): ChatCompletionContentPartImage {\n if (block.source_type === \"url\") {\n return {\n type: \"image_url\",\n image_url: {\n url: block.url,\n ...(block.metadata?.detail\n ? { detail: block.metadata.detail as \"auto\" | \"low\" | \"high\" }\n : {}),\n },\n };\n }\n\n if (block.source_type === \"base64\") {\n const url = `data:${block.mime_type ?? \"\"};base64,${block.data}`;\n return {\n type: \"image_url\",\n image_url: {\n url,\n ...(block.metadata?.detail\n ? { detail: block.metadata.detail as \"auto\" | \"low\" | \"high\" }\n : {}),\n },\n };\n }\n\n throw new Error(\n `Image content blocks with source_type ${block.source_type} are not supported for ChatOpenAI`\n );\n },\n\n fromStandardAudioBlock(block): ChatCompletionContentPartInputAudio {\n if (block.source_type === \"url\") {\n const data = parseBase64DataUrl({ dataUrl: block.url });\n if (!data) {\n throw new Error(\n `URL audio blocks with source_type ${block.source_type} must be formatted as a data URL for ChatOpenAI`\n );\n }\n\n const rawMimeType = data.mime_type || block.mime_type || \"\";\n let mimeType: { type: string; subtype: string };\n\n try {\n mimeType = parseMimeType(rawMimeType);\n } catch {\n throw new Error(\n `Audio blocks with source_type ${block.source_type} must have mime type of audio/wav or audio/mp3`\n );\n }\n\n if (\n mimeType.type !== \"audio\" ||\n (mimeType.subtype !== \"wav\" && mimeType.subtype !== \"mp3\")\n ) {\n throw new Error(\n `Audio blocks with source_type ${block.source_type} must have mime type of audio/wav or audio/mp3`\n );\n }\n\n return {\n type: \"input_audio\",\n input_audio: {\n format: mimeType.subtype,\n data: data.data,\n },\n };\n }\n\n if (block.source_type === \"base64\") {\n let mimeType: { type: string; subtype: string };\n\n try {\n mimeType = parseMimeType(block.mime_type ?? \"\");\n } catch {\n throw new Error(\n `Audio blocks with source_type ${block.source_type} must have mime type of audio/wav or audio/mp3`\n );\n }\n\n if (\n mimeType.type !== \"audio\" ||\n (mimeType.subtype !== \"wav\" && mimeType.subtype !== \"mp3\")\n ) {\n throw new Error(\n `Audio blocks with source_type ${block.source_type} must have mime type of audio/wav or audio/mp3`\n );\n }\n\n return {\n type: \"input_audio\",\n input_audio: {\n format: mimeType.subtype,\n data: block.data,\n },\n };\n }\n\n throw new Error(\n `Audio content blocks with source_type ${block.source_type} are not supported for ChatOpenAI`\n );\n },\n\n fromStandardFileBlock(block): ChatCompletionContentPart.File {\n if (block.source_type === \"url\") {\n const data = parseBase64DataUrl({ dataUrl: block.url });\n if (!data) {\n throw new Error(\n `URL file blocks with source_type ${block.source_type} must be formatted as a data URL for ChatOpenAI`\n );\n }\n\n return {\n type: \"file\",\n file: {\n file_data: block.url, // formatted as base64 data URL\n ...(block.metadata?.filename || block.metadata?.name\n ? {\n filename: (block.metadata?.filename ||\n block.metadata?.name) as string,\n }\n : {}),\n },\n };\n }\n\n if (block.source_type === \"base64\") {\n return {\n type: \"file\",\n file: {\n file_data: `data:${block.mime_type ?? \"\"};base64,${block.data}`,\n ...(block.metadata?.filename ||\n block.metadata?.name ||\n block.metadata?.title\n ? {\n filename: (block.metadata?.filename ||\n block.metadata?.name ||\n block.metadata?.title) as string,\n }\n : {}),\n },\n };\n }\n\n if (block.source_type === \"id\") {\n return {\n type: \"file\",\n file: {\n file_id: block.id,\n },\n };\n }\n\n throw new Error(\n `File content blocks with source_type ${block.source_type} are not supported for ChatOpenAI`\n );\n },\n};\n\nexport function _convertMessagesToOpenAIParams(\n messages: BaseMessage[],\n model?: string\n): OpenAIClient.Chat.Completions.ChatCompletionMessageParam[] {\n return messages.flatMap((message) => {\n if (\n \"output_version\" in message.response_metadata &&\n message.response_metadata?.output_version === \"v1\"\n ) {\n return _convertToCompletionsMessageFromV1(message);\n }\n let role = messageToOpenAIRole(message);\n if (role === \"system\" && isReasoningModel(model)) {\n role = \"developer\";\n }\n\n const content =\n typeof message.content === \"string\"\n ? message.content\n : message.content.map((m) => {\n if (isDataContentBlock(m)) {\n return convertToProviderContentBlock(\n m,\n completionsApiContentBlockConverter\n );\n }\n return m;\n });\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const completionParam: Record<string, any> = {\n role,\n content,\n };\n if (message.name != null) {\n completionParam.name = message.name;\n }\n if (message.additional_kwargs.function_call != null) {\n completionParam.function_call = message.additional_kwargs.function_call;\n completionParam.content = \"\";\n }\n if (isAIMessage(message) && !!message.tool_calls?.length) {\n completionParam.tool_calls = message.tool_calls.map(\n convertLangChainToolCallToOpenAI\n );\n completionParam.content = \"\";\n } else {\n if (message.additional_kwargs.tool_calls != null) {\n completionParam.tool_calls = message.additional_kwargs.tool_calls;\n }\n if ((message as ToolMessage).tool_call_id != null) {\n completionParam.tool_call_id = (message as ToolMessage).tool_call_id;\n }\n }\n\n if (\n message.additional_kwargs.audio &&\n typeof message.additional_kwargs.audio === \"object\" &&\n \"id\" in message.additional_kwargs.audio\n ) {\n const audioMessage = {\n role: \"assistant\",\n audio: {\n id: message.additional_kwargs.audio.id,\n },\n };\n return [\n completionParam,\n audioMessage,\n ] as OpenAIClient.Chat.Completions.ChatCompletionMessageParam[];\n }\n\n return completionParam as OpenAIClient.Chat.Completions.ChatCompletionMessageParam;\n });\n}\n"],"mappings":";;;;;;AAqBA,MAAaA,sCAKR;CACH,cAAc;CAEd,sBAAsB,OAAsC;AAC1D,SAAO;GAAE,MAAM;GAAQ,MAAM,MAAM;EAAM;CAC1C;CAED,uBAAuB,OAAuC;AAC5D,MAAI,MAAM,gBAAgB,MACxB,QAAO;GACL,MAAM;GACN,WAAW;IACT,KAAK,MAAM;IACX,GAAI,MAAM,UAAU,SAChB,EAAE,QAAQ,MAAM,SAAS,OAAmC,IAC5D,CAAE;GACP;EACF;AAGH,MAAI,MAAM,gBAAgB,UAAU;GAClC,MAAM,MAAM,CAAC,KAAK,EAAE,MAAM,aAAa,GAAG,QAAQ,EAAE,MAAM,MAAM;AAChE,UAAO;IACL,MAAM;IACN,WAAW;KACT;KACA,GAAI,MAAM,UAAU,SAChB,EAAE,QAAQ,MAAM,SAAS,OAAmC,IAC5D,CAAE;IACP;GACF;EACF;AAED,QAAM,IAAI,MACR,CAAC,sCAAsC,EAAE,MAAM,YAAY,iCAAiC,CAAC;CAEhG;CAED,uBAAuB,OAA4C;AACjE,MAAI,MAAM,gBAAgB,OAAO;GAC/B,MAAM,OAAO,mBAAmB,EAAE,SAAS,MAAM,IAAK,EAAC;AACvD,OAAI,CAAC,KACH,OAAM,IAAI,MACR,CAAC,kCAAkC,EAAE,MAAM,YAAY,+CAA+C,CAAC;GAI3G,MAAM,cAAc,KAAK,aAAa,MAAM,aAAa;GACzD,IAAIC;AAEJ,OAAI;IACF,WAAW,cAAc,YAAY;GACtC,QAAO;AACN,UAAM,IAAI,MACR,CAAC,8BAA8B,EAAE,MAAM,YAAY,8CAA8C,CAAC;GAErG;AAED,OACE,SAAS,SAAS,WACjB,SAAS,YA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A,MAAM,eAAe;IACnB,MAAM;IACN,OAAO,EACL,IAAI,QAAQ,kBAAkB,MAAM,GACrC;GACF;AACD,UAAO,CACL,iBACA,YACD;EACF;AAED,SAAO;CACR,EAAC;AACH"}
|
package/dist/utils/standard.cjs
DELETED
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_misc = require('./misc.cjs');
|
|
3
|
-
const __langchain_core_messages = require_rolldown_runtime.__toESM(require("@langchain/core/messages"));
|
|
4
|
-
|
|
5
|
-
//#region src/utils/standard.ts
|
|
6
|
-
function _convertToChatCompletionsData(block) {
|
|
7
|
-
if (block.type === "image") {
|
|
8
|
-
if (block.url) return {
|
|
9
|
-
type: "image_url",
|
|
10
|
-
image_url: { url: block.url }
|
|
11
|
-
};
|
|
12
|
-
else if (block.data) return {
|
|
13
|
-
type: "image_url",
|
|
14
|
-
image_url: { url: `data:${block.mimeType};base64,${block.data}` }
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
if (block.type === "audio") {
|
|
18
|
-
if (block.data) {
|
|
19
|
-
const format = require_misc.iife(() => {
|
|
20
|
-
const [, format$1] = block.mimeType.split("/");
|
|
21
|
-
if (format$1 === "wav" || format$1 === "mp3") return format$1;
|
|
22
|
-
return "wav";
|
|
23
|
-
});
|
|
24
|
-
return {
|
|
25
|
-
type: "input_audio",
|
|
26
|
-
input_audio: {
|
|
27
|
-
data: block.data.toString(),
|
|
28
|
-
format
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
if (block.type === "file") {
|
|
34
|
-
if (block.data) return {
|
|
35
|
-
type: "file",
|
|
36
|
-
file: { file_data: block.data.toString() }
|
|
37
|
-
};
|
|
38
|
-
if (block.fileId) return {
|
|
39
|
-
type: "file",
|
|
40
|
-
file: { file_id: block.fileId }
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
return void 0;
|
|
44
|
-
}
|
|
45
|
-
function _convertToCompletionsMessageFromV1(message, model) {
|
|
46
|
-
let role = require_misc.messageToOpenAIRole(message);
|
|
47
|
-
if (role === "system" && require_misc.isReasoningModel(model)) role = "developer";
|
|
48
|
-
if (role === "developer") return {
|
|
49
|
-
role: "developer",
|
|
50
|
-
content: message.contentBlocks.filter((block) => block.type === "text")
|
|
51
|
-
};
|
|
52
|
-
else if (role === "system") return {
|
|
53
|
-
role: "system",
|
|
54
|
-
content: message.contentBlocks.filter((block) => block.type === "text")
|
|
55
|
-
};
|
|
56
|
-
else if (role === "assistant") return {
|
|
57
|
-
role: "assistant",
|
|
58
|
-
content: message.contentBlocks.filter((block) => block.type === "text")
|
|
59
|
-
};
|
|
60
|
-
else if (role === "tool" && __langchain_core_messages.ToolMessage.isInstance(message)) return {
|
|
61
|
-
role: "tool",
|
|
62
|
-
tool_call_id: message.tool_call_id,
|
|
63
|
-
content: message.contentBlocks.filter((block) => block.type === "text")
|
|
64
|
-
};
|
|
65
|
-
else if (role === "function") return {
|
|
66
|
-
role: "function",
|
|
67
|
-
name: message.name ?? "",
|
|
68
|
-
content: message.contentBlocks.filter((block) => block.type === "text").join("")
|
|
69
|
-
};
|
|
70
|
-
function* iterateUserContent(blocks) {
|
|
71
|
-
for (const block of blocks) {
|
|
72
|
-
if (block.type === "text") yield {
|
|
73
|
-
type: "text",
|
|
74
|
-
text: block.text
|
|
75
|
-
};
|
|
76
|
-
const data = _convertToChatCompletionsData(block);
|
|
77
|
-
if (data) yield data;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return {
|
|
81
|
-
role: "user",
|
|
82
|
-
content: Array.from(iterateUserContent(message.contentBlocks))
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
function _convertToResponsesMessageFromV1(message) {
|
|
86
|
-
const isResponsesMessage = (0, __langchain_core_messages.isAIMessage)(message) && message.response_metadata?.model_provider === "openai";
|
|
87
|
-
function* iterateItems() {
|
|
88
|
-
const messageRole = require_misc.iife(() => {
|
|
89
|
-
try {
|
|
90
|
-
const role = require_misc.messageToOpenAIRole(message);
|
|
91
|
-
if (role === "system" || role === "developer" || role === "assistant" || role === "user") return role;
|
|
92
|
-
return "assistant";
|
|
93
|
-
} catch {
|
|
94
|
-
return "assistant";
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
let currentMessage = void 0;
|
|
98
|
-
const functionCallIdsWithBlocks = /* @__PURE__ */ new Set();
|
|
99
|
-
const serverFunctionCallIdsWithBlocks = /* @__PURE__ */ new Set();
|
|
100
|
-
const pendingFunctionChunks = /* @__PURE__ */ new Map();
|
|
101
|
-
const pendingServerFunctionChunks = /* @__PURE__ */ new Map();
|
|
102
|
-
function* flushMessage() {
|
|
103
|
-
if (!currentMessage) return;
|
|
104
|
-
const content = currentMessage.content;
|
|
105
|
-
if (typeof content === "string" && content.length > 0 || Array.isArray(content) && content.length > 0) yield currentMessage;
|
|
106
|
-
currentMessage = void 0;
|
|
107
|
-
}
|
|
108
|
-
const pushMessageContent = (content) => {
|
|
109
|
-
if (!currentMessage) currentMessage = {
|
|
110
|
-
type: "message",
|
|
111
|
-
role: messageRole,
|
|
112
|
-
content: []
|
|
113
|
-
};
|
|
114
|
-
if (typeof currentMessage.content === "string") currentMessage.content = currentMessage.content.length > 0 ? [{
|
|
115
|
-
type: "input_text",
|
|
116
|
-
text: currentMessage.content
|
|
117
|
-
}, ...content] : [...content];
|
|
118
|
-
else currentMessage.content.push(...content);
|
|
119
|
-
};
|
|
120
|
-
const toJsonString = (value) => {
|
|
121
|
-
if (typeof value === "string") return value;
|
|
122
|
-
try {
|
|
123
|
-
return JSON.stringify(value ?? {});
|
|
124
|
-
} catch {
|
|
125
|
-
return "{}";
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
const resolveImageItem = (block) => {
|
|
129
|
-
const detail = require_misc.iife(() => {
|
|
130
|
-
const raw = block.metadata?.detail;
|
|
131
|
-
if (raw === "low" || raw === "high" || raw === "auto") return raw;
|
|
132
|
-
return "auto";
|
|
133
|
-
});
|
|
134
|
-
if (block.fileId) return {
|
|
135
|
-
type: "input_image",
|
|
136
|
-
detail,
|
|
137
|
-
file_id: block.fileId
|
|
138
|
-
};
|
|
139
|
-
if (block.url) return {
|
|
140
|
-
type: "input_image",
|
|
141
|
-
detail,
|
|
142
|
-
image_url: block.url
|
|
143
|
-
};
|
|
144
|
-
if (block.data) {
|
|
145
|
-
const base64Data = typeof block.data === "string" ? block.data : Buffer.from(block.data).toString("base64");
|
|
146
|
-
const mimeType = block.mimeType ?? "image/png";
|
|
147
|
-
return {
|
|
148
|
-
type: "input_image",
|
|
149
|
-
detail,
|
|
150
|
-
image_url: `data:${mimeType};base64,${base64Data}`
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
return void 0;
|
|
154
|
-
};
|
|
155
|
-
const resolveFileItem = (block) => {
|
|
156
|
-
const filename = block.metadata?.filename ?? block.metadata?.name ?? block.metadata?.title;
|
|
157
|
-
if (block.fileId && typeof filename === "string") return {
|
|
158
|
-
type: "input_file",
|
|
159
|
-
file_id: block.fileId,
|
|
160
|
-
...filename ? { filename } : {}
|
|
161
|
-
};
|
|
162
|
-
if (block.url && typeof filename === "string") return {
|
|
163
|
-
type: "input_file",
|
|
164
|
-
file_url: block.url,
|
|
165
|
-
...filename ? { filename } : {}
|
|
166
|
-
};
|
|
167
|
-
if (block.data && typeof filename === "string") {
|
|
168
|
-
const encoded = typeof block.data === "string" ? block.data : Buffer.from(block.data).toString("base64");
|
|
169
|
-
const mimeType = block.mimeType ?? "application/octet-stream";
|
|
170
|
-
return {
|
|
171
|
-
type: "input_file",
|
|
172
|
-
file_data: `data:${mimeType};base64,${encoded}`,
|
|
173
|
-
...filename ? { filename } : {}
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
return void 0;
|
|
177
|
-
};
|
|
178
|
-
const convertReasoningBlock = (block) => {
|
|
179
|
-
const summaryEntries = require_misc.iife(() => {
|
|
180
|
-
if (Array.isArray(block.summary)) {
|
|
181
|
-
const candidate = block.summary;
|
|
182
|
-
const mapped = candidate?.map((item) => item?.text).filter((text) => typeof text === "string") ?? [];
|
|
183
|
-
if (mapped.length > 0) return mapped;
|
|
184
|
-
}
|
|
185
|
-
return block.reasoning ? [block.reasoning] : [];
|
|
186
|
-
});
|
|
187
|
-
const summary = summaryEntries.length > 0 ? summaryEntries.map((text) => ({
|
|
188
|
-
type: "summary_text",
|
|
189
|
-
text
|
|
190
|
-
})) : [{
|
|
191
|
-
type: "summary_text",
|
|
192
|
-
text: ""
|
|
193
|
-
}];
|
|
194
|
-
const reasoningItem = {
|
|
195
|
-
type: "reasoning",
|
|
196
|
-
id: block.id ?? "",
|
|
197
|
-
summary
|
|
198
|
-
};
|
|
199
|
-
if (block.reasoning) reasoningItem.content = [{
|
|
200
|
-
type: "reasoning_text",
|
|
201
|
-
text: block.reasoning
|
|
202
|
-
}];
|
|
203
|
-
return reasoningItem;
|
|
204
|
-
};
|
|
205
|
-
const convertFunctionCall = (block) => ({
|
|
206
|
-
type: "function_call",
|
|
207
|
-
name: block.name ?? "",
|
|
208
|
-
call_id: block.id ?? "",
|
|
209
|
-
arguments: toJsonString(block.args)
|
|
210
|
-
});
|
|
211
|
-
const convertFunctionCallOutput = (block) => {
|
|
212
|
-
const output = toJsonString(block.output);
|
|
213
|
-
const status = block.status === "success" ? "completed" : block.status === "error" ? "incomplete" : void 0;
|
|
214
|
-
return {
|
|
215
|
-
type: "function_call_output",
|
|
216
|
-
call_id: block.toolCallId ?? "",
|
|
217
|
-
output,
|
|
218
|
-
...status ? { status } : {}
|
|
219
|
-
};
|
|
220
|
-
};
|
|
221
|
-
for (const block of message.contentBlocks) if (block.type === "text") pushMessageContent([{
|
|
222
|
-
type: "input_text",
|
|
223
|
-
text: block.text
|
|
224
|
-
}]);
|
|
225
|
-
else if (block.type === "invalid_tool_call") {} else if (block.type === "reasoning") {
|
|
226
|
-
yield* flushMessage();
|
|
227
|
-
yield convertReasoningBlock(block);
|
|
228
|
-
} else if (block.type === "tool_call") {
|
|
229
|
-
yield* flushMessage();
|
|
230
|
-
const id = block.id ?? "";
|
|
231
|
-
if (id) {
|
|
232
|
-
functionCallIdsWithBlocks.add(id);
|
|
233
|
-
pendingFunctionChunks.delete(id);
|
|
234
|
-
}
|
|
235
|
-
yield convertFunctionCall(block);
|
|
236
|
-
} else if (block.type === "tool_call_chunk") {
|
|
237
|
-
if (block.id) {
|
|
238
|
-
const existing = pendingFunctionChunks.get(block.id) ?? {
|
|
239
|
-
name: block.name,
|
|
240
|
-
args: []
|
|
241
|
-
};
|
|
242
|
-
if (block.name) existing.name = block.name;
|
|
243
|
-
if (block.args) existing.args.push(block.args);
|
|
244
|
-
pendingFunctionChunks.set(block.id, existing);
|
|
245
|
-
}
|
|
246
|
-
} else if (block.type === "server_tool_call") {
|
|
247
|
-
yield* flushMessage();
|
|
248
|
-
const id = block.id ?? "";
|
|
249
|
-
if (id) {
|
|
250
|
-
serverFunctionCallIdsWithBlocks.add(id);
|
|
251
|
-
pendingServerFunctionChunks.delete(id);
|
|
252
|
-
}
|
|
253
|
-
yield convertFunctionCall(block);
|
|
254
|
-
} else if (block.type === "server_tool_call_chunk") {
|
|
255
|
-
if (block.id) {
|
|
256
|
-
const existing = pendingServerFunctionChunks.get(block.id) ?? {
|
|
257
|
-
name: block.name,
|
|
258
|
-
args: []
|
|
259
|
-
};
|
|
260
|
-
if (block.name) existing.name = block.name;
|
|
261
|
-
if (block.args) existing.args.push(block.args);
|
|
262
|
-
pendingServerFunctionChunks.set(block.id, existing);
|
|
263
|
-
}
|
|
264
|
-
} else if (block.type === "server_tool_call_result") {
|
|
265
|
-
yield* flushMessage();
|
|
266
|
-
yield convertFunctionCallOutput(block);
|
|
267
|
-
} else if (block.type === "audio") {} else if (block.type === "file") {
|
|
268
|
-
const fileItem = resolveFileItem(block);
|
|
269
|
-
if (fileItem) pushMessageContent([fileItem]);
|
|
270
|
-
} else if (block.type === "image") {
|
|
271
|
-
const imageItem = resolveImageItem(block);
|
|
272
|
-
if (imageItem) pushMessageContent([imageItem]);
|
|
273
|
-
} else if (block.type === "video") {
|
|
274
|
-
const videoItem = resolveFileItem(block);
|
|
275
|
-
if (videoItem) pushMessageContent([videoItem]);
|
|
276
|
-
} else if (block.type === "text-plain") {
|
|
277
|
-
if (block.text) pushMessageContent([{
|
|
278
|
-
type: "input_text",
|
|
279
|
-
text: block.text
|
|
280
|
-
}]);
|
|
281
|
-
} else if (block.type === "non_standard" && isResponsesMessage) {
|
|
282
|
-
yield* flushMessage();
|
|
283
|
-
yield block.value;
|
|
284
|
-
}
|
|
285
|
-
yield* flushMessage();
|
|
286
|
-
for (const [id, chunk] of pendingFunctionChunks) {
|
|
287
|
-
if (!id || functionCallIdsWithBlocks.has(id)) continue;
|
|
288
|
-
const args = chunk.args.join("");
|
|
289
|
-
if (!chunk.name && !args) continue;
|
|
290
|
-
yield {
|
|
291
|
-
type: "function_call",
|
|
292
|
-
call_id: id,
|
|
293
|
-
name: chunk.name ?? "",
|
|
294
|
-
arguments: args
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
for (const [id, chunk] of pendingServerFunctionChunks) {
|
|
298
|
-
if (!id || serverFunctionCallIdsWithBlocks.has(id)) continue;
|
|
299
|
-
const args = chunk.args.join("");
|
|
300
|
-
if (!chunk.name && !args) continue;
|
|
301
|
-
yield {
|
|
302
|
-
type: "function_call",
|
|
303
|
-
call_id: id,
|
|
304
|
-
name: chunk.name ?? "",
|
|
305
|
-
arguments: args
|
|
306
|
-
};
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
return Array.from(iterateItems());
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
//#endregion
|
|
313
|
-
exports._convertToCompletionsMessageFromV1 = _convertToCompletionsMessageFromV1;
|
|
314
|
-
exports._convertToResponsesMessageFromV1 = _convertToResponsesMessageFromV1;
|
|
315
|
-
//# sourceMappingURL=standard.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"standard.cjs","names":["block: ContentBlock.Standard","iife","format","message: BaseMessage","model?: string","messageToOpenAIRole","isReasoningModel","ToolMessage","blocks: ContentBlock.Standard[]","currentMessage: OpenAIClient.Responses.EasyInputMessage | undefined","pushMessageContent: (\n content: OpenAIClient.Responses.ResponseInputMessageContentList\n ) => void","value: unknown","block: ContentBlock.Multimodal.Image","block: ContentBlock.Multimodal.File | ContentBlock.Multimodal.Video","block: ContentBlock.Reasoning","reasoningItem: OpenAIClient.Responses.ResponseReasoningItem","block: ContentBlock.Tools.ToolCall | ContentBlock.Tools.ServerToolCall","block: ContentBlock.Tools.ServerToolCallResult"],"sources":["../../src/utils/standard.ts"],"sourcesContent":["import type { OpenAI as OpenAIClient } from \"openai\";\nimport {\n isAIMessage,\n BaseMessage,\n ToolMessage,\n type ContentBlock,\n} from \"@langchain/core/messages\";\nimport { iife, isReasoningModel, messageToOpenAIRole } from \"./misc.js\";\n\nexport type ResponsesInputItem = OpenAIClient.Responses.ResponseInputItem;\n\ntype ChatCompletionContentData =\n | OpenAIClient.Chat.Completions.ChatCompletionContentPartImage\n | OpenAIClient.Chat.Completions.ChatCompletionContentPartInputAudio\n | OpenAIClient.Chat.Completions.ChatCompletionContentPart.File;\n\nfunction _convertToChatCompletionsData(\n block: ContentBlock.Standard\n): ChatCompletionContentData | undefined {\n if (block.type === \"image\") {\n if (block.url) {\n return {\n type: \"image_url\",\n image_url: {\n url: block.url,\n },\n };\n } else if (block.data) {\n return {\n type: \"image_url\",\n image_url: {\n url: `data:${block.mimeType};base64,${block.data}`,\n },\n };\n }\n }\n if (block.type === \"audio\") {\n if (block.data) {\n const format = iife(() => {\n const [, format] = block.mimeType.split(\"/\");\n if (format === \"wav\" || format === \"mp3\") {\n return format;\n }\n return \"wav\";\n });\n return {\n type: \"input_audio\",\n input_audio: {\n data: block.data.toString(),\n format,\n },\n };\n }\n }\n if (block.type === \"file\") {\n if (block.data) {\n return {\n type: \"file\",\n file: {\n file_data: block.data.toString(),\n },\n };\n }\n if (block.fileId) {\n return {\n type: \"file\",\n file: {\n file_id: block.fileId,\n },\n };\n }\n }\n return undefined;\n}\n\nexport function _convertToCompletionsMessageFromV1(\n message: BaseMessage,\n model?: string\n): OpenAIClient.Chat.Completions.ChatCompletionMessageParam {\n let role = messageToOpenAIRole(message);\n if (role === \"system\" && isReasoningModel(model)) {\n role = \"developer\";\n }\n if (role === \"developer\") {\n return {\n role: \"developer\",\n content: message.contentBlocks.filter((block) => block.type === \"text\"),\n };\n } else if (role === \"system\") {\n return {\n role: \"system\",\n content: message.contentBlocks.filter((block) => block.type === \"text\"),\n };\n } else if (role === \"assistant\") {\n return {\n role: \"assistant\",\n content: message.contentBlocks.filter((block) => block.type === \"text\"),\n };\n } else if (role === \"tool\" && ToolMessage.isInstance(message)) {\n return {\n role: \"tool\",\n tool_call_id: message.tool_call_id,\n content: message.contentBlocks.filter((block) => block.type === \"text\"),\n };\n } else if (role === \"function\") {\n return {\n role: \"function\",\n name: message.name ?? \"\",\n content: message.contentBlocks\n .filter((block) => block.type === \"text\")\n .join(\"\"),\n };\n }\n // Default to user message handling\n function* iterateUserContent(blocks: ContentBlock.Standard[]) {\n for (const block of blocks) {\n if (block.type === \"text\") {\n yield {\n type: \"text\" as const,\n text: block.text,\n };\n }\n const data = _convertToChatCompletionsData(block);\n if (data) {\n yield data;\n }\n }\n }\n return {\n role: \"user\",\n content: Array.from(iterateUserContent(message.contentBlocks)),\n };\n}\n\nexport function _convertToResponsesMessageFromV1(message: BaseMessage) {\n const isResponsesMessage =\n isAIMessage(message) &&\n message.response_metadata?.model_provider === \"openai\";\n\n function* iterateItems(): Generator<OpenAIClient.Responses.ResponseInputItem> {\n const messageRole = iife(() => {\n try {\n const role = messageToOpenAIRole(message);\n if (\n role === \"system\" ||\n role === \"developer\" ||\n role === \"assistant\" ||\n role === \"user\"\n ) {\n return role;\n }\n return \"assistant\";\n } catch {\n return \"assistant\";\n }\n });\n\n let currentMessage: OpenAIClient.Responses.EasyInputMessage | undefined =\n undefined;\n\n const functionCallIdsWithBlocks = new Set<string>();\n const serverFunctionCallIdsWithBlocks = new Set<string>();\n\n const pendingFunctionChunks = new Map<\n string,\n { name?: string; args: string[] }\n >();\n const pendingServerFunctionChunks = new Map<\n string,\n { name?: string; args: string[] }\n >();\n\n function* flushMessage() {\n if (!currentMessage) return;\n const content = currentMessage.content;\n if (\n (typeof content === \"string\" && content.length > 0) ||\n (Array.isArray(content) && content.length > 0)\n ) {\n yield currentMessage;\n }\n currentMessage = undefined;\n }\n\n const pushMessageContent: (\n content: OpenAIClient.Responses.ResponseInputMessageContentList\n ) => void = (content) => {\n if (!currentMessage) {\n currentMessage = {\n type: \"message\",\n role: messageRole,\n content: [],\n };\n }\n if (typeof currentMessage.content === \"string\") {\n currentMessage.content =\n currentMessage.content.length > 0\n ? [{ type: \"input_text\", text: currentMessage.content }, ...content]\n : [...content];\n } else {\n currentMessage.content.push(...content);\n }\n };\n\n const toJsonString = (value: unknown) => {\n if (typeof value === \"string\") {\n return value;\n }\n try {\n return JSON.stringify(value ?? {});\n } catch {\n return \"{}\";\n }\n };\n\n const resolveImageItem = (\n block: ContentBlock.Multimodal.Image\n ): OpenAIClient.Responses.ResponseInputImage | undefined => {\n const detail = iife(() => {\n const raw = block.metadata?.detail;\n if (raw === \"low\" || raw === \"high\" || raw === \"auto\") {\n return raw;\n }\n return \"auto\";\n });\n if (block.fileId) {\n return {\n type: \"input_image\",\n detail,\n file_id: block.fileId,\n };\n }\n if (block.url) {\n return {\n type: \"input_image\",\n detail,\n image_url: block.url,\n };\n }\n if (block.data) {\n const base64Data =\n typeof block.data === \"string\"\n ? block.data\n : Buffer.from(block.data).toString(\"base64\");\n const mimeType = block.mimeType ?? \"image/png\";\n return {\n type: \"input_image\",\n detail,\n image_url: `data:${mimeType};base64,${base64Data}`,\n };\n }\n return undefined;\n };\n\n const resolveFileItem = (\n block: ContentBlock.Multimodal.File | ContentBlock.Multimodal.Video\n ): OpenAIClient.Responses.ResponseInputFile | undefined => {\n const filename =\n block.metadata?.filename ??\n block.metadata?.name ??\n block.metadata?.title;\n if (block.fileId && typeof filename === \"string\") {\n return {\n type: \"input_file\",\n file_id: block.fileId,\n ...(filename ? { filename } : {}),\n };\n }\n if (block.url && typeof filename === \"string\") {\n return {\n type: \"input_file\",\n file_url: block.url,\n ...(filename ? { filename } : {}),\n };\n }\n if (block.data && typeof filename === \"string\") {\n const encoded =\n typeof block.data === \"string\"\n ? block.data\n : Buffer.from(block.data).toString(\"base64\");\n const mimeType = block.mimeType ?? \"application/octet-stream\";\n return {\n type: \"input_file\",\n file_data: `data:${mimeType};base64,${encoded}`,\n ...(filename ? { filename } : {}),\n };\n }\n return undefined;\n };\n\n const convertReasoningBlock = (\n block: ContentBlock.Reasoning\n ): OpenAIClient.Responses.ResponseReasoningItem => {\n const summaryEntries = iife(() => {\n if (Array.isArray(block.summary)) {\n const candidate = block.summary;\n const mapped =\n candidate\n ?.map((item) => item?.text)\n .filter((text): text is string => typeof text === \"string\") ?? [];\n if (mapped.length > 0) {\n return mapped;\n }\n }\n return block.reasoning ? [block.reasoning] : [];\n });\n\n const summary =\n summaryEntries.length > 0\n ? summaryEntries.map((text) => ({\n type: \"summary_text\" as const,\n text,\n }))\n : [{ type: \"summary_text\" as const, text: \"\" }];\n\n const reasoningItem: OpenAIClient.Responses.ResponseReasoningItem = {\n type: \"reasoning\",\n id: block.id ?? \"\",\n summary,\n };\n\n if (block.reasoning) {\n reasoningItem.content = [\n {\n type: \"reasoning_text\" as const,\n text: block.reasoning,\n },\n ];\n }\n return reasoningItem;\n };\n\n const convertFunctionCall = (\n block: ContentBlock.Tools.ToolCall | ContentBlock.Tools.ServerToolCall\n ): OpenAIClient.Responses.ResponseFunctionToolCall => ({\n type: \"function_call\",\n name: block.name ?? \"\",\n call_id: block.id ?? \"\",\n arguments: toJsonString(block.args),\n });\n\n const convertFunctionCallOutput = (\n block: ContentBlock.Tools.ServerToolCallResult\n ): OpenAIClient.Responses.ResponseInputItem.FunctionCallOutput => {\n const output = toJsonString(block.output);\n const status =\n block.status === \"success\"\n ? \"completed\"\n : block.status === \"error\"\n ? \"incomplete\"\n : undefined;\n return {\n type: \"function_call_output\",\n call_id: block.toolCallId ?? \"\",\n output,\n ...(status ? { status } : {}),\n };\n };\n\n for (const block of message.contentBlocks) {\n if (block.type === \"text\") {\n pushMessageContent([{ type: \"input_text\", text: block.text }]);\n } else if (block.type === \"invalid_tool_call\") {\n // no-op\n } else if (block.type === \"reasoning\") {\n yield* flushMessage();\n yield convertReasoningBlock(\n block as ContentBlock.Standard & { type: \"reasoning\" }\n );\n } else if (block.type === \"tool_call\") {\n yield* flushMessage();\n const id = block.id ?? \"\";\n if (id) {\n functionCallIdsWithBlocks.add(id);\n pendingFunctionChunks.delete(id);\n }\n yield convertFunctionCall(\n block as ContentBlock.Standard & { type: \"tool_call\" }\n );\n } else if (block.type === \"tool_call_chunk\") {\n if (block.id) {\n const existing = pendingFunctionChunks.get(block.id) ?? {\n name: block.name,\n args: [],\n };\n if (block.name) existing.name = block.name;\n if (block.args) existing.args.push(block.args);\n pendingFunctionChunks.set(block.id, existing);\n }\n } else if (block.type === \"server_tool_call\") {\n yield* flushMessage();\n const id = block.id ?? \"\";\n if (id) {\n serverFunctionCallIdsWithBlocks.add(id);\n pendingServerFunctionChunks.delete(id);\n }\n yield convertFunctionCall(block);\n } else if (block.type === \"server_tool_call_chunk\") {\n if (block.id) {\n const existing = pendingServerFunctionChunks.get(block.id) ?? {\n name: block.name,\n args: [],\n };\n if (block.name) existing.name = block.name;\n if (block.args) existing.args.push(block.args);\n pendingServerFunctionChunks.set(block.id, existing);\n }\n } else if (block.type === \"server_tool_call_result\") {\n yield* flushMessage();\n yield convertFunctionCallOutput(block);\n } else if (block.type === \"audio\") {\n // no-op\n } else if (block.type === \"file\") {\n const fileItem = resolveFileItem(block);\n if (fileItem) {\n pushMessageContent([fileItem]);\n }\n } else if (block.type === \"image\") {\n const imageItem = resolveImageItem(block);\n if (imageItem) {\n pushMessageContent([imageItem]);\n }\n } else if (block.type === \"video\") {\n const videoItem = resolveFileItem(block);\n if (videoItem) {\n pushMessageContent([videoItem]);\n }\n } else if (block.type === \"text-plain\") {\n if (block.text) {\n pushMessageContent([\n {\n type: \"input_text\",\n text: block.text,\n },\n ]);\n }\n } else if (block.type === \"non_standard\" && isResponsesMessage) {\n yield* flushMessage();\n yield block.value as ResponsesInputItem;\n }\n }\n yield* flushMessage();\n\n for (const [id, chunk] of pendingFunctionChunks) {\n if (!id || functionCallIdsWithBlocks.has(id)) continue;\n const args = chunk.args.join(\"\");\n if (!chunk.name && !args) continue;\n yield {\n type: \"function_call\",\n call_id: id,\n name: chunk.name ?? \"\",\n arguments: args,\n };\n }\n\n for (const [id, chunk] of pendingServerFunctionChunks) {\n if (!id || serverFunctionCallIdsWithBlocks.has(id)) continue;\n const args = chunk.args.join(\"\");\n if (!chunk.name && !args) continue;\n yield {\n type: \"function_call\",\n call_id: id,\n name: chunk.name ?? \"\",\n arguments: args,\n };\n }\n }\n return Array.from(iterateItems());\n}\n"],"mappings":";;;;;AAgBA,SAAS,8BACPA,OACuC;AACvC,KAAI,MAAM,SAAS,SACjB;MAAI,MAAM,IACR,QAAO;GACL,MAAM;GACN,WAAW,EACT,KAAK,MAAM,IACZ;EACF;WACQ,MAAM,KACf,QAAO;GACL,MAAM;GACN,WAAW,EACT,KAAK,CAAC,KAAK,EAAE,MAAM,SAAS,QAAQ,EAAE,MAAM,MAAM,CACnD;EACF;CACF;AAEH,KAAI,MAAM,SAAS,SACjB;MAAI,MAAM,MAAM;GACd,MAAM,SAASC,kBAAK,MAAM;IACxB,MAAM,GAAGC,SAAO,GAAG,MAAM,SAAS,MAAM,IAAI;AAC5C,QAAIA,aAAW,SAASA,aAAW,MACjC,QAAOA;AAET,WAAO;GACR,EAAC;AACF,UAAO;IACL,MAAM;IACN,aAAa;KACX,MAAM,MAAM,KAAK,UAAU;KAC3B;IACD;GACF;EACF;;AAEH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