@standardagents/deepinfra 0.0.1-dev.fffff
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -0
- package/dist/index.d.ts +93 -0
- package/dist/index.js +1021 -0
- package/dist/index.js.map +1 -0
- package/package.json +41 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1021 @@
|
|
|
1
|
+
// src/DeepInfraProvider.ts
|
|
2
|
+
import { ProviderError } from "@standardagents/spec";
|
|
3
|
+
|
|
4
|
+
// src/chat-completions-transformers.ts
|
|
5
|
+
function roundCost(value) {
|
|
6
|
+
return Number(value.toFixed(12));
|
|
7
|
+
}
|
|
8
|
+
function calculateUsageCost(usage, pricing) {
|
|
9
|
+
if (!pricing || typeof pricing.inputPerMillion !== "number" || typeof pricing.outputPerMillion !== "number") {
|
|
10
|
+
return void 0;
|
|
11
|
+
}
|
|
12
|
+
const cachedTokens = usage.cachedTokens || 0;
|
|
13
|
+
const uncachedPromptTokens = Math.max(0, usage.promptTokens - cachedTokens);
|
|
14
|
+
const cachedRate = pricing.cachedInputPerMillion ?? pricing.inputPerMillion;
|
|
15
|
+
return roundCost(
|
|
16
|
+
uncachedPromptTokens / 1e6 * pricing.inputPerMillion + cachedTokens / 1e6 * cachedRate + usage.completionTokens / 1e6 * pricing.outputPerMillion
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
function attachUsagePricing(usage, pricing) {
|
|
20
|
+
if (!pricing) return usage;
|
|
21
|
+
usage.pricing = pricing;
|
|
22
|
+
if (usage.cost === void 0) {
|
|
23
|
+
const cost = calculateUsageCost(usage, pricing);
|
|
24
|
+
if (cost !== void 0) usage.cost = cost;
|
|
25
|
+
}
|
|
26
|
+
return usage;
|
|
27
|
+
}
|
|
28
|
+
function transformChatContentPart(part) {
|
|
29
|
+
if (part.type === "text") {
|
|
30
|
+
return { type: "text", text: part.text };
|
|
31
|
+
}
|
|
32
|
+
if (part.type === "image") {
|
|
33
|
+
const data = part.data || "";
|
|
34
|
+
const imageUrl = data.startsWith("data:") ? data : `data:${part.mediaType || "image/png"};base64,${data}`;
|
|
35
|
+
return {
|
|
36
|
+
type: "image_url",
|
|
37
|
+
image_url: {
|
|
38
|
+
url: imageUrl,
|
|
39
|
+
detail: part.detail || "auto"
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
if (part.type === "image_url") {
|
|
44
|
+
return {
|
|
45
|
+
type: "image_url",
|
|
46
|
+
image_url: {
|
|
47
|
+
url: part.image_url?.url || "",
|
|
48
|
+
detail: part.image_url?.detail || "auto"
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
type: "text",
|
|
54
|
+
text: `[File: ${part.filename || "file"}]`
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function transformChatMessageContent(content) {
|
|
58
|
+
if (typeof content === "string") {
|
|
59
|
+
return content;
|
|
60
|
+
}
|
|
61
|
+
return content.map(transformChatContentPart);
|
|
62
|
+
}
|
|
63
|
+
function transformChatMessages(messages) {
|
|
64
|
+
const result = [];
|
|
65
|
+
for (const msg of messages) {
|
|
66
|
+
switch (msg.role) {
|
|
67
|
+
case "system":
|
|
68
|
+
result.push({
|
|
69
|
+
role: "system",
|
|
70
|
+
content: msg.content
|
|
71
|
+
});
|
|
72
|
+
break;
|
|
73
|
+
case "user":
|
|
74
|
+
result.push({
|
|
75
|
+
role: "user",
|
|
76
|
+
content: transformChatMessageContent(msg.content)
|
|
77
|
+
});
|
|
78
|
+
break;
|
|
79
|
+
case "assistant": {
|
|
80
|
+
const message = {
|
|
81
|
+
role: "assistant",
|
|
82
|
+
content: msg.content || null
|
|
83
|
+
};
|
|
84
|
+
if (msg.toolCalls && msg.toolCalls.length > 0) {
|
|
85
|
+
message.tool_calls = msg.toolCalls.map((tc) => ({
|
|
86
|
+
id: tc.id,
|
|
87
|
+
type: "function",
|
|
88
|
+
function: {
|
|
89
|
+
name: tc.name,
|
|
90
|
+
arguments: typeof tc.arguments === "string" ? tc.arguments : JSON.stringify(tc.arguments)
|
|
91
|
+
}
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
|
+
if (msg.reasoning) {
|
|
95
|
+
message.reasoning_content = msg.reasoning;
|
|
96
|
+
}
|
|
97
|
+
result.push(message);
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
case "tool": {
|
|
101
|
+
let output;
|
|
102
|
+
if (typeof msg.content === "string") {
|
|
103
|
+
output = msg.content;
|
|
104
|
+
} else if ("type" in msg.content) {
|
|
105
|
+
if (msg.content.type === "text") {
|
|
106
|
+
output = msg.content.text;
|
|
107
|
+
} else if (msg.content.type === "error") {
|
|
108
|
+
output = `Error: ${msg.content.error}`;
|
|
109
|
+
} else {
|
|
110
|
+
output = JSON.stringify(msg.content);
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
113
|
+
output = JSON.stringify(msg.content);
|
|
114
|
+
}
|
|
115
|
+
const imageAttachments = msg.attachments?.filter((a) => a.type === "image" && a.data) || [];
|
|
116
|
+
result.push({
|
|
117
|
+
role: "tool",
|
|
118
|
+
tool_call_id: msg.toolCallId,
|
|
119
|
+
content: output || (imageAttachments.length > 0 ? "Success" : "")
|
|
120
|
+
});
|
|
121
|
+
if (imageAttachments.length > 0) {
|
|
122
|
+
const imageContent = [];
|
|
123
|
+
const toolName = msg.toolName || "the tool";
|
|
124
|
+
const isSingle = imageAttachments.length === 1;
|
|
125
|
+
const descriptor = isSingle ? "the file" : `${imageAttachments.length} files`;
|
|
126
|
+
const verb = isSingle ? "is" : "are";
|
|
127
|
+
imageContent.push({
|
|
128
|
+
type: "text",
|
|
129
|
+
text: `Here ${verb} ${descriptor} from ${toolName}:`
|
|
130
|
+
});
|
|
131
|
+
for (const attachment of imageAttachments) {
|
|
132
|
+
const attachmentData = attachment.data || "";
|
|
133
|
+
const imageData = attachmentData.startsWith("data:") ? attachmentData : `data:${attachment.mediaType || "image/png"};base64,${attachmentData}`;
|
|
134
|
+
imageContent.push({
|
|
135
|
+
type: "image_url",
|
|
136
|
+
image_url: {
|
|
137
|
+
url: imageData,
|
|
138
|
+
detail: "auto"
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
result.push({
|
|
143
|
+
role: "user",
|
|
144
|
+
content: imageContent
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return result;
|
|
152
|
+
}
|
|
153
|
+
function isRecord(value) {
|
|
154
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
155
|
+
}
|
|
156
|
+
var STRICT_UNSUPPORTED_KEYWORDS = /* @__PURE__ */ new Set([
|
|
157
|
+
"minLength",
|
|
158
|
+
"maxLength",
|
|
159
|
+
"pattern",
|
|
160
|
+
"format",
|
|
161
|
+
"minimum",
|
|
162
|
+
"maximum",
|
|
163
|
+
"exclusiveMinimum",
|
|
164
|
+
"exclusiveMaximum",
|
|
165
|
+
"multipleOf",
|
|
166
|
+
"minItems",
|
|
167
|
+
"maxItems",
|
|
168
|
+
"uniqueItems",
|
|
169
|
+
"minContains",
|
|
170
|
+
"maxContains",
|
|
171
|
+
"minProperties",
|
|
172
|
+
"maxProperties",
|
|
173
|
+
"patternProperties",
|
|
174
|
+
"propertyNames",
|
|
175
|
+
"dependentRequired",
|
|
176
|
+
"dependentSchemas",
|
|
177
|
+
"unevaluatedProperties",
|
|
178
|
+
"default",
|
|
179
|
+
"examples",
|
|
180
|
+
"$schema",
|
|
181
|
+
"$comment",
|
|
182
|
+
"contentEncoding",
|
|
183
|
+
"contentMediaType"
|
|
184
|
+
]);
|
|
185
|
+
function normalizeStrictJsonSchema(schema) {
|
|
186
|
+
if (Array.isArray(schema)) {
|
|
187
|
+
return schema.map((item) => normalizeStrictJsonSchema(item));
|
|
188
|
+
}
|
|
189
|
+
if (!isRecord(schema)) {
|
|
190
|
+
return schema;
|
|
191
|
+
}
|
|
192
|
+
const normalized = {};
|
|
193
|
+
for (const [key, value] of Object.entries(schema)) {
|
|
194
|
+
if (STRICT_UNSUPPORTED_KEYWORDS.has(key)) continue;
|
|
195
|
+
if (key === "properties" && isRecord(value)) {
|
|
196
|
+
const props = {};
|
|
197
|
+
for (const [propName, propSchema] of Object.entries(value)) {
|
|
198
|
+
props[propName] = normalizeStrictJsonSchema(propSchema);
|
|
199
|
+
}
|
|
200
|
+
normalized[key] = props;
|
|
201
|
+
} else if (key === "enum" || key === "const") {
|
|
202
|
+
normalized[key] = value;
|
|
203
|
+
} else {
|
|
204
|
+
normalized[key] = normalizeStrictJsonSchema(value);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
const properties = isRecord(normalized.properties) ? normalized.properties : void 0;
|
|
208
|
+
const type = normalized.type;
|
|
209
|
+
const isObjectSchema = type === "object" || Array.isArray(type) && type.includes("object") || !!properties;
|
|
210
|
+
if (isObjectSchema) {
|
|
211
|
+
if (normalized.type === void 0) {
|
|
212
|
+
normalized.type = "object";
|
|
213
|
+
}
|
|
214
|
+
normalized.properties = properties || {};
|
|
215
|
+
normalized.required = Object.keys(normalized.properties);
|
|
216
|
+
normalized.additionalProperties = false;
|
|
217
|
+
}
|
|
218
|
+
return normalized;
|
|
219
|
+
}
|
|
220
|
+
function normalizeStrictToolParameters(parameters) {
|
|
221
|
+
const base = isRecord(parameters) ? { ...parameters } : {};
|
|
222
|
+
if (base.type === void 0) base.type = "object";
|
|
223
|
+
if (base.properties === void 0) base.properties = {};
|
|
224
|
+
return normalizeStrictJsonSchema(base);
|
|
225
|
+
}
|
|
226
|
+
function transformChatTool(tool) {
|
|
227
|
+
const inputParams = tool.function.parameters;
|
|
228
|
+
return {
|
|
229
|
+
type: "function",
|
|
230
|
+
function: {
|
|
231
|
+
name: tool.function.name,
|
|
232
|
+
description: tool.function.description || void 0,
|
|
233
|
+
parameters: normalizeStrictToolParameters(inputParams),
|
|
234
|
+
strict: true
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
function transformChatToolChoice(choice) {
|
|
239
|
+
if (choice === "auto") return "auto";
|
|
240
|
+
if (choice === "none") return "none";
|
|
241
|
+
if (choice === "required") return "required";
|
|
242
|
+
if (typeof choice === "object" && "name" in choice) {
|
|
243
|
+
return { type: "function", function: { name: choice.name } };
|
|
244
|
+
}
|
|
245
|
+
return void 0;
|
|
246
|
+
}
|
|
247
|
+
function mapChatFinishReason(finishReason) {
|
|
248
|
+
switch (finishReason) {
|
|
249
|
+
case "stop":
|
|
250
|
+
return "stop";
|
|
251
|
+
case "tool_calls":
|
|
252
|
+
case "function_call":
|
|
253
|
+
return "tool_calls";
|
|
254
|
+
case "length":
|
|
255
|
+
return "length";
|
|
256
|
+
case "content_filter":
|
|
257
|
+
return "content_filter";
|
|
258
|
+
case "error":
|
|
259
|
+
return "error";
|
|
260
|
+
default:
|
|
261
|
+
return "stop";
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
function extractChatToolCalls(toolCalls) {
|
|
265
|
+
if (!toolCalls || toolCalls.length === 0) {
|
|
266
|
+
return void 0;
|
|
267
|
+
}
|
|
268
|
+
return toolCalls.map((tc) => {
|
|
269
|
+
let parsedArgs = {};
|
|
270
|
+
try {
|
|
271
|
+
parsedArgs = tc.function.arguments ? JSON.parse(tc.function.arguments) : {};
|
|
272
|
+
} catch {
|
|
273
|
+
parsedArgs = {};
|
|
274
|
+
}
|
|
275
|
+
return {
|
|
276
|
+
id: tc.id,
|
|
277
|
+
name: tc.function.name,
|
|
278
|
+
arguments: parsedArgs
|
|
279
|
+
};
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
function transformChatUsage(usage, pricing) {
|
|
283
|
+
const mapped = {
|
|
284
|
+
promptTokens: usage?.prompt_tokens || 0,
|
|
285
|
+
completionTokens: usage?.completion_tokens || 0,
|
|
286
|
+
totalTokens: usage?.total_tokens || 0,
|
|
287
|
+
cachedTokens: usage?.prompt_tokens_details?.cached_tokens,
|
|
288
|
+
reasoningTokens: usage?.completion_tokens_details?.reasoning_tokens
|
|
289
|
+
};
|
|
290
|
+
if (typeof usage?.estimated_cost === "number" && Number.isFinite(usage.estimated_cost)) {
|
|
291
|
+
mapped.cost = usage.estimated_cost;
|
|
292
|
+
}
|
|
293
|
+
return attachUsagePricing(mapped, pricing);
|
|
294
|
+
}
|
|
295
|
+
function transformChatResponse(response, pricing) {
|
|
296
|
+
const choice = response.choices?.[0];
|
|
297
|
+
const message = choice?.message;
|
|
298
|
+
const reasoning = message?.reasoning_content || message?.reasoning || null;
|
|
299
|
+
return {
|
|
300
|
+
content: message?.content || null,
|
|
301
|
+
reasoning,
|
|
302
|
+
reasoningDetails: reasoning ? [{ type: "text", text: reasoning }] : void 0,
|
|
303
|
+
toolCalls: extractChatToolCalls(message?.tool_calls),
|
|
304
|
+
finishReason: mapChatFinishReason(choice?.finish_reason),
|
|
305
|
+
usage: transformChatUsage(response.usage, pricing),
|
|
306
|
+
metadata: {
|
|
307
|
+
model: response.model,
|
|
308
|
+
provider: "deepinfra",
|
|
309
|
+
requestId: response.id,
|
|
310
|
+
created: response.created,
|
|
311
|
+
object: response.object
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
function createChatStreamState(model) {
|
|
316
|
+
return {
|
|
317
|
+
model,
|
|
318
|
+
content: "",
|
|
319
|
+
toolCalls: /* @__PURE__ */ new Map(),
|
|
320
|
+
reasoningContent: "",
|
|
321
|
+
hasContent: false,
|
|
322
|
+
hasReasoning: false,
|
|
323
|
+
finishReason: null
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
function processChatStreamChunk(chunk, state) {
|
|
327
|
+
const chunks = [];
|
|
328
|
+
const choice = chunk.choices?.[0];
|
|
329
|
+
const delta = choice?.delta;
|
|
330
|
+
if (chunk.model) {
|
|
331
|
+
state.model = chunk.model;
|
|
332
|
+
}
|
|
333
|
+
if (!delta && !choice?.finish_reason && !chunk.usage) {
|
|
334
|
+
return chunks;
|
|
335
|
+
}
|
|
336
|
+
if (delta?.content) {
|
|
337
|
+
state.hasContent = true;
|
|
338
|
+
state.content += delta.content;
|
|
339
|
+
chunks.push({ type: "content-delta", delta: delta.content });
|
|
340
|
+
}
|
|
341
|
+
const reasoningDelta = delta?.reasoning_content || delta?.reasoning;
|
|
342
|
+
if (reasoningDelta) {
|
|
343
|
+
state.hasReasoning = true;
|
|
344
|
+
state.reasoningContent += reasoningDelta;
|
|
345
|
+
chunks.push({ type: "reasoning-delta", delta: reasoningDelta });
|
|
346
|
+
}
|
|
347
|
+
if (delta?.tool_calls) {
|
|
348
|
+
for (const tc of delta.tool_calls) {
|
|
349
|
+
const existing = state.toolCalls.get(tc.index);
|
|
350
|
+
if (tc.id && tc.function?.name) {
|
|
351
|
+
state.toolCalls.set(tc.index, {
|
|
352
|
+
id: tc.id,
|
|
353
|
+
name: tc.function.name,
|
|
354
|
+
arguments: tc.function.arguments || ""
|
|
355
|
+
});
|
|
356
|
+
chunks.push({
|
|
357
|
+
type: "tool-call-start",
|
|
358
|
+
id: tc.id,
|
|
359
|
+
name: tc.function.name
|
|
360
|
+
});
|
|
361
|
+
} else if (existing && tc.function?.arguments) {
|
|
362
|
+
existing.arguments += tc.function.arguments;
|
|
363
|
+
chunks.push({
|
|
364
|
+
type: "tool-call-delta",
|
|
365
|
+
id: existing.id,
|
|
366
|
+
argumentsDelta: tc.function.arguments
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
if (choice?.finish_reason) {
|
|
372
|
+
state.finishReason = choice.finish_reason;
|
|
373
|
+
if (state.hasContent) {
|
|
374
|
+
chunks.push({ type: "content-done" });
|
|
375
|
+
}
|
|
376
|
+
if (state.hasReasoning) {
|
|
377
|
+
chunks.push({ type: "reasoning-done" });
|
|
378
|
+
}
|
|
379
|
+
for (const tc of state.toolCalls.values()) {
|
|
380
|
+
let parsedArgs = {};
|
|
381
|
+
try {
|
|
382
|
+
parsedArgs = tc.arguments ? JSON.parse(tc.arguments) : {};
|
|
383
|
+
} catch {
|
|
384
|
+
parsedArgs = {};
|
|
385
|
+
}
|
|
386
|
+
chunks.push({
|
|
387
|
+
type: "tool-call-done",
|
|
388
|
+
id: tc.id,
|
|
389
|
+
arguments: parsedArgs
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
if (chunk.usage) {
|
|
394
|
+
const reasoningDetails = state.reasoningContent ? [{ type: "text", text: state.reasoningContent }] : void 0;
|
|
395
|
+
chunks.push({
|
|
396
|
+
type: "finish",
|
|
397
|
+
finishReason: mapChatFinishReason(state.finishReason),
|
|
398
|
+
usage: transformChatUsage(chunk.usage),
|
|
399
|
+
reasoningDetails
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
return chunks;
|
|
403
|
+
}
|
|
404
|
+
function parseChatStreamEvent(jsonStr) {
|
|
405
|
+
try {
|
|
406
|
+
return JSON.parse(jsonStr);
|
|
407
|
+
} catch {
|
|
408
|
+
return null;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
async function* parseChatSSEStream(response, state) {
|
|
412
|
+
const reader = response.body?.getReader();
|
|
413
|
+
if (!reader) {
|
|
414
|
+
throw new Error("No response body");
|
|
415
|
+
}
|
|
416
|
+
const decoder = new TextDecoder();
|
|
417
|
+
let buffer = "";
|
|
418
|
+
try {
|
|
419
|
+
while (true) {
|
|
420
|
+
const { done, value } = await reader.read();
|
|
421
|
+
if (done) break;
|
|
422
|
+
buffer += decoder.decode(value, { stream: true });
|
|
423
|
+
const lines = buffer.split("\n");
|
|
424
|
+
buffer = lines.pop() || "";
|
|
425
|
+
for (const line of lines) {
|
|
426
|
+
const trimmed = line.trim();
|
|
427
|
+
if (!trimmed || trimmed.startsWith(":")) continue;
|
|
428
|
+
if (!trimmed.startsWith("data: ")) continue;
|
|
429
|
+
const data = trimmed.slice(6);
|
|
430
|
+
if (data === "[DONE]") continue;
|
|
431
|
+
const chunk = parseChatStreamEvent(data);
|
|
432
|
+
if (!chunk) continue;
|
|
433
|
+
for (const providerChunk of processChatStreamChunk(chunk, state)) {
|
|
434
|
+
yield providerChunk;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
if (buffer.trim()) {
|
|
439
|
+
const trimmed = buffer.trim();
|
|
440
|
+
if (trimmed.startsWith("data: ")) {
|
|
441
|
+
const data = trimmed.slice(6);
|
|
442
|
+
if (data !== "[DONE]") {
|
|
443
|
+
const chunk = parseChatStreamEvent(data);
|
|
444
|
+
if (chunk) {
|
|
445
|
+
for (const providerChunk of processChatStreamChunk(chunk, state)) {
|
|
446
|
+
yield providerChunk;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
} finally {
|
|
453
|
+
reader.releaseLock();
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
function buildChatParams(request) {
|
|
457
|
+
const params = {
|
|
458
|
+
model: request.model,
|
|
459
|
+
messages: transformChatMessages(request.messages)
|
|
460
|
+
};
|
|
461
|
+
if (request.tools && request.tools.length > 0) {
|
|
462
|
+
params.tools = request.tools.map(transformChatTool);
|
|
463
|
+
const toolChoice = transformChatToolChoice(request.toolChoice);
|
|
464
|
+
if (toolChoice !== void 0) {
|
|
465
|
+
params.tool_choice = toolChoice;
|
|
466
|
+
}
|
|
467
|
+
if (request.parallelToolCalls !== void 0) {
|
|
468
|
+
params.parallel_tool_calls = request.parallelToolCalls;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
if (request.maxOutputTokens !== void 0) {
|
|
472
|
+
params.max_tokens = request.maxOutputTokens;
|
|
473
|
+
}
|
|
474
|
+
if (request.temperature !== void 0) {
|
|
475
|
+
params.temperature = request.temperature;
|
|
476
|
+
}
|
|
477
|
+
if (request.topP !== void 0) {
|
|
478
|
+
params.top_p = request.topP;
|
|
479
|
+
}
|
|
480
|
+
if (request.user) {
|
|
481
|
+
params.user = request.user;
|
|
482
|
+
}
|
|
483
|
+
if (request.stopSequences && request.stopSequences.length > 0) {
|
|
484
|
+
params.stop = request.stopSequences;
|
|
485
|
+
}
|
|
486
|
+
if (request.reasoning?.level !== void 0) {
|
|
487
|
+
const level = request.reasoning.level;
|
|
488
|
+
params.reasoning_effort = level <= 0 ? "none" : level <= 33 ? "low" : level <= 66 ? "medium" : "high";
|
|
489
|
+
}
|
|
490
|
+
if (request.responseFormat?.type === "json") {
|
|
491
|
+
if (request.responseFormat.schema) {
|
|
492
|
+
params.response_format = {
|
|
493
|
+
type: "json_schema",
|
|
494
|
+
json_schema: {
|
|
495
|
+
name: "response",
|
|
496
|
+
schema: normalizeStrictJsonSchema(request.responseFormat.schema),
|
|
497
|
+
strict: true
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
} else {
|
|
501
|
+
params.response_format = { type: "json_object" };
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
if (request.providerOptions) {
|
|
505
|
+
const { _metadata, ...safeOptions } = request.providerOptions;
|
|
506
|
+
Object.assign(params, safeOptions);
|
|
507
|
+
}
|
|
508
|
+
return params;
|
|
509
|
+
}
|
|
510
|
+
function createChatErrorChunk(error, code) {
|
|
511
|
+
return { type: "error", error, code };
|
|
512
|
+
}
|
|
513
|
+
function isBase64Like(str) {
|
|
514
|
+
if (str.startsWith("data:")) return true;
|
|
515
|
+
if (str.length > 200) {
|
|
516
|
+
const base64Pattern = /^[A-Za-z0-9+/]+=*$/;
|
|
517
|
+
return base64Pattern.test(str.substring(0, 200));
|
|
518
|
+
}
|
|
519
|
+
return false;
|
|
520
|
+
}
|
|
521
|
+
function truncateBase64String(str, maxLength = 50) {
|
|
522
|
+
if (str.length <= maxLength) return str;
|
|
523
|
+
const preview = str.substring(0, maxLength);
|
|
524
|
+
return `${preview}...[truncated, ${str.length.toLocaleString()} chars]`;
|
|
525
|
+
}
|
|
526
|
+
function truncateChatBase64(obj, maxLength = 50) {
|
|
527
|
+
if (obj === null || obj === void 0) {
|
|
528
|
+
return obj;
|
|
529
|
+
}
|
|
530
|
+
if (typeof obj === "string") {
|
|
531
|
+
return isBase64Like(obj) ? truncateBase64String(obj, maxLength) : obj;
|
|
532
|
+
}
|
|
533
|
+
if (Array.isArray(obj)) {
|
|
534
|
+
return obj.map((item) => truncateChatBase64(item, maxLength));
|
|
535
|
+
}
|
|
536
|
+
if (typeof obj === "object") {
|
|
537
|
+
const result = {};
|
|
538
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
539
|
+
result[key] = truncateChatBase64(value, maxLength);
|
|
540
|
+
}
|
|
541
|
+
return result;
|
|
542
|
+
}
|
|
543
|
+
return obj;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
// src/deepinfra.svg?raw
|
|
547
|
+
var deepinfra_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" role="img" aria-labelledby="deepinfra-title">\n <title id="deepinfra-title">DeepInfra</title>\n <path fill="#2A3275" d="M3.294 7.821A2.297 2.297 0 0 1 1 5.527a2.297 2.297 0 0 1 2.294-2.295A2.297 2.297 0 0 1 5.59 5.527a2.297 2.297 0 0 1-2.296 2.294Zm0-3.688a1.396 1.396 0 1 0 0 2.79 1.396 1.396 0 0 0 0-2.79Zm0 10.16A2.297 2.297 0 0 1 1 11.998a2.297 2.297 0 0 1 2.294-2.294 2.297 2.297 0 0 1 2.295 2.294 2.297 2.297 0 0 1-2.295 2.295Zm0-3.688a1.395 1.395 0 1 0 0 2.788 1.395 1.395 0 0 0 0-2.788Zm0 10.156A2.297 2.297 0 0 1 1 18.467a2.297 2.297 0 0 1 2.294-2.295 2.297 2.297 0 0 1 2.295 2.295 2.297 2.297 0 0 1-2.295 2.294Zm0-3.688a1.396 1.396 0 1 0 0 2.79 1.396 1.396 0 0 0 0-2.79Zm17.444-9.252a2.297 2.297 0 0 1-2.295-2.294 2.297 2.297 0 0 1 2.294-2.295 2.297 2.297 0 0 1 2.295 2.295 2.297 2.297 0 0 1-2.294 2.294Zm0-3.688a1.396 1.396 0 1 0 0 2.79 1.396 1.396 0 0 0 0-2.79Zm0 10.16a2.297 2.297 0 0 1-2.295-2.295 2.297 2.297 0 0 1 2.294-2.294 2.297 2.297 0 0 1 2.295 2.294 2.297 2.297 0 0 1-2.294 2.295Zm0-3.688a1.395 1.395 0 1 0 0 2.788 1.395 1.395 0 0 0 0-2.788Zm0 10.156a2.297 2.297 0 0 1-2.295-2.294 2.297 2.297 0 0 1 2.294-2.295 2.297 2.297 0 0 1 2.295 2.295 2.297 2.297 0 0 1-2.294 2.294Zm0-3.688a1.396 1.396 0 1 0 0 2.79 1.396 1.396 0 0 0 0-2.79ZM12.016 11.057a2.297 2.297 0 0 1-2.294-2.294 2.297 2.297 0 0 1 2.294-2.295 2.297 2.297 0 0 1 2.295 2.295 2.297 2.297 0 0 1-2.295 2.294Zm0-3.688a1.396 1.396 0 1 0 0 2.79 1.396 1.396 0 0 0 0-2.79Zm.001-2.78a2.297 2.297 0 0 1-2.295-2.295A2.297 2.297 0 0 1 12.017 0a2.297 2.297 0 0 1 2.294 2.294 2.297 2.297 0 0 1-2.294 2.295Zm0-3.688a1.396 1.396 0 1 0 0 2.79 1.396 1.396 0 0 0 0-2.79Zm0 16.628a2.297 2.297 0 0 1-2.295-2.295 2.297 2.297 0 0 1 2.295-2.294 2.297 2.297 0 0 1 2.294 2.294 2.297 2.297 0 0 1-2.294 2.295Zm0-3.688a1.396 1.396 0 1 0 0 2.79 1.396 1.396 0 0 0 0-2.79ZM12.016 24a2.297 2.297 0 0 1-2.294-2.295 2.297 2.297 0 0 1 2.294-2.294 2.297 2.297 0 0 1 2.295 2.294A2.297 2.297 0 0 1 12.016 24Zm0-3.688a1.396 1.396 0 1 0 0 2.79 1.396 1.396 0 0 0 0-2.79Z"/>\n <path fill="#5699DB" d="M8.363 8.222a.75.75 0 0 1-.277-.053l-1.494-.596a.75.75 0 1 1 .557-1.392l1.493.595a.75.75 0 0 1-.279 1.446Zm0 6.344a.75.75 0 0 1-.277-.053l-1.494-.595a.75.75 0 1 1 .557-1.393l1.493.596a.75.75 0 0 1-.279 1.445Zm8.761-3.169a.75.75 0 0 1-.277-.054l-1.493-.595a.75.75 0 1 1 .555-1.392l1.493.595a.75.75 0 0 1-.278 1.446Zm0-6.347a.75.75 0 0 1-.277-.054L15.354 4.4a.75.75 0 0 1 .555-1.392l1.493.596a.75.75 0 0 1-.278 1.446Zm0 12.689a.75.75 0 0 1-.277-.053l-1.494-.596a.75.75 0 1 1 .556-1.392l1.493.596a.75.75 0 0 1-.278 1.445ZM6.91 17.966a.75.75 0 0 1-.279-1.445l1.494-.595a.75.75 0 1 1 .556 1.392l-1.493.595a.75.75 0 0 1-.278.053Zm0-6.306a.75.75 0 0 1-.279-1.446l1.494-.595a.75.75 0 0 1 .556 1.392l-1.493.595a.75.75 0 0 1-.278.054Zm0-6.627a.75.75 0 0 1-.279-1.446l1.494-.595a.75.75 0 0 1 .556 1.392l-1.493.596a.75.75 0 0 1-.278.053Zm1.453 16.331a.75.75 0 0 1-.277-.053l-1.494-.596a.75.75 0 0 1 .555-1.392l1.494.595a.75.75 0 0 1-.278 1.446ZM15.63 8.223a.75.75 0 0 1-.278-1.447l1.494-.595a.75.75 0 0 1 .556 1.393l-1.494.595a.75.75 0 0 1-.278.054Zm0 6.344a.75.75 0 0 1-.278-1.446l1.494-.596a.75.75 0 0 1 .556 1.394l-1.494.595a.75.75 0 0 1-.278.053Zm0 6.796a.75.75 0 0 1-.278-1.445l1.494-.595a.75.75 0 1 1 .555 1.392l-1.494.595a.75.75 0 0 1-.277.053Z"/>\n</svg>\n';
|
|
548
|
+
|
|
549
|
+
// src/vendor-icons/anthropic.svg?raw
|
|
550
|
+
var anthropic_default = '<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48" fill="none">\n<rect width="48" height="48" fill="#F0EFEA"/>\n<path d="M32.84 10H26.72L37.88 38H44L32.84 10Z" fill="black"/>\n<path d="M15.16 10L4 38H10.24L12.5224 32.12H24.1976L26.48 38H32.72L21.56 10H15.16ZM14.5408 26.92L18.36 17.08L22.1793 26.92H14.5408Z" fill="black"/>\n</svg>\n';
|
|
551
|
+
|
|
552
|
+
// src/vendor-icons/bytedance.svg?raw
|
|
553
|
+
var bytedance_default = '<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48" fill="none"><rect width="48" height="48" rx="10" fill="#2563EB"/><text x="24" y="28" fill="white" font-size="11" font-family="Arial, sans-serif" font-weight="700" text-anchor="middle">BYTE</text></svg>\n\n';
|
|
554
|
+
|
|
555
|
+
// src/vendor-icons/deepseek.svg?raw
|
|
556
|
+
var deepseek_default = '<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48" fill="none">\n<rect width="48" height="48" fill="white"/>\n<path d="M47.4964 9.43757C46.988 9.19072 46.769 9.66115 46.4717 9.90013C46.37 9.97722 46.284 10.0774 46.1979 10.1699C45.4548 10.9562 44.5866 11.4729 43.4523 11.4112C41.794 11.3186 40.3781 11.8353 39.1265 13.092C38.8605 11.5423 37.9767 10.617 36.6312 10.0234C35.9273 9.71497 35.2154 9.40651 34.7226 8.7357C34.3784 8.25783 34.2845 7.7258 34.1124 7.20147C34.0029 6.8854 33.8934 6.56146 33.5257 6.50747C33.1268 6.44587 32.9703 6.77725 32.8138 7.05499C32.1881 8.18844 31.9456 9.43749 31.969 10.7019C32.0237 13.5471 33.2363 15.8137 35.6455 17.4252C35.9193 17.6103 35.9896 17.7952 35.9036 18.0652C35.7393 18.6204 35.5437 19.16 35.3717 19.7151C35.2622 20.0699 35.0978 20.147 34.7146 19.9926C33.3926 19.4453 32.2505 18.6357 31.2414 17.6566C29.5284 16.0143 27.9795 14.2024 26.0475 12.7837C25.5938 12.4521 25.1401 12.1438 24.6707 11.8507C22.6994 9.95412 24.9289 8.39653 25.4451 8.21163C25.9848 8.01885 25.6329 7.35566 23.8884 7.36353C22.144 7.37114 20.5483 7.94946 18.5146 8.72047C18.2173 8.83615 17.9043 8.92086 17.5836 8.99025C15.7376 8.64338 13.8211 8.56612 11.8186 8.78986C8.04819 9.20613 5.03671 10.9718 2.823 13.9865C0.16347 17.6103 -0.462297 21.7274 0.304303 26.0221C1.11002 30.5478 3.44099 34.295 7.02367 37.225C10.7393 40.2626 15.0181 41.7507 19.8992 41.4655C22.8639 41.2959 26.1649 40.9027 29.8884 37.7801C30.827 38.2427 31.8126 38.4276 33.4475 38.5664C34.7069 38.6821 35.9194 38.5048 36.858 38.3121C38.3286 38.0037 38.227 36.6544 37.6951 36.4077C33.385 34.4185 34.3314 35.228 33.471 34.5726C35.6613 32.0052 38.9624 29.3374 40.253 20.6942C40.3546 20.0081 40.2686 19.5763 40.253 19.0211C40.2451 18.682 40.3234 18.551 40.7145 18.5123C41.794 18.3889 42.8422 18.096 43.8043 17.5717C46.5969 16.0606 47.7233 13.5779 47.9892 10.6017C48.0284 10.1468 47.9814 9.67638 47.4964 9.43757ZM23.1611 36.2225C18.984 32.969 16.9581 31.8971 16.1211 31.9434C15.3388 31.9897 15.4797 32.8764 15.6517 33.4547C15.8316 34.0252 16.0663 34.4185 16.3948 34.9196C16.6216 35.2511 16.7782 35.7445 16.168 36.1147C14.8226 36.9397 12.4836 35.8371 12.3741 35.7832C9.65202 34.1948 7.37571 32.0975 5.77205 29.2295C4.22322 26.4691 3.32373 23.5086 3.17504 20.3474C3.13592 19.5841 3.36276 19.3141 4.12936 19.1755C5.13843 18.9904 6.17884 18.9517 7.1879 19.0982C11.4512 19.7151 15.0807 21.6041 18.1235 24.5956C19.86 26.2995 21.1742 28.3352 22.5275 30.3243C23.9668 32.4368 25.5156 34.4493 27.4868 36.0992C28.183 36.6775 28.7384 37.1169 29.2703 37.4408C27.6668 37.6181 24.9915 37.6568 23.1611 36.2225ZM25.1636 23.4623C25.1636 23.123 25.4374 22.8532 25.7817 22.8532C25.8599 22.8532 25.9303 22.8685 25.9929 22.8916C26.079 22.9225 26.1572 22.9688 26.2198 23.038C26.3293 23.1461 26.3919 23.3002 26.3919 23.4622C26.3919 23.8014 26.1181 24.0712 25.774 24.0712C25.4299 24.0712 25.1636 23.8015 25.1636 23.4623ZM31.3824 26.6235C30.9835 26.7854 30.5846 26.9241 30.2013 26.9395C29.6068 26.9703 28.9575 26.7313 28.6056 26.4383C28.058 25.9834 27.6669 25.7291 27.5026 24.9349C27.4322 24.5956 27.4713 24.0713 27.534 23.7707C27.6747 23.123 27.5183 22.7067 27.0568 22.3288C26.6813 22.0204 26.2041 21.9357 25.68 21.9357C25.4844 21.9357 25.3046 21.8508 25.1716 21.7814C24.9525 21.6735 24.7727 21.4036 24.9447 21.0721C24.9995 20.9643 25.2655 20.702 25.3281 20.6558C26.04 20.2548 26.8613 20.3859 27.6201 20.6866C28.3242 20.9719 28.8561 21.4962 29.6226 22.2363C30.4048 23.1306 30.5456 23.3776 30.9915 24.0482C31.3436 24.5725 31.6643 25.1122 31.8833 25.7291C32.0162 26.1146 31.844 26.4307 31.3824 26.6235Z" fill="#4D6BFE"/>\n</svg>\n';
|
|
557
|
+
|
|
558
|
+
// src/vendor-icons/google.svg?raw
|
|
559
|
+
var google_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" role="img" aria-labelledby="google-title">\n <title id="google-title">Google</title>\n <rect width="64" height="64" rx="12" fill="#fff"/>\n <path fill="#4285F4" d="M54 32.73c0-1.58-.14-3.1-.4-4.55H32v8.61h12.33c-.53 2.85-2.14 5.27-4.56 6.9v5.73h7.38C51.47 45.44 54 39.61 54 32.73Z"/>\n <path fill="#34A853" d="M32 55c6.2 0 11.4-2.05 15.2-5.58l-7.38-5.73c-2.05 1.37-4.67 2.18-7.82 2.18-6 0-11.08-4.05-12.9-9.49h-7.62v5.96A22.98 22.98 0 0 0 32 55Z"/>\n <path fill="#FBBC05" d="M19.1 36.38A13.8 13.8 0 0 1 18.38 32c0-1.52.26-3 .72-4.38v-5.96h-7.62A22.98 22.98 0 0 0 9 32c0 3.67.88 7.13 2.48 10.34l7.62-5.96Z"/>\n <path fill="#EA4335" d="M32 18.9c3.37 0 6.4 1.16 8.79 3.45l6.59-6.59C43.39 12.05 38.19 9 32 9A22.98 22.98 0 0 0 11.48 21.66l7.62 5.96C20.92 22.95 26 18.9 32 18.9Z"/>\n</svg>\n';
|
|
560
|
+
|
|
561
|
+
// src/vendor-icons/gryphe.svg?raw
|
|
562
|
+
var gryphe_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" role="img" aria-labelledby="gryphe-title"><title id="gryphe-title">Gryphe</title><rect width="48" height="48" rx="12" fill="#312E81"/><path fill="#fff" d="M34.5 20.5v12.2A17.1 17.1 0 0 1 24 36C15.7 36 10 30.8 10 23.8S15.8 12 24.2 12c4.1 0 7.4 1 10 3l-4 5a9.4 9.4 0 0 0-5.8-1.8c-4.3 0-7.1 2.2-7.1 5.8 0 3.7 2.8 5.9 7.2 5.9 1.3 0 2.5-.2 3.5-.6v-3.2h-5.6v-5.6h12.1Z"/></svg>\n';
|
|
563
|
+
|
|
564
|
+
// src/vendor-icons/meta.svg?raw
|
|
565
|
+
var meta_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" role="img" aria-labelledby="meta-title">\n <title id="meta-title">Meta</title>\n <rect width="64" height="64" rx="12" fill="#fff"/>\n <path fill="none" stroke="#0668E1" stroke-linecap="round" stroke-linejoin="round" stroke-width="5" d="M8 39c4.1-12.5 8.3-20 14.1-20 7.5 0 12.8 26 19.8 26 5.8 0 10.1-9 14.1-20-4.1 12.5-8.3 20-14.1 20-7.5 0-12.8-26-19.8-26C16.3 19 12 28 8 39Z"/>\n</svg>\n';
|
|
566
|
+
|
|
567
|
+
// src/vendor-icons/microsoft.svg?raw
|
|
568
|
+
var microsoft_default = '<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" fill="none" viewBox="0 0 128 128"><g clip-path="url(#clip0_2138_481)"><path fill="#f35325" d="M5.565 5.565h55.652v55.652H5.565z"/><path fill="#81bc06" d="M66.783 5.565h55.652v55.652H66.783z"/><path fill="#05a6f0" d="M5.565 66.783h55.652v55.652H5.565z"/><path fill="#ffba08" d="M66.783 66.783h55.652v55.652H66.783z"/></g><defs><clipPath id="clip0_2138_481"><path fill="#fff" d="M0 0h128v128H0z"/></clipPath></defs></svg>\n';
|
|
569
|
+
|
|
570
|
+
// src/vendor-icons/minimax.svg?raw
|
|
571
|
+
var minimax_default = '<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48" fill="none">\n<rect width="48" height="48" fill="#FF6B6B"/>\n<text x="50%" y="50%" dominant-baseline="middle" text-anchor="middle" fill="white" font-family="Arial, sans-serif" font-size="16" font-weight="bold">MM</text>\n</svg>\n';
|
|
572
|
+
|
|
573
|
+
// src/vendor-icons/mistralai.svg?raw
|
|
574
|
+
var mistralai_default = '<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" fill="none" viewBox="0 0 128 128"><g clip-path="url(#clip0_2138_513)"><g clip-path="url(#clip1_2138_513)"><path fill="#000" d="M92.364 6h23.091v23.173H92.364z"/><path fill="#f7d046" d="M103.909 6H127v23.173h-23.091z"/><path fill="#000" d="M0 6h23.09v23.173H0zm0 23.173h23.09v23.173H0zm0 23.173h23.09v23.173H0zm0 23.173h23.09V98.69H0zM0 98.69h23.09v23.173H0z"/><path fill="#f7d046" d="M11.546 6h23.09v23.173h-23.09z"/><path fill="#f2a73b" d="M103.909 29.173H127v23.173h-23.091zm-92.363 0h23.09v23.173h-23.09z"/><path fill="#000" d="M69.273 29.173h23.09v23.173h-23.09z"/><path fill="#f2a73b" d="M80.818 29.173h23.091v23.173h-23.09zm-46.182 0h23.091v23.173h-23.09z"/><path fill="#ee792f" d="M57.727 52.346h23.091v23.173h-23.09zm23.091 0h23.091v23.173h-23.09zm-46.182 0h23.091v23.173h-23.09z"/><path fill="#000" d="M46.182 75.519h23.09V98.69h-23.09z"/><path fill="#eb5829" d="M57.727 75.519h23.091V98.69h-23.09z"/><path fill="#ee792f" d="M103.909 52.346H127v23.173h-23.091zm-92.363 0h23.09v23.173h-23.09z"/><path fill="#000" d="M92.364 75.519h23.091V98.69H92.364z"/><path fill="#eb5829" d="M103.909 75.519H127V98.69h-23.091z"/><path fill="#000" d="M92.364 98.691h23.091v23.173H92.364z"/><path fill="#eb5829" d="M11.546 75.519h23.09V98.69h-23.09z"/><path fill="#ea3326" d="M103.909 98.691H127v23.173h-23.091zm-92.363 0h23.09v23.173h-23.09z"/></g></g><defs><clipPath id="clip0_2138_513"><path fill="#fff" d="M0 0h128v128H0z"/></clipPath><clipPath id="clip1_2138_513"><path fill="#fff" d="M0 6h127v116H0z"/></clipPath></defs></svg>\n';
|
|
575
|
+
|
|
576
|
+
// src/vendor-icons/moonshotai.svg?raw
|
|
577
|
+
var moonshotai_default = '<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>MoonshotAI</title><path d="M1.052 16.916l9.539 2.552a21.007 21.007 0 00.06 2.033l5.956 1.593a11.997 11.997 0 01-5.586.865l-.18-.016-.044-.004-.084-.009-.094-.01a11.605 11.605 0 01-.157-.02l-.107-.014-.11-.016a11.962 11.962 0 01-.32-.051l-.042-.008-.075-.013-.107-.02-.07-.015-.093-.019-.075-.016-.095-.02-.097-.023-.094-.022-.068-.017-.088-.022-.09-.024-.095-.025-.082-.023-.109-.03-.062-.02-.084-.025-.093-.028-.105-.034-.058-.019-.08-.026-.09-.031-.066-.024a6.293 6.293 0 01-.044-.015l-.068-.025-.101-.037-.057-.022-.08-.03-.087-.035-.088-.035-.079-.032-.095-.04-.063-.028-.063-.027a5.655 5.655 0 01-.041-.018l-.066-.03-.103-.047-.052-.024-.096-.046-.062-.03-.084-.04-.086-.044-.093-.047-.052-.027-.103-.055-.057-.03-.058-.032a6.49 6.49 0 01-.046-.026l-.094-.053-.06-.034-.051-.03-.072-.041-.082-.05-.093-.056-.052-.032-.084-.053-.061-.039-.079-.05-.07-.047-.053-.035a7.785 7.785 0 01-.054-.036l-.044-.03-.044-.03a6.066 6.066 0 01-.04-.028l-.057-.04-.076-.054-.069-.05-.074-.054-.056-.042-.076-.057-.076-.059-.086-.067-.045-.035-.064-.052-.074-.06-.089-.073-.046-.039-.046-.039a7.516 7.516 0 01-.043-.037l-.045-.04-.061-.053-.07-.062-.068-.06-.062-.058-.067-.062-.053-.05-.088-.084a13.28 13.28 0 01-.099-.097l-.029-.028-.041-.042-.069-.07-.05-.051-.05-.053a6.457 6.457 0 01-.168-.179l-.08-.088-.062-.07-.071-.08-.042-.049-.053-.062-.058-.068-.046-.056a7.175 7.175 0 01-.027-.033l-.045-.055-.066-.082-.041-.052-.05-.064-.02-.025a11.99 11.99 0 01-1.44-2.402zm-1.02-5.794l11.353 3.037a20.468 20.468 0 00-.469 2.011l10.817 2.894a12.076 12.076 0 01-1.845 2.005L.657 15.923l-.016-.046-.035-.104a11.965 11.965 0 01-.05-.153l-.007-.023a11.896 11.896 0 01-.207-.741l-.03-.126-.018-.08-.021-.097-.018-.081-.018-.09-.017-.084-.018-.094c-.026-.141-.05-.283-.071-.426l-.017-.118-.011-.083-.013-.102a12.01 12.01 0 01-.019-.161l-.005-.047a12.12 12.12 0 01-.034-2.145zm1.593-5.15l11.948 3.196c-.368.605-.705 1.231-1.01 1.875l11.295 3.022c-.142.82-.368 1.612-.668 2.365l-11.55-3.09L.124 10.26l.015-.1.008-.049.01-.067.015-.087.018-.098c.026-.148.056-.295.088-.442l.028-.124.02-.085.024-.097c.022-.09.045-.18.07-.268l.028-.102.023-.083.03-.1.025-.082.03-.096.026-.082.031-.095a11.896 11.896 0 011.01-2.232zm4.442-4.4L17.352 4.59a20.77 20.77 0 00-1.688 1.721l7.823 2.093c.267.852.442 1.744.513 2.665L2.106 5.213l.045-.065.027-.04.04-.055.046-.065.055-.076.054-.072.064-.086.05-.065.057-.073.055-.07.06-.074.055-.069.065-.077.054-.066.066-.077.053-.06.072-.082.053-.06.067-.074.054-.058.073-.078.058-.06.063-.067.168-.17.1-.098.059-.056.076-.071a12.084 12.084 0 012.272-1.677zM12.017 0h.097l.082.001.069.001.054.002.068.002.046.001.076.003.047.002.06.003.054.002.087.005.105.007.144.011.088.007.044.004.077.008.082.008.047.005.102.012.05.006.108.014.081.01.042.006.065.01.207.032.07.012.065.011.14.026.092.018.11.022.046.01.075.016.041.01L14.7.3l.042.01.065.015.049.012.071.017.096.024.112.03.113.03.113.032.05.015.07.02.078.024.073.023.05.016.05.016.076.025.099.033.102.036.048.017.064.023.093.034.11.041.116.045.1.04.047.02.06.024.041.018.063.026.04.018.057.025.11.048.1.046.074.035.075.036.06.028.092.046.091.045.102.052.053.028.049.026.046.024.06.033.041.022.052.029.088.05.106.06.087.051.057.034.053.032.096.059.088.055.098.062.036.024.064.041.084.056.04.027.062.042.062.043.023.017c.054.037.108.075.161.114l.083.06.065.048.056.043.086.065.082.064.04.03.05.041.086.069.079.065.085.071c.712.6 1.353 1.283 1.909 2.031L7.222.994l.062-.027.065-.028.081-.034.086-.035c.113-.045.227-.09.341-.131l.096-.035.093-.033.084-.03.096-.031c.087-.03.176-.058.264-.085l.091-.027.086-.025.102-.03.085-.023.1-.026L9.04.37l.09-.023.091-.022.095-.022.09-.02.098-.021.091-.02.095-.018.092-.018.1-.018.091-.016.098-.017.092-.014.097-.015.092-.013.102-.013.091-.012.105-.012.09-.01.105-.01c.093-.01.186-.018.28-.024l.106-.008.09-.005.11-.006.093-.004.1-.004.097-.002.099-.002.197-.002z"></path></svg>\n\n';
|
|
578
|
+
|
|
579
|
+
// src/vendor-icons/nvidia.svg?raw
|
|
580
|
+
var nvidia_default = '<svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M10.212 8.976V7.62c.127-.01.256-.017.388-.021 3.596-.117 5.957 3.184 5.957 3.184s-2.548 3.647-5.282 3.647a3.227 3.227 0 01-1.063-.175v-4.109c1.4.174 1.681.812 2.523 2.258l1.873-1.627a4.905 4.905 0 00-3.67-1.846 6.594 6.594 0 00-.729.044m0-4.476v2.025c.13-.01.259-.019.388-.024 5.002-.174 8.261 4.226 8.261 4.226s-3.743 4.69-7.643 4.69c-.338 0-.675-.031-1.007-.092v1.25c.278.038.558.057.838.057 3.629 0 6.253-1.91 8.794-4.169.421.347 2.146 1.193 2.501 1.564-2.416 2.083-8.048 3.763-11.24 3.763-.308 0-.603-.02-.894-.048V19.5H24v-15H10.21zm0 9.756v1.068c-3.356-.616-4.287-4.21-4.287-4.21a7.173 7.173 0 014.287-2.138v1.172h-.005a3.182 3.182 0 00-2.502 1.178s.615 2.276 2.507 2.931m-5.961-3.3c1.436-1.935 3.604-3.148 5.961-3.336V6.523C5.81 6.887 2 10.723 2 10.723s2.158 6.427 8.21 7.015v-1.166C5.77 16 4.25 10.958 4.25 10.958h-.002z" fill="#74B71B" fill-rule="nonzero"/></svg>\n\n';
|
|
581
|
+
|
|
582
|
+
// src/vendor-icons/nousresearch.svg?raw
|
|
583
|
+
var nousresearch_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" role="img" aria-labelledby="nous-title"><title id="nous-title">Nous Research</title><rect width="48" height="48" rx="12" fill="#09090B"/><path fill="none" stroke="#fff" stroke-linecap="round" stroke-linejoin="round" stroke-width="4" d="M13 34V14l22 20V14M13 14l22 20"/></svg>\n';
|
|
584
|
+
|
|
585
|
+
// src/vendor-icons/openai.svg?raw
|
|
586
|
+
var openai_default = '<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" fill="none" viewBox="0 0 128 128"><g clip-path="url(#clip0_2138_504)"><g clip-path="url(#clip1_2138_504)"><path fill="#000" d="M118.824 52.388a31.9 31.9 0 0 0-2.74-26.192 32.25 32.25 0 0 0-34.736-15.472A31.9 31.9 0 0 0 57.296 0C43.28-.032 30.844 8.992 26.532 22.328A31.9 31.9 0 0 0 5.208 37.796C-1.828 49.924-.224 65.212 9.176 75.612a31.9 31.9 0 0 0 2.74 26.192 32.25 32.25 0 0 0 34.736 15.472 31.88 31.88 0 0 0 24.052 10.72c14.024.036 26.464-8.996 30.776-22.344a31.9 31.9 0 0 0 21.324-15.468 32.26 32.26 0 0 0-3.976-37.804zm-48.112 67.244a23.9 23.9 0 0 1-15.356-5.552c.196-.104.536-.292.756-.428L81.6 98.932a4.14 4.14 0 0 0 2.096-3.628V59.372l10.772 6.22a.38.38 0 0 1 .208.296v29.756c-.016 13.232-10.732 23.96-23.964 23.988M19.176 97.62a23.88 23.88 0 0 1-2.86-16.072c.188.112.52.316.756.452L42.56 96.72a4.15 4.15 0 0 0 4.188 0l31.116-17.968v12.44a.4.4 0 0 1-.152.332L51.948 106.4c-11.476 6.608-26.132 2.68-32.768-8.78zm-6.708-55.636a23.9 23.9 0 0 1 12.484-10.516c0 .22-.012.608-.012.88v29.444a4.15 4.15 0 0 0 2.092 3.624L58.148 83.38 47.376 89.6a.38.38 0 0 1-.364.032L21.244 74.744c-11.452-6.632-15.38-21.284-8.78-32.756zm88.504 20.596L69.856 44.612l10.772-6.216a.38.38 0 0 1 .364-.032L106.76 53.24c11.472 6.628 15.404 21.304 8.776 32.776a23.98 23.98 0 0 1-12.48 10.512V66.204a4.14 4.14 0 0 0-2.08-3.624zm10.72-16.136c-.188-.116-.52-.316-.756-.452l-25.488-14.72a4.15 4.15 0 0 0-4.188 0L50.144 49.24V36.8a.4.4 0 0 1 .152-.332L76.06 21.604c11.476-6.62 26.148-2.68 32.764 8.8a23.98 23.98 0 0 1 2.86 16.04zM44.288 68.616l-10.776-6.22a.38.38 0 0 1-.208-.296V32.344C33.312 19.096 44.06 8.36 57.308 8.368a23.98 23.98 0 0 1 15.336 5.552c-.196.104-.532.292-.756.428L46.4 29.068a4.14 4.14 0 0 0-2.096 3.624l-.016 35.916zM50.14 56 64 47.996l13.86 8V72L64 80l-13.86-8z"/></g></g><defs><clipPath id="clip0_2138_504"><path fill="#fff" d="M0 0h128v128H0z"/></clipPath><clipPath id="clip1_2138_504"><path fill="#fff" d="M0 0h128v128H0z"/></clipPath></defs></svg>\n';
|
|
587
|
+
|
|
588
|
+
// src/vendor-icons/qwen.svg?raw
|
|
589
|
+
var qwen_default = '<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24"><title>Qwen</title><defs><linearGradient id="lobe-icons-qwen-fill" x1="0%" x2="100%" y1="0%" y2="0%"><stop offset="0%" stop-color="#00055f" stop-opacity=".84"/><stop offset="100%" stop-color="#6f69f7" stop-opacity=".84"/></linearGradient></defs><path fill="url(#lobe-icons-qwen-fill)" d="M12.604 1.34q.59 1.035 1.174 2.075a.18.18 0 0 0 .157.091h5.552q.26 0 .446.327l1.454 2.57c.19.337.24.478.024.837q-.39.646-.76 1.3l-.367.658c-.106.196-.223.28-.04.512l2.652 4.637c.172.301.111.494-.043.77q-.656 1.177-1.335 2.34c-.159.272-.352.375-.68.37a43 43 0 0 0-2.327.016.1.1 0 0 0-.081.05 575 575 0 0 1-2.705 4.74c-.169.293-.38.363-.725.364q-1.495.005-3.017.002a.54.54 0 0 1-.465-.271l-1.335-2.323a.09.09 0 0 0-.083-.049H4.982a1.8 1.8 0 0 1-.805-.092l-1.603-2.77a.54.54 0 0 1-.002-.54l1.207-2.12a.2.2 0 0 0 0-.197 551 551 0 0 1-1.875-3.272l-.79-1.395c-.16-.31-.173-.496.095-.965q.697-1.22 1.387-2.436c.132-.234.304-.334.584-.335a338 338 0 0 1 2.589-.001.12.12 0 0 0 .107-.063l2.806-4.895a.49.49 0 0 1 .422-.246c.524-.001 1.053 0 1.583-.006L11.704 1c.341-.003.724.032.9.34m-3.432.403a.06.06 0 0 0-.052.03L6.254 6.788a.16.16 0 0 1-.135.078H3.253q-.084 0-.041.074l5.81 10.156q.037.062-.034.063l-2.795.015a.22.22 0 0 0-.2.116l-1.32 2.31q-.066.117.068.118l5.716.008q.068 0 .104.061l1.403 2.454q.069.122.139 0l5.006-8.76.783-1.382a.055.055 0 0 1 .096 0l1.424 2.53a.12.12 0 0 0 .107.062l2.763-.02a.04.04 0 0 0 .035-.02.04.04 0 0 0 0-.04l-2.9-5.086a.11.11 0 0 1 0-.113l.293-.507 1.12-1.977q.036-.062-.035-.062H9.2q-.088 0-.043-.077l1.434-2.505a.11.11 0 0 0 0-.114L9.225 1.774a.06.06 0 0 0-.053-.031m6.29 8.02q.07 0 .034.06l-.832 1.465-2.613 4.585a.06.06 0 0 1-.05.029.06.06 0 0 1-.05-.029L8.498 9.841q-.03-.051.028-.054l.216-.012 6.722-.012z"/></svg>\n';
|
|
590
|
+
|
|
591
|
+
// src/vendor-icons/sao10k.svg?raw
|
|
592
|
+
var sao10k_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" role="img" aria-labelledby="sao10k-title"><title id="sao10k-title">Sao10K</title><rect width="48" height="48" rx="12" fill="#7C3AED"/><text x="24" y="28" fill="#fff" font-family="system-ui,sans-serif" font-size="12" font-weight="700" text-anchor="middle">S10K</text></svg>\n';
|
|
593
|
+
|
|
594
|
+
// src/vendor-icons/stepfun.svg?raw
|
|
595
|
+
var stepfun_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" role="img" aria-labelledby="stepfun-title"><title id="stepfun-title">StepFun</title><path fill="#111827" d="M22.012 0h1.032v.927H24v.968h-.956V3.78h-1.032V1.896h-1.878v-.97h1.878V0zM2.6 12.371V1.87h.969v10.502h-.97zm10.423.66h10.95v.918h-6.208v9.579h-4.742V13.03zM5.629 3.333v12.356H0v4.51h10.386V8L20.859 8l-.003-4.668-15.227.001z"/></svg>\n';
|
|
596
|
+
|
|
597
|
+
// src/vendor-icons/tencent.svg?raw
|
|
598
|
+
var tencent_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640" role="img" aria-labelledby="hunyuan-title">\n<title id="hunyuan-title">Tencent Hunyuan</title>\n<path d="M0 0 C6.75 0.6 13.08 1.83 19.62 3.56 C20.62 3.83 21.62 4.09 22.65 4.36 C72.51 17.91 116.93 43.29 155 78 C156.73 79.54 158.46 81.08 160.19 82.62 C166.94 88.71 173.09 95.1 179 102 C179.8 102.91 180.6 103.83 181.43 104.77 C227.38 157.49 257.88 229.61 258.2 300.04 C258.21 301.06 258.22 302.09 258.22 303.15 C258.24 306.46 258.25 309.76 258.25 313.06 C258.25 313.63 258.25 313.63 258.25 316.48 C258.24 332.54 257.91 348.17 255 364 C254.83 364.99 254.66 365.99 254.48 367.02 C243.71 428.88 216.25 484.66 174 531 C172.46 532.73 170.92 534.46 169.38 536.19 C163.29 542.94 156.9 549.09 150 555 C149.54 555.4 149.54 555.4 147.23 557.43 C98.74 599.69 36.86 626.15 -27 633 C-27.75 633.09 -28.49 633.17 -29.26 633.26 C-35.53 633.95 -41.73 634.17 -48.04 634.2 C-49.06 634.21 -50.09 634.22 -51.15 634.22 C-54.46 634.24 -57.76 634.25 -61.06 634.25 C-61.63 634.25 -61.63 634.25 -64.48 634.25 C-80.53 634.24 -96.17 633.92 -112 631 C-113.01 630.82 -114.02 630.65 -115.06 630.46 C-166.68 621.33 -217.07 601.24 -258 568 C-258.86 567.33 -259.73 566.65 -260.62 565.96 C-266.11 561.67 -271.28 557.09 -276.41 552.37 C-278.6 550.37 -280.81 548.43 -283.06 546.5 C-290.63 539.91 -297.51 532.65 -304 525 C-304.8 524.09 -305.6 523.18 -306.42 522.25 C-352.14 469.83 -381.88 397.82 -382.2 327.9 C-382.21 326.88 -382.22 325.85 -382.22 324.8 C-382.45 282.09 -382.45 282.09 -379 263 C-378.8 261.87 -378.6 260.73 -378.4 259.56 C-373.92 234.56 -366.67 210.48 -357 187 C-356.66 186.18 -356.33 185.36 -355.98 184.52 C-355.64 183.72 -355.3 182.92 -354.95 182.1 C-354.65 181.38 -354.35 180.67 -354.04 179.93 C-352.92 177.86 -351.66 176.64 -350 175 C-348.96 173.42 -347.96 171.8 -347 170.17 C-346.43 169.21 -345.85 168.25 -345.27 167.27 C-344.66 166.25 -344.06 165.23 -343.44 164.19 C-331.42 144.22 -318.96 124.69 -294.81 118.43 C-280.94 115.37 -265.1 115.15 -252 121 C-250.93 121.47 -249.85 121.95 -248.75 122.44 C-232.73 130.3 -220.7 143.72 -214.71 160.6 C-210.71 174.17 -210.47 188.54 -215 202 C-215.31 202.93 -215.61 203.85 -215.93 204.81 C-218.84 212.63 -223.24 219.26 -227.82 226.16 C-236.74 239.63 -245.07 253.41 -252 268 C-252.61 269.2 -253.22 270.4 -253.84 271.59 C-284.74 331.58 -298.6 398.7 -277.87 464.32 C-266.79 498.53 -247.75 528.21 -224 555 C-222.85 556.33 -221.71 557.67 -220.56 559 C-205.7 575.86 -205.7 575.86 -198.21 582.11 C-195.74 584.22 -193.38 586.43 -191.02 588.65 C-184.56 594.73 -177.96 600.51 -171 606 C-170.39 606.48 -169.79 606.96 -169.17 607.45 C-165.12 610.64 -161.06 613.83 -157 617 C-159.56 613.73 -162.24 610.6 -165.01 607.5 C-201.18 566.59 -213.33 515.45 -211 462 C-208.95 430.25 -197.01 398.12 -176 374 C-175.27 373.16 -174.54 372.32 -173.78 371.45 C-171.55 368.93 -169.29 366.46 -167 364 C-166.41 363.35 -165.82 362.69 -165.21 362.02 C-151.26 347.17 -131.41 335.11 -112 329 C-110.68 329 -109.36 329 -108 329 C-108.02 329.83 -108.03 330.66 -108.05 331.52 C-108.55 362.08 -108.55 362.08 -105 374 C-104.87 374.49 -104.87 374.49 -104.23 376.95 C-100.13 390.99 -92.23 403.79 -83 415 C-82.69 415.39 -82.69 415.39 -81.15 417.35 C-63.85 438.22 -38.06 448.36 -12 453 C18.86 455.12 49.01 447.16 72.66 426.55 C79.34 420.6 85.74 414.38 92 408 C94.51 405.48 97.03 402.97 99.58 400.49 C105.87 394.33 111.52 387.91 117 381 C117.93 379.87 118.87 378.74 119.8 377.61 C146.48 345.23 166.07 306.78 176 266 C176.11 265.55 176.11 265.55 176.68 263.24 C180.18 248.28 180.39 233.29 180.44 218 C180.44 217.52 180.44 217.52 180.46 215.09 C180.51 202.72 179.64 191.09 177 179 C176.8 178.05 176.6 177.1 176.4 176.11 C165.8 127.29 136.46 82.53 97 52 C96 51.2 94.99 50.4 93.96 49.58 C85.94 43.25 77.59 37.53 69 32 C67.92 31.3 66.84 30.6 65.72 29.88 C57.43 24.63 48.85 20.21 40 16 C39.61 15.81 39.61 15.81 37.66 14.87 C25.4 8.98 13.13 4.56 0 1 C0 0.67 0 0.34 0 0 Z " fill="#0055E9" transform="translate(382,6)"/>\n<path d="M0 0 C1.07 -0 2.14 -0 3.24 -0 C5.48 -0 7.72 -0 9.96 0 C13.37 0.01 16.77 0 20.17 -0 C22.36 -0 24.56 -0 26.75 0 C27.75 -0 28.75 -0 29.79 -0.01 C36.37 0.02 42.83 0.43 49.38 1.13 C49.05 1.79 48.71 2.45 48.38 3.13 C49.57 3.62 50.77 4.1 52 4.6 C84.75 18.01 113.08 37.06 128.38 70.13 C134.91 85.9 137.95 101.96 137.75 119.01 C137.75 119.71 137.74 120.41 137.74 121.13 C137.65 131.73 137.12 141.84 134.38 152.13 C134.28 152.51 134.28 152.51 133.81 154.42 C129.31 172.21 122.25 189.95 110.38 204.13 C110.11 204.48 110.11 204.48 108.75 206.25 C91.52 227.63 60.34 238.15 35.91 248.86 C7.95 261.17 -13.02 280.6 -24.41 309.5 C-24.95 310.95 -25.48 312.42 -26 313.88 C-26.25 314.59 -26.51 315.31 -26.77 316.04 C-27.88 319.3 -28.62 322.1 -28.92 325.55 C-29.24 329.19 -29.56 331.09 -31.62 334.13 C-37.23 337.75 -43.73 339.81 -49.96 342.11 C-65.69 348.15 -78.48 358.7 -90.62 370.13 C-91.23 370.68 -91.83 371.23 -92.45 371.79 C-119.52 397.41 -133.67 437.32 -134.86 473.91 C-135.47 498.02 -134.37 522.12 -126.62 545.13 C-126.49 545.56 -126.49 545.56 -125.79 547.69 C-117.49 573.02 -105.01 595.73 -86.62 615.13 C-85.26 616.67 -83.91 618.21 -82.56 619.76 C-81.99 620.41 -81.43 621.06 -80.84 621.73 C-80.44 622.2 -80.04 622.66 -79.62 623.13 C-83.79 623.13 -85.84 620.9 -88.94 618.38 C-89.55 617.89 -90.17 617.4 -90.81 616.89 C-101.22 608.5 -111.25 599.7 -121.04 590.6 C-122.77 589 -124.5 587.42 -126.24 585.84 C-137.22 575.79 -137.22 575.79 -141.94 570.13 C-144.01 567.68 -146.19 565.36 -148.38 563.01 C-154.16 556.65 -159.44 549.98 -164.62 543.13 C-165.13 542.47 -165.64 541.81 -166.17 541.12 C-188.25 512.21 -204.68 478.22 -210.62 442.13 C-210.76 441.39 -210.89 440.64 -211.03 439.88 C-215.21 415.95 -214.59 392.03 -210.62 368.13 C-210.48 367.21 -210.33 366.29 -210.19 365.34 C-205.88 338.85 -196.58 312.13 -184.62 288.13 C-183.95 286.75 -183.28 285.36 -182.61 283.98 C-180.99 280.66 -179.32 277.37 -177.63 274.08 C-176.96 272.78 -176.29 271.47 -175.63 270.17 C-168.29 255.69 -160.05 241.56 -150.94 228.12 C-139.52 211.27 -134.97 193.23 -138.69 173.01 C-142.32 158.06 -151.03 144.12 -163.62 135.13 C-175.37 128.13 -186.81 123.58 -200.62 123.82 C-201.55 123.82 -202.47 123.81 -203.41 123.81 C-212.93 123.88 -221.23 125.38 -229.69 129.82 C-230.03 130 -230.03 130 -231.77 130.89 C-242.14 136.37 -249.78 143.51 -256.44 153.13 C-257.16 154.12 -257.88 155.11 -258.62 156.13 C-259.28 156.13 -259.94 156.13 -260.62 156.13 C-260.1 151.42 -257.94 148.13 -255.31 144.32 C-255.09 144 -255.09 144 -253.97 142.35 C-232.29 110.77 -232.29 110.77 -225.37 106.86 C-221.91 104.68 -219.27 102.04 -216.41 99.14 C-216.12 98.85 -216.12 98.85 -214.65 97.38 C-213.42 96.16 -212.2 94.93 -210.99 93.7 C-209.14 91.83 -207.28 89.97 -205.42 88.11 C-204.23 86.91 -203.03 85.72 -201.84 84.52 C-201.29 83.97 -200.75 83.42 -200.18 82.85 C-197.65 80.29 -195.24 77.71 -192.97 74.93 C-191.04 72.63 -189.31 70.86 -186.95 69.05 C-186.27 68.54 -185.6 68.02 -184.9 67.49 C-184.19 66.96 -183.48 66.43 -182.75 65.88 C-182 65.32 -181.25 64.75 -180.48 64.17 C-173.38 58.87 -166.11 53.87 -158.62 49.13 C-158.04 48.76 -157.46 48.39 -156.86 48.01 C-110.72 19 -54.84 -0.11 0 0 Z " fill="#A7DEF4" transform="translate(306.625,-0.1328125)"/>\n<path d="M0 0 C2.06 0.14 4.13 0.29 6.19 0.44 C7.34 0.52 8.48 0.6 9.67 0.68 C12.52 0.95 15.21 1.38 18 2 C18 2.66 18 3.32 18 4 C18.61 4.07 19.22 4.15 19.84 4.23 C57.38 9.86 95.12 36.37 123 61 C123.86 61.75 124.71 62.49 125.6 63.26 C135.95 72.4 145.58 82.04 154 93 C154.43 93.56 154.86 94.12 155.31 94.7 C165.93 108.58 174.55 123.21 182 139 C182.27 139.56 182.27 139.56 183.62 142.42 C189.87 156.26 193.99 171.14 197 186 C197.18 186.88 197.36 187.76 197.55 188.67 C199.45 199.32 199.4 209.96 199.38 220.75 C199.37 221.75 199.37 222.75 199.37 223.79 C199.32 239.19 198.77 253.98 195 269 C194.87 269.54 194.87 269.54 194.19 272.25 C189.91 288.76 184.06 304.49 177 320 C176.66 320.75 176.32 321.5 175.97 322.27 C165.46 345 151.21 365.96 135 385 C134.03 386.15 133.06 387.31 132.1 388.46 C126.34 395.29 120.43 401.79 114 408 C111.21 410.77 108.45 413.56 105.72 416.38 C83.23 439.47 55.67 456.71 22.5 457.29 C10.42 457.37 -0.41 456.4 -12 453 C-13.06 452.71 -14.12 452.42 -15.21 452.12 C-28.84 448.04 -41.09 441.05 -52 432 C-52.42 431.66 -52.42 431.66 -54.57 429.92 C-74.53 413 -87.38 387.76 -91 362 C-91.08 359.55 -91.11 357.09 -91.1 354.63 C-91.1 353.95 -91.09 353.27 -91.09 352.57 C-91.09 350.42 -91.08 348.27 -91.06 346.12 C-91.06 344.66 -91.05 343.19 -91.05 341.73 C-91.04 338.15 -91.02 334.58 -91 331 C-74.08 326.37 -58.2 324.13 -40.69 323.56 C-0.78 322.23 37.3 308.79 66.67 281.18 C68.49 279.48 70.3 277.91 72.25 276.38 C93.96 257.63 107.24 229.03 115 202 C115.29 201.02 115.58 200.04 115.88 199.03 C127.04 157.72 119.02 112.76 98.18 76 C88.06 58.82 74.78 43.15 59 31 C58.08 30.26 57.15 29.52 56.2 28.76 C44.54 19.64 31.57 12.84 18 7 C17.09 6.61 16.19 6.22 15.25 5.82 C10.23 3.73 5.31 2.18 0 1 C0 0.67 0 0.34 0 0 Z " fill="#00BBFE" transform="translate(364,3)"/>\n<path d="M0 0 C3.96 0 7.92 0 12 0 C12 0.66 12 1.32 12 2 C12.55 2.07 13.1 2.15 13.66 2.23 C37.23 6.14 60.54 20.85 77.76 36.91 C79.85 38.86 82 40.72 84.19 42.56 C88.2 46.09 91.65 49.84 95 54 C95.22 54.27 95.22 54.27 96.31 55.63 C104.44 65.81 111.03 76.43 117 88 C117.28 88.53 117.28 88.53 118.71 91.18 C135.83 125.2 138.65 170.55 127.15 206.69 C126.77 207.78 126.39 208.88 126 210 C125.79 210.62 125.58 211.24 125.36 211.87 C115.6 240.43 98.74 267.94 75 287 C74.06 287.77 73.12 288.54 72.14 289.33 C59.19 299.71 45.13 307.28 30 314 C29.13 314.4 28.26 314.8 27.37 315.21 C8.53 323.4 -11.46 324.91 -31.69 325.61 C-47.24 326.18 -61.89 328.32 -77 332 C-74.58 310.32 -64.5 290.12 -50 274 C-49.65 273.58 -49.65 273.58 -47.89 271.43 C-33.78 254.62 -12.26 246.57 7.32 237.95 C42.44 222.48 67.21 206.71 82 170 C84.43 163.44 86.31 156.78 88 150 C88.18 149.34 88.35 148.67 88.53 147.99 C93.81 127.65 93.28 102.03 87 82 C86.79 81.31 86.57 80.61 86.35 79.9 C81.82 65.69 74.78 53.27 65 42 C64.66 41.59 64.66 41.59 62.95 39.52 C47.08 20.87 22.97 8.54 0 1 C0 0.67 0 0.34 0 0 Z " fill="#EBEBEE" transform="translate(352,2)"/>\n</svg>\n';
|
|
599
|
+
|
|
600
|
+
// src/vendor-icons/thinkingmachines.svg?raw
|
|
601
|
+
var thinkingmachines_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" role="img" aria-labelledby="thinking-machines-title"><title id="thinking-machines-title">Thinking Machines Lab</title><rect width="48" height="48" rx="12" fill="#111827"/><circle cx="24" cy="24" r="14" fill="none" stroke="#fff" stroke-width="3"/><path fill="#fff" d="M14 17h20v5h-7.5v14h-5V22H14z"/></svg>\n';
|
|
602
|
+
|
|
603
|
+
// src/vendor-icons/xiaomi.svg?raw
|
|
604
|
+
var xiaomi_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" role="img" aria-labelledby="xiaomi-title"><title id="xiaomi-title">Xiaomi</title><rect width="24" height="24" rx="6" fill="#FF6900"/><path fill="#fff" d="M5 7.1h8.2c3.7 0 5.8 2 5.8 5.7V18h-2.8v-5.1c0-2.2-1-3.1-3.1-3.1H5V7.1Zm0 4h2.8V18H5v-6.9Zm4.2 0H12V18H9.2v-6.9Z"/></svg>\n';
|
|
605
|
+
|
|
606
|
+
// src/vendor-icons/zai-org.svg?raw
|
|
607
|
+
var zai_org_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30" width="24" height="24">\n <path d="M24.51,28.51H5.49c-2.21,0-4-1.79-4-4V5.49c0-2.21,1.79-4,4-4h19.03c2.21,0,4,1.79,4,4v19.03C28.51,26.72,26.72,28.51,24.51,28.51z" fill="#2D2D2D" stroke="#FFFFFF" stroke-width="0.6317" stroke-miterlimit="10"/>\n <path d="M15.47,7.1l-1.3,1.85c-0.2,0.29-0.54,0.47-0.9,0.47h-7.1V7.09C6.16,7.1,15.47,7.1,15.47,7.1z" fill="#FFFFFF"/>\n <polygon points="24.3,7.1 13.14,22.91 5.7,22.91 16.86,7.1" fill="#FFFFFF"/>\n <path d="M14.53,22.91l1.31-1.86c0.2-0.29,0.54-0.47,0.9-0.47h7.09v2.33H14.53z" fill="#FFFFFF"/>\n</svg>\n\n';
|
|
608
|
+
|
|
609
|
+
// src/icons.ts
|
|
610
|
+
var LAB_ICONS = {
|
|
611
|
+
anthropic: anthropic_default,
|
|
612
|
+
bytedance: bytedance_default,
|
|
613
|
+
"deepseek-ai": deepseek_default,
|
|
614
|
+
google: google_default,
|
|
615
|
+
gryphe: gryphe_default,
|
|
616
|
+
"meta-llama": meta_default,
|
|
617
|
+
microsoft: microsoft_default,
|
|
618
|
+
minimaxai: minimax_default,
|
|
619
|
+
mistralai: mistralai_default,
|
|
620
|
+
moonshotai: moonshotai_default,
|
|
621
|
+
nvidia: nvidia_default,
|
|
622
|
+
nousresearch: nousresearch_default,
|
|
623
|
+
openai: openai_default,
|
|
624
|
+
qwen: qwen_default,
|
|
625
|
+
sao10k: sao10k_default,
|
|
626
|
+
"stepfun-ai": stepfun_default,
|
|
627
|
+
tencent: tencent_default,
|
|
628
|
+
thinkingmachines: thinkingmachines_default,
|
|
629
|
+
xiaomimimo: xiaomi_default,
|
|
630
|
+
"zai-org": zai_org_default
|
|
631
|
+
};
|
|
632
|
+
function normalizeIcon(icon) {
|
|
633
|
+
if (icon.startsWith("data:")) return icon;
|
|
634
|
+
return `data:image/svg+xml,${encodeURIComponent(icon).replace(/'/g, "%27").replace(/"/g, "%22")}`;
|
|
635
|
+
}
|
|
636
|
+
function getDeepInfraIconDataUri() {
|
|
637
|
+
return normalizeIcon(deepinfra_default);
|
|
638
|
+
}
|
|
639
|
+
function getDeepInfraModelIconDataUri(modelId) {
|
|
640
|
+
const lab = modelId?.trim().toLowerCase().split("/")[0];
|
|
641
|
+
return lab && LAB_ICONS[lab] ? normalizeIcon(LAB_ICONS[lab]) : void 0;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
// src/DeepInfraProvider.ts
|
|
645
|
+
var DEFAULT_BASE_URL = "https://api.deepinfra.com/v1/openai";
|
|
646
|
+
var DEFAULT_MODELS_URL = "https://api.deepinfra.com/v1/models";
|
|
647
|
+
function trimTrailingSlashes(value) {
|
|
648
|
+
return value.replace(/\/+$/, "");
|
|
649
|
+
}
|
|
650
|
+
function isVisionModel(model) {
|
|
651
|
+
const tags = model.metadata?.tags || [];
|
|
652
|
+
return tags.includes("vision") || tags.includes("vlm");
|
|
653
|
+
}
|
|
654
|
+
function normalizeDeepInfraPricePerMillion(value) {
|
|
655
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
656
|
+
return void 0;
|
|
657
|
+
}
|
|
658
|
+
return Number(value.toFixed(12));
|
|
659
|
+
}
|
|
660
|
+
function deepinfraUsagePricingFromModel(model) {
|
|
661
|
+
const inputPerMillion = normalizeDeepInfraPricePerMillion(
|
|
662
|
+
model?.metadata?.pricing?.input_tokens
|
|
663
|
+
);
|
|
664
|
+
const outputPerMillion = normalizeDeepInfraPricePerMillion(
|
|
665
|
+
model?.metadata?.pricing?.output_tokens
|
|
666
|
+
);
|
|
667
|
+
if (inputPerMillion === void 0 || outputPerMillion === void 0) {
|
|
668
|
+
return void 0;
|
|
669
|
+
}
|
|
670
|
+
const cachedInputPerMillion = normalizeDeepInfraPricePerMillion(
|
|
671
|
+
model?.metadata?.pricing?.cache_read_tokens
|
|
672
|
+
);
|
|
673
|
+
const pricing = {
|
|
674
|
+
inputPerMillion,
|
|
675
|
+
outputPerMillion
|
|
676
|
+
};
|
|
677
|
+
if (cachedInputPerMillion !== void 0) {
|
|
678
|
+
pricing.cachedInputPerMillion = cachedInputPerMillion;
|
|
679
|
+
}
|
|
680
|
+
return pricing;
|
|
681
|
+
}
|
|
682
|
+
function calculateDeepInfraUsageCost(usage, pricing) {
|
|
683
|
+
if (!pricing || typeof pricing.inputPerMillion !== "number" || typeof pricing.outputPerMillion !== "number") {
|
|
684
|
+
return void 0;
|
|
685
|
+
}
|
|
686
|
+
const cachedTokens = usage.cachedTokens || 0;
|
|
687
|
+
const uncachedPromptTokens = Math.max(0, usage.promptTokens - cachedTokens);
|
|
688
|
+
const cachedRate = pricing.cachedInputPerMillion ?? pricing.inputPerMillion;
|
|
689
|
+
return Number((uncachedPromptTokens / 1e6 * pricing.inputPerMillion + cachedTokens / 1e6 * cachedRate + usage.completionTokens / 1e6 * pricing.outputPerMillion).toFixed(12));
|
|
690
|
+
}
|
|
691
|
+
var DeepInfraProvider = class _DeepInfraProvider {
|
|
692
|
+
name = "deepinfra";
|
|
693
|
+
specificationVersion = "1";
|
|
694
|
+
config;
|
|
695
|
+
modelsCache = null;
|
|
696
|
+
modelsCacheTime = 0;
|
|
697
|
+
static CACHE_TTL = 5 * 60 * 1e3;
|
|
698
|
+
constructor(config) {
|
|
699
|
+
this.config = config;
|
|
700
|
+
}
|
|
701
|
+
supportsModel(_modelId) {
|
|
702
|
+
return true;
|
|
703
|
+
}
|
|
704
|
+
getIcon(modelId) {
|
|
705
|
+
return getDeepInfraModelIconDataUri(modelId) || getDeepInfraIconDataUri();
|
|
706
|
+
}
|
|
707
|
+
baseUrl() {
|
|
708
|
+
return trimTrailingSlashes(this.config.baseUrl || DEFAULT_BASE_URL);
|
|
709
|
+
}
|
|
710
|
+
modelsUrl() {
|
|
711
|
+
const configured = typeof this.config.modelsUrl === "string" ? this.config.modelsUrl : void 0;
|
|
712
|
+
return trimTrailingSlashes(configured || DEFAULT_MODELS_URL);
|
|
713
|
+
}
|
|
714
|
+
fetch() {
|
|
715
|
+
return this.config.fetch || globalThis.fetch;
|
|
716
|
+
}
|
|
717
|
+
headers() {
|
|
718
|
+
return {
|
|
719
|
+
...this.config.defaultHeaders,
|
|
720
|
+
"Content-Type": "application/json",
|
|
721
|
+
"Authorization": `Bearer ${this.config.apiKey}`
|
|
722
|
+
};
|
|
723
|
+
}
|
|
724
|
+
requestGuard(externalSignal) {
|
|
725
|
+
const controller = new AbortController();
|
|
726
|
+
const abortFromExternal = () => controller.abort(externalSignal?.reason);
|
|
727
|
+
if (externalSignal?.aborted) abortFromExternal();
|
|
728
|
+
else externalSignal?.addEventListener("abort", abortFromExternal, { once: true });
|
|
729
|
+
const timeoutMs = typeof this.config.timeout === "number" ? this.config.timeout : 3e4;
|
|
730
|
+
const timer = setTimeout(() => controller.abort(new DOMException("DeepInfra request timed out", "TimeoutError")), timeoutMs);
|
|
731
|
+
return {
|
|
732
|
+
signal: controller.signal,
|
|
733
|
+
cleanup: () => {
|
|
734
|
+
clearTimeout(timer);
|
|
735
|
+
externalSignal?.removeEventListener("abort", abortFromExternal);
|
|
736
|
+
}
|
|
737
|
+
};
|
|
738
|
+
}
|
|
739
|
+
async fetchModelsWithCache() {
|
|
740
|
+
const now = Date.now();
|
|
741
|
+
if (this.modelsCache && now - this.modelsCacheTime < _DeepInfraProvider.CACHE_TTL) {
|
|
742
|
+
return this.modelsCache;
|
|
743
|
+
}
|
|
744
|
+
const response = await this.fetch()(this.modelsUrl(), {
|
|
745
|
+
method: "GET",
|
|
746
|
+
headers: this.headers()
|
|
747
|
+
});
|
|
748
|
+
if (!response.ok) {
|
|
749
|
+
throw await this.toHttpProviderErrorFromResponse(response, "DeepInfra models API error");
|
|
750
|
+
}
|
|
751
|
+
const data = await response.json();
|
|
752
|
+
this.modelsCache = (data.data || []).filter((model) => model.metadata?.tags?.includes("chat"));
|
|
753
|
+
this.modelsCacheTime = now;
|
|
754
|
+
return this.modelsCache;
|
|
755
|
+
}
|
|
756
|
+
mapModelCapabilities(model) {
|
|
757
|
+
return {
|
|
758
|
+
supportsImages: isVisionModel(model),
|
|
759
|
+
supportsToolCalls: true,
|
|
760
|
+
supportsStreaming: true,
|
|
761
|
+
supportsJsonMode: true,
|
|
762
|
+
maxContextTokens: model.metadata?.context_length
|
|
763
|
+
};
|
|
764
|
+
}
|
|
765
|
+
async getModelCapabilities(modelId) {
|
|
766
|
+
try {
|
|
767
|
+
const models = await this.fetchModelsWithCache();
|
|
768
|
+
const model = models.find((candidate) => candidate.id === modelId);
|
|
769
|
+
if (!model) return null;
|
|
770
|
+
return this.mapModelCapabilities(model);
|
|
771
|
+
} catch (error) {
|
|
772
|
+
console.error(`Failed to fetch capabilities for DeepInfra model ${modelId}:`, error);
|
|
773
|
+
return null;
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
mapToProviderModelInfo(model) {
|
|
777
|
+
const pricing = deepinfraUsagePricingFromModel(model);
|
|
778
|
+
return {
|
|
779
|
+
id: model.id,
|
|
780
|
+
name: model.id,
|
|
781
|
+
description: model.metadata?.description,
|
|
782
|
+
contextLength: model.metadata?.context_length,
|
|
783
|
+
iconId: this.getIcon(model.id),
|
|
784
|
+
slug: model.id,
|
|
785
|
+
inputPrice: pricing?.inputPerMillion,
|
|
786
|
+
outputPrice: pricing?.outputPerMillion,
|
|
787
|
+
cachedPrice: pricing?.cachedInputPerMillion,
|
|
788
|
+
capabilities: this.mapModelCapabilities(model)
|
|
789
|
+
};
|
|
790
|
+
}
|
|
791
|
+
async getModels(filter) {
|
|
792
|
+
try {
|
|
793
|
+
let models = (await this.fetchModelsWithCache()).map((model) => this.mapToProviderModelInfo(model)).sort((a, b) => a.name.localeCompare(b.name));
|
|
794
|
+
if (filter) {
|
|
795
|
+
const lowerFilter = filter.toLowerCase();
|
|
796
|
+
models = models.filter(
|
|
797
|
+
(model) => model.id.toLowerCase().includes(lowerFilter) || model.name.toLowerCase().includes(lowerFilter) || model.description && model.description.toLowerCase().includes(lowerFilter)
|
|
798
|
+
);
|
|
799
|
+
}
|
|
800
|
+
return models;
|
|
801
|
+
} catch (error) {
|
|
802
|
+
console.error("Failed to fetch models from DeepInfra:", error);
|
|
803
|
+
return [];
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
async getUsagePricing(modelId) {
|
|
807
|
+
if (!modelId) return void 0;
|
|
808
|
+
try {
|
|
809
|
+
const models = await this.fetchModelsWithCache();
|
|
810
|
+
const model = models.find((candidate) => candidate.id === modelId);
|
|
811
|
+
return deepinfraUsagePricingFromModel(model);
|
|
812
|
+
} catch {
|
|
813
|
+
return void 0;
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
async generate(request) {
|
|
817
|
+
const guard = this.requestGuard(request.signal);
|
|
818
|
+
try {
|
|
819
|
+
const response = await this.fetch()(`${this.baseUrl()}/chat/completions`, {
|
|
820
|
+
method: "POST",
|
|
821
|
+
headers: this.headers(),
|
|
822
|
+
body: JSON.stringify(buildChatParams(request)),
|
|
823
|
+
signal: guard.signal
|
|
824
|
+
});
|
|
825
|
+
if (!response.ok) {
|
|
826
|
+
throw await this.toHttpProviderErrorFromResponse(response, "DeepInfra API error");
|
|
827
|
+
}
|
|
828
|
+
const data = await response.json();
|
|
829
|
+
const result = transformChatResponse(data);
|
|
830
|
+
if (result.usage.cost === void 0) {
|
|
831
|
+
attachUsagePricing(result.usage, await this.getUsagePricing(request.model));
|
|
832
|
+
}
|
|
833
|
+
return result;
|
|
834
|
+
} catch (error) {
|
|
835
|
+
throw this.toProviderError(error);
|
|
836
|
+
} finally {
|
|
837
|
+
guard.cleanup();
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
async stream(request) {
|
|
841
|
+
const self = this;
|
|
842
|
+
const guard = this.requestGuard(request.signal);
|
|
843
|
+
try {
|
|
844
|
+
const response = await this.fetch()(`${this.baseUrl()}/chat/completions`, {
|
|
845
|
+
method: "POST",
|
|
846
|
+
headers: this.headers(),
|
|
847
|
+
body: JSON.stringify({
|
|
848
|
+
...buildChatParams(request),
|
|
849
|
+
stream: true,
|
|
850
|
+
stream_options: { include_usage: true }
|
|
851
|
+
}),
|
|
852
|
+
signal: guard.signal
|
|
853
|
+
});
|
|
854
|
+
if (!response.ok) {
|
|
855
|
+
throw await this.toHttpProviderErrorFromResponse(response, "DeepInfra API error");
|
|
856
|
+
}
|
|
857
|
+
return {
|
|
858
|
+
async *[Symbol.asyncIterator]() {
|
|
859
|
+
const state = createChatStreamState(request.model);
|
|
860
|
+
try {
|
|
861
|
+
for await (const chunk of parseChatSSEStream(response, state)) {
|
|
862
|
+
if (chunk.type === "finish") {
|
|
863
|
+
if (chunk.usage.cost === void 0) {
|
|
864
|
+
attachUsagePricing(chunk.usage, await self.getUsagePricing(request.model));
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
yield chunk;
|
|
868
|
+
}
|
|
869
|
+
} catch (error) {
|
|
870
|
+
const providerError = self.toProviderError(error);
|
|
871
|
+
yield createChatErrorChunk(providerError.message, providerError.code);
|
|
872
|
+
} finally {
|
|
873
|
+
guard.cleanup();
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
};
|
|
877
|
+
} catch (error) {
|
|
878
|
+
guard.cleanup();
|
|
879
|
+
throw this.toProviderError(error);
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
async toHttpProviderErrorFromResponse(response, fallbackPrefix) {
|
|
883
|
+
const errorText = await response.text();
|
|
884
|
+
let errorMessage = `${fallbackPrefix}: ${response.status}`;
|
|
885
|
+
try {
|
|
886
|
+
const errorJson = JSON.parse(errorText);
|
|
887
|
+
errorMessage = errorJson.error?.message || errorJson.message || errorMessage;
|
|
888
|
+
} catch {
|
|
889
|
+
errorMessage = errorText || errorMessage;
|
|
890
|
+
}
|
|
891
|
+
return this.toHttpProviderError(errorMessage, response.status, response.headers);
|
|
892
|
+
}
|
|
893
|
+
toProviderError(error) {
|
|
894
|
+
if (error instanceof ProviderError) {
|
|
895
|
+
return error;
|
|
896
|
+
}
|
|
897
|
+
if (error instanceof Error) {
|
|
898
|
+
const anyError = error;
|
|
899
|
+
const status = anyError.status || anyError.statusCode;
|
|
900
|
+
const retryAfter = anyError.headers?.["retry-after"] ? parseInt(anyError.headers["retry-after"], 10) : void 0;
|
|
901
|
+
if (status === 429) {
|
|
902
|
+
return new ProviderError(error.message, "rate_limit", status, retryAfter);
|
|
903
|
+
}
|
|
904
|
+
if (status === 401 || status === 403) {
|
|
905
|
+
return new ProviderError(error.message, "auth_error", status);
|
|
906
|
+
}
|
|
907
|
+
if (status === 400 || status === 404) {
|
|
908
|
+
return new ProviderError(error.message, "invalid_request", status);
|
|
909
|
+
}
|
|
910
|
+
if (status && status >= 500) {
|
|
911
|
+
return new ProviderError(error.message, "server_error", status);
|
|
912
|
+
}
|
|
913
|
+
if (error.name === "AbortError" || error.name === "TimeoutError" || anyError.code === "ETIMEDOUT") {
|
|
914
|
+
return new ProviderError(error.message, "timeout");
|
|
915
|
+
}
|
|
916
|
+
return new ProviderError(error.message, "unknown", status);
|
|
917
|
+
}
|
|
918
|
+
return new ProviderError(String(error), "unknown");
|
|
919
|
+
}
|
|
920
|
+
toHttpProviderError(message, status, headers) {
|
|
921
|
+
const retryAfterHeader = headers?.get("retry-after");
|
|
922
|
+
const retryAfter = retryAfterHeader ? parseInt(retryAfterHeader, 10) : void 0;
|
|
923
|
+
if (status === 429) {
|
|
924
|
+
return new ProviderError(message, "rate_limit", status, retryAfter);
|
|
925
|
+
}
|
|
926
|
+
if (status === 401 || status === 403) {
|
|
927
|
+
return new ProviderError(message, "auth_error", status);
|
|
928
|
+
}
|
|
929
|
+
if (status === 400 || status === 404) {
|
|
930
|
+
return new ProviderError(message, "invalid_request", status);
|
|
931
|
+
}
|
|
932
|
+
if (status >= 500) {
|
|
933
|
+
return new ProviderError(message, "server_error", status);
|
|
934
|
+
}
|
|
935
|
+
return new ProviderError(message, "unknown", status);
|
|
936
|
+
}
|
|
937
|
+
async inspectRequest(request) {
|
|
938
|
+
const params = buildChatParams(request);
|
|
939
|
+
return {
|
|
940
|
+
body: truncateChatBase64(params),
|
|
941
|
+
messagesPath: "messages",
|
|
942
|
+
metadata: {
|
|
943
|
+
endpoint: "POST /v1/openai/chat/completions",
|
|
944
|
+
headers: {
|
|
945
|
+
"Content-Type": "application/json"
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
};
|
|
949
|
+
}
|
|
950
|
+
};
|
|
951
|
+
|
|
952
|
+
// src/providerOptions.ts
|
|
953
|
+
import { z } from "zod";
|
|
954
|
+
var reasoningEffort = z.enum(["none", "low", "medium", "high"]);
|
|
955
|
+
var deepinfraProviderOptions = z.object({
|
|
956
|
+
n: z.number().int().min(1).optional(),
|
|
957
|
+
seed: z.number().int().optional(),
|
|
958
|
+
frequency_penalty: z.number().min(-2).max(2).optional(),
|
|
959
|
+
presence_penalty: z.number().min(-2).max(2).optional(),
|
|
960
|
+
repetition_penalty: z.number().gt(0).max(5).optional(),
|
|
961
|
+
top_k: z.number().int().positive().optional(),
|
|
962
|
+
min_p: z.number().min(0).max(1).optional(),
|
|
963
|
+
logit_bias: z.record(z.string(), z.number().min(-100).max(100)).optional(),
|
|
964
|
+
logprobs: z.boolean().optional(),
|
|
965
|
+
top_logprobs: z.number().int().min(0).max(20).optional(),
|
|
966
|
+
stop_token_ids: z.array(z.number().int().nonnegative()).optional(),
|
|
967
|
+
reasoning_effort: reasoningEffort.optional(),
|
|
968
|
+
reasoning: z.object({
|
|
969
|
+
enabled: z.boolean().optional(),
|
|
970
|
+
effort: reasoningEffort.optional()
|
|
971
|
+
}).passthrough().optional(),
|
|
972
|
+
service_tier: z.enum(["default", "priority", "flex"]).optional(),
|
|
973
|
+
prompt_cache_key: z.string().min(1).optional()
|
|
974
|
+
}).passthrough();
|
|
975
|
+
|
|
976
|
+
// src/index.ts
|
|
977
|
+
var deepinfra = Object.assign(
|
|
978
|
+
(config) => new DeepInfraProvider(config),
|
|
979
|
+
{
|
|
980
|
+
providerOptions: deepinfraProviderOptions,
|
|
981
|
+
configSlots: {
|
|
982
|
+
apiKey: {
|
|
983
|
+
type: "secret",
|
|
984
|
+
required: true,
|
|
985
|
+
defaultEnv: "DEEPINFRA_API_KEY",
|
|
986
|
+
overridable: true,
|
|
987
|
+
description: "DeepInfra API token used to authenticate inference requests."
|
|
988
|
+
},
|
|
989
|
+
baseUrl: {
|
|
990
|
+
type: "url",
|
|
991
|
+
required: false,
|
|
992
|
+
default: "https://api.deepinfra.com/v1/openai",
|
|
993
|
+
overridable: true,
|
|
994
|
+
description: "DeepInfra OpenAI-compatible API base URL."
|
|
995
|
+
},
|
|
996
|
+
modelsUrl: {
|
|
997
|
+
type: "url",
|
|
998
|
+
required: false,
|
|
999
|
+
default: "https://api.deepinfra.com/v1/models",
|
|
1000
|
+
overridable: true,
|
|
1001
|
+
description: "DeepInfra public model catalog URL."
|
|
1002
|
+
},
|
|
1003
|
+
timeout: {
|
|
1004
|
+
type: "number",
|
|
1005
|
+
required: false,
|
|
1006
|
+
default: 3e4,
|
|
1007
|
+
overridable: true,
|
|
1008
|
+
description: "Provider request timeout in milliseconds."
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
);
|
|
1013
|
+
export {
|
|
1014
|
+
DeepInfraProvider,
|
|
1015
|
+
calculateDeepInfraUsageCost,
|
|
1016
|
+
deepinfra,
|
|
1017
|
+
deepinfraProviderOptions,
|
|
1018
|
+
deepinfraUsagePricingFromModel,
|
|
1019
|
+
normalizeDeepInfraPricePerMillion
|
|
1020
|
+
};
|
|
1021
|
+
//# sourceMappingURL=index.js.map
|