@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
package/dist/utils/standard.js
DELETED
|
@@ -1,313 +0,0 @@
|
|
|
1
|
-
import { iife, isReasoningModel, messageToOpenAIRole } from "./misc.js";
|
|
2
|
-
import { ToolMessage, isAIMessage } from "@langchain/core/messages";
|
|
3
|
-
|
|
4
|
-
//#region src/utils/standard.ts
|
|
5
|
-
function _convertToChatCompletionsData(block) {
|
|
6
|
-
if (block.type === "image") {
|
|
7
|
-
if (block.url) return {
|
|
8
|
-
type: "image_url",
|
|
9
|
-
image_url: { url: block.url }
|
|
10
|
-
};
|
|
11
|
-
else if (block.data) return {
|
|
12
|
-
type: "image_url",
|
|
13
|
-
image_url: { url: `data:${block.mimeType};base64,${block.data}` }
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
if (block.type === "audio") {
|
|
17
|
-
if (block.data) {
|
|
18
|
-
const format = iife(() => {
|
|
19
|
-
const [, format$1] = block.mimeType.split("/");
|
|
20
|
-
if (format$1 === "wav" || format$1 === "mp3") return format$1;
|
|
21
|
-
return "wav";
|
|
22
|
-
});
|
|
23
|
-
return {
|
|
24
|
-
type: "input_audio",
|
|
25
|
-
input_audio: {
|
|
26
|
-
data: block.data.toString(),
|
|
27
|
-
format
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
if (block.type === "file") {
|
|
33
|
-
if (block.data) return {
|
|
34
|
-
type: "file",
|
|
35
|
-
file: { file_data: block.data.toString() }
|
|
36
|
-
};
|
|
37
|
-
if (block.fileId) return {
|
|
38
|
-
type: "file",
|
|
39
|
-
file: { file_id: block.fileId }
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
return void 0;
|
|
43
|
-
}
|
|
44
|
-
function _convertToCompletionsMessageFromV1(message, model) {
|
|
45
|
-
let role = messageToOpenAIRole(message);
|
|
46
|
-
if (role === "system" && isReasoningModel(model)) role = "developer";
|
|
47
|
-
if (role === "developer") return {
|
|
48
|
-
role: "developer",
|
|
49
|
-
content: message.contentBlocks.filter((block) => block.type === "text")
|
|
50
|
-
};
|
|
51
|
-
else if (role === "system") return {
|
|
52
|
-
role: "system",
|
|
53
|
-
content: message.contentBlocks.filter((block) => block.type === "text")
|
|
54
|
-
};
|
|
55
|
-
else if (role === "assistant") return {
|
|
56
|
-
role: "assistant",
|
|
57
|
-
content: message.contentBlocks.filter((block) => block.type === "text")
|
|
58
|
-
};
|
|
59
|
-
else if (role === "tool" && ToolMessage.isInstance(message)) return {
|
|
60
|
-
role: "tool",
|
|
61
|
-
tool_call_id: message.tool_call_id,
|
|
62
|
-
content: message.contentBlocks.filter((block) => block.type === "text")
|
|
63
|
-
};
|
|
64
|
-
else if (role === "function") return {
|
|
65
|
-
role: "function",
|
|
66
|
-
name: message.name ?? "",
|
|
67
|
-
content: message.contentBlocks.filter((block) => block.type === "text").join("")
|
|
68
|
-
};
|
|
69
|
-
function* iterateUserContent(blocks) {
|
|
70
|
-
for (const block of blocks) {
|
|
71
|
-
if (block.type === "text") yield {
|
|
72
|
-
type: "text",
|
|
73
|
-
text: block.text
|
|
74
|
-
};
|
|
75
|
-
const data = _convertToChatCompletionsData(block);
|
|
76
|
-
if (data) yield data;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return {
|
|
80
|
-
role: "user",
|
|
81
|
-
content: Array.from(iterateUserContent(message.contentBlocks))
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
function _convertToResponsesMessageFromV1(message) {
|
|
85
|
-
const isResponsesMessage = isAIMessage(message) && message.response_metadata?.model_provider === "openai";
|
|
86
|
-
function* iterateItems() {
|
|
87
|
-
const messageRole = iife(() => {
|
|
88
|
-
try {
|
|
89
|
-
const role = messageToOpenAIRole(message);
|
|
90
|
-
if (role === "system" || role === "developer" || role === "assistant" || role === "user") return role;
|
|
91
|
-
return "assistant";
|
|
92
|
-
} catch {
|
|
93
|
-
return "assistant";
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
let currentMessage = void 0;
|
|
97
|
-
const functionCallIdsWithBlocks = /* @__PURE__ */ new Set();
|
|
98
|
-
const serverFunctionCallIdsWithBlocks = /* @__PURE__ */ new Set();
|
|
99
|
-
const pendingFunctionChunks = /* @__PURE__ */ new Map();
|
|
100
|
-
const pendingServerFunctionChunks = /* @__PURE__ */ new Map();
|
|
101
|
-
function* flushMessage() {
|
|
102
|
-
if (!currentMessage) return;
|
|
103
|
-
const content = currentMessage.content;
|
|
104
|
-
if (typeof content === "string" && content.length > 0 || Array.isArray(content) && content.length > 0) yield currentMessage;
|
|
105
|
-
currentMessage = void 0;
|
|
106
|
-
}
|
|
107
|
-
const pushMessageContent = (content) => {
|
|
108
|
-
if (!currentMessage) currentMessage = {
|
|
109
|
-
type: "message",
|
|
110
|
-
role: messageRole,
|
|
111
|
-
content: []
|
|
112
|
-
};
|
|
113
|
-
if (typeof currentMessage.content === "string") currentMessage.content = currentMessage.content.length > 0 ? [{
|
|
114
|
-
type: "input_text",
|
|
115
|
-
text: currentMessage.content
|
|
116
|
-
}, ...content] : [...content];
|
|
117
|
-
else currentMessage.content.push(...content);
|
|
118
|
-
};
|
|
119
|
-
const toJsonString = (value) => {
|
|
120
|
-
if (typeof value === "string") return value;
|
|
121
|
-
try {
|
|
122
|
-
return JSON.stringify(value ?? {});
|
|
123
|
-
} catch {
|
|
124
|
-
return "{}";
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
const resolveImageItem = (block) => {
|
|
128
|
-
const detail = iife(() => {
|
|
129
|
-
const raw = block.metadata?.detail;
|
|
130
|
-
if (raw === "low" || raw === "high" || raw === "auto") return raw;
|
|
131
|
-
return "auto";
|
|
132
|
-
});
|
|
133
|
-
if (block.fileId) return {
|
|
134
|
-
type: "input_image",
|
|
135
|
-
detail,
|
|
136
|
-
file_id: block.fileId
|
|
137
|
-
};
|
|
138
|
-
if (block.url) return {
|
|
139
|
-
type: "input_image",
|
|
140
|
-
detail,
|
|
141
|
-
image_url: block.url
|
|
142
|
-
};
|
|
143
|
-
if (block.data) {
|
|
144
|
-
const base64Data = typeof block.data === "string" ? block.data : Buffer.from(block.data).toString("base64");
|
|
145
|
-
const mimeType = block.mimeType ?? "image/png";
|
|
146
|
-
return {
|
|
147
|
-
type: "input_image",
|
|
148
|
-
detail,
|
|
149
|
-
image_url: `data:${mimeType};base64,${base64Data}`
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
return void 0;
|
|
153
|
-
};
|
|
154
|
-
const resolveFileItem = (block) => {
|
|
155
|
-
const filename = block.metadata?.filename ?? block.metadata?.name ?? block.metadata?.title;
|
|
156
|
-
if (block.fileId && typeof filename === "string") return {
|
|
157
|
-
type: "input_file",
|
|
158
|
-
file_id: block.fileId,
|
|
159
|
-
...filename ? { filename } : {}
|
|
160
|
-
};
|
|
161
|
-
if (block.url && typeof filename === "string") return {
|
|
162
|
-
type: "input_file",
|
|
163
|
-
file_url: block.url,
|
|
164
|
-
...filename ? { filename } : {}
|
|
165
|
-
};
|
|
166
|
-
if (block.data && typeof filename === "string") {
|
|
167
|
-
const encoded = typeof block.data === "string" ? block.data : Buffer.from(block.data).toString("base64");
|
|
168
|
-
const mimeType = block.mimeType ?? "application/octet-stream";
|
|
169
|
-
return {
|
|
170
|
-
type: "input_file",
|
|
171
|
-
file_data: `data:${mimeType};base64,${encoded}`,
|
|
172
|
-
...filename ? { filename } : {}
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
return void 0;
|
|
176
|
-
};
|
|
177
|
-
const convertReasoningBlock = (block) => {
|
|
178
|
-
const summaryEntries = iife(() => {
|
|
179
|
-
if (Array.isArray(block.summary)) {
|
|
180
|
-
const candidate = block.summary;
|
|
181
|
-
const mapped = candidate?.map((item) => item?.text).filter((text) => typeof text === "string") ?? [];
|
|
182
|
-
if (mapped.length > 0) return mapped;
|
|
183
|
-
}
|
|
184
|
-
return block.reasoning ? [block.reasoning] : [];
|
|
185
|
-
});
|
|
186
|
-
const summary = summaryEntries.length > 0 ? summaryEntries.map((text) => ({
|
|
187
|
-
type: "summary_text",
|
|
188
|
-
text
|
|
189
|
-
})) : [{
|
|
190
|
-
type: "summary_text",
|
|
191
|
-
text: ""
|
|
192
|
-
}];
|
|
193
|
-
const reasoningItem = {
|
|
194
|
-
type: "reasoning",
|
|
195
|
-
id: block.id ?? "",
|
|
196
|
-
summary
|
|
197
|
-
};
|
|
198
|
-
if (block.reasoning) reasoningItem.content = [{
|
|
199
|
-
type: "reasoning_text",
|
|
200
|
-
text: block.reasoning
|
|
201
|
-
}];
|
|
202
|
-
return reasoningItem;
|
|
203
|
-
};
|
|
204
|
-
const convertFunctionCall = (block) => ({
|
|
205
|
-
type: "function_call",
|
|
206
|
-
name: block.name ?? "",
|
|
207
|
-
call_id: block.id ?? "",
|
|
208
|
-
arguments: toJsonString(block.args)
|
|
209
|
-
});
|
|
210
|
-
const convertFunctionCallOutput = (block) => {
|
|
211
|
-
const output = toJsonString(block.output);
|
|
212
|
-
const status = block.status === "success" ? "completed" : block.status === "error" ? "incomplete" : void 0;
|
|
213
|
-
return {
|
|
214
|
-
type: "function_call_output",
|
|
215
|
-
call_id: block.toolCallId ?? "",
|
|
216
|
-
output,
|
|
217
|
-
...status ? { status } : {}
|
|
218
|
-
};
|
|
219
|
-
};
|
|
220
|
-
for (const block of message.contentBlocks) if (block.type === "text") pushMessageContent([{
|
|
221
|
-
type: "input_text",
|
|
222
|
-
text: block.text
|
|
223
|
-
}]);
|
|
224
|
-
else if (block.type === "invalid_tool_call") {} else if (block.type === "reasoning") {
|
|
225
|
-
yield* flushMessage();
|
|
226
|
-
yield convertReasoningBlock(block);
|
|
227
|
-
} else if (block.type === "tool_call") {
|
|
228
|
-
yield* flushMessage();
|
|
229
|
-
const id = block.id ?? "";
|
|
230
|
-
if (id) {
|
|
231
|
-
functionCallIdsWithBlocks.add(id);
|
|
232
|
-
pendingFunctionChunks.delete(id);
|
|
233
|
-
}
|
|
234
|
-
yield convertFunctionCall(block);
|
|
235
|
-
} else if (block.type === "tool_call_chunk") {
|
|
236
|
-
if (block.id) {
|
|
237
|
-
const existing = pendingFunctionChunks.get(block.id) ?? {
|
|
238
|
-
name: block.name,
|
|
239
|
-
args: []
|
|
240
|
-
};
|
|
241
|
-
if (block.name) existing.name = block.name;
|
|
242
|
-
if (block.args) existing.args.push(block.args);
|
|
243
|
-
pendingFunctionChunks.set(block.id, existing);
|
|
244
|
-
}
|
|
245
|
-
} else if (block.type === "server_tool_call") {
|
|
246
|
-
yield* flushMessage();
|
|
247
|
-
const id = block.id ?? "";
|
|
248
|
-
if (id) {
|
|
249
|
-
serverFunctionCallIdsWithBlocks.add(id);
|
|
250
|
-
pendingServerFunctionChunks.delete(id);
|
|
251
|
-
}
|
|
252
|
-
yield convertFunctionCall(block);
|
|
253
|
-
} else if (block.type === "server_tool_call_chunk") {
|
|
254
|
-
if (block.id) {
|
|
255
|
-
const existing = pendingServerFunctionChunks.get(block.id) ?? {
|
|
256
|
-
name: block.name,
|
|
257
|
-
args: []
|
|
258
|
-
};
|
|
259
|
-
if (block.name) existing.name = block.name;
|
|
260
|
-
if (block.args) existing.args.push(block.args);
|
|
261
|
-
pendingServerFunctionChunks.set(block.id, existing);
|
|
262
|
-
}
|
|
263
|
-
} else if (block.type === "server_tool_call_result") {
|
|
264
|
-
yield* flushMessage();
|
|
265
|
-
yield convertFunctionCallOutput(block);
|
|
266
|
-
} else if (block.type === "audio") {} else if (block.type === "file") {
|
|
267
|
-
const fileItem = resolveFileItem(block);
|
|
268
|
-
if (fileItem) pushMessageContent([fileItem]);
|
|
269
|
-
} else if (block.type === "image") {
|
|
270
|
-
const imageItem = resolveImageItem(block);
|
|
271
|
-
if (imageItem) pushMessageContent([imageItem]);
|
|
272
|
-
} else if (block.type === "video") {
|
|
273
|
-
const videoItem = resolveFileItem(block);
|
|
274
|
-
if (videoItem) pushMessageContent([videoItem]);
|
|
275
|
-
} else if (block.type === "text-plain") {
|
|
276
|
-
if (block.text) pushMessageContent([{
|
|
277
|
-
type: "input_text",
|
|
278
|
-
text: block.text
|
|
279
|
-
}]);
|
|
280
|
-
} else if (block.type === "non_standard" && isResponsesMessage) {
|
|
281
|
-
yield* flushMessage();
|
|
282
|
-
yield block.value;
|
|
283
|
-
}
|
|
284
|
-
yield* flushMessage();
|
|
285
|
-
for (const [id, chunk] of pendingFunctionChunks) {
|
|
286
|
-
if (!id || functionCallIdsWithBlocks.has(id)) continue;
|
|
287
|
-
const args = chunk.args.join("");
|
|
288
|
-
if (!chunk.name && !args) continue;
|
|
289
|
-
yield {
|
|
290
|
-
type: "function_call",
|
|
291
|
-
call_id: id,
|
|
292
|
-
name: chunk.name ?? "",
|
|
293
|
-
arguments: args
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
for (const [id, chunk] of pendingServerFunctionChunks) {
|
|
297
|
-
if (!id || serverFunctionCallIdsWithBlocks.has(id)) continue;
|
|
298
|
-
const args = chunk.args.join("");
|
|
299
|
-
if (!chunk.name && !args) continue;
|
|
300
|
-
yield {
|
|
301
|
-
type: "function_call",
|
|
302
|
-
call_id: id,
|
|
303
|
-
name: chunk.name ?? "",
|
|
304
|
-
arguments: args
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
return Array.from(iterateItems());
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
//#endregion
|
|
312
|
-
export { _convertToCompletionsMessageFromV1, _convertToResponsesMessageFromV1 };
|
|
313
|
-
//# sourceMappingURL=standard.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"standard.js","names":["block: ContentBlock.Standard","format","message: BaseMessage","model?: string","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,SAAS,KAAK,MAAM;IACxB,MAAM,GAAGC,SAAO,GAA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