@providerprotocol/ai 0.0.22 → 0.0.23
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 +188 -6
- package/dist/anthropic/index.d.ts +1 -1
- package/dist/anthropic/index.js +30 -25
- package/dist/anthropic/index.js.map +1 -1
- package/dist/{chunk-7WYBJPJJ.js → chunk-55X3W2MN.js} +4 -3
- package/dist/chunk-55X3W2MN.js.map +1 -0
- package/dist/chunk-73IIE3QT.js +120 -0
- package/dist/chunk-73IIE3QT.js.map +1 -0
- package/dist/{chunk-M4BMM5IB.js → chunk-MF5ETY5O.js} +13 -4
- package/dist/chunk-MF5ETY5O.js.map +1 -0
- package/dist/{chunk-RFWLEFAB.js → chunk-QNJO7DSD.js} +61 -16
- package/dist/chunk-QNJO7DSD.js.map +1 -0
- package/dist/{chunk-RS7C25LS.js → chunk-SBCATNHA.js} +9 -5
- package/dist/chunk-SBCATNHA.js.map +1 -0
- package/dist/{chunk-I2VHCGQE.js → chunk-Z6DKC37J.js} +6 -5
- package/dist/chunk-Z6DKC37J.js.map +1 -0
- package/dist/google/index.d.ts +3 -2
- package/dist/google/index.js +38 -33
- package/dist/google/index.js.map +1 -1
- package/dist/http/index.d.ts +2 -2
- package/dist/http/index.js +3 -3
- package/dist/index.d.ts +8 -6
- package/dist/index.js +81 -121
- package/dist/index.js.map +1 -1
- package/dist/ollama/index.d.ts +5 -2
- package/dist/ollama/index.js +34 -29
- package/dist/ollama/index.js.map +1 -1
- package/dist/openai/index.d.ts +1 -1
- package/dist/openai/index.js +58 -53
- package/dist/openai/index.js.map +1 -1
- package/dist/openrouter/index.d.ts +1 -1
- package/dist/openrouter/index.js +57 -52
- package/dist/openrouter/index.js.map +1 -1
- package/dist/{provider-DWEAzeM5.d.ts → provider-DR1yins0.d.ts} +148 -52
- package/dist/proxy/index.d.ts +2 -2
- package/dist/proxy/index.js +11 -9
- package/dist/proxy/index.js.map +1 -1
- package/dist/{retry-DmPmqZL6.d.ts → retry-DJiqAslw.d.ts} +1 -1
- package/dist/{stream-DbkLOIbJ.d.ts → stream-BuTrqt_j.d.ts} +90 -38
- package/dist/xai/index.d.ts +1 -1
- package/dist/xai/index.js +71 -66
- package/dist/xai/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-7WYBJPJJ.js.map +0 -1
- package/dist/chunk-I2VHCGQE.js.map +0 -1
- package/dist/chunk-M4BMM5IB.js.map +0 -1
- package/dist/chunk-RFWLEFAB.js.map +0 -1
- package/dist/chunk-RS7C25LS.js.map +0 -1
package/dist/xai/index.js
CHANGED
|
@@ -3,7 +3,10 @@ import {
|
|
|
3
3
|
} from "../chunk-WAKD3OO5.js";
|
|
4
4
|
import {
|
|
5
5
|
parseJsonResponse
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-Z6DKC37J.js";
|
|
7
|
+
import {
|
|
8
|
+
StreamEventType
|
|
9
|
+
} from "../chunk-73IIE3QT.js";
|
|
7
10
|
import {
|
|
8
11
|
AssistantMessage,
|
|
9
12
|
createProvider,
|
|
@@ -11,20 +14,22 @@ import {
|
|
|
11
14
|
isAssistantMessage,
|
|
12
15
|
isToolResultMessage,
|
|
13
16
|
isUserMessage
|
|
14
|
-
} from "../chunk-
|
|
17
|
+
} from "../chunk-MF5ETY5O.js";
|
|
15
18
|
import {
|
|
16
19
|
parseSSEStream
|
|
17
20
|
} from "../chunk-NWS5IKNR.js";
|
|
18
21
|
import {
|
|
19
22
|
resolveApiKey
|
|
20
|
-
} from "../chunk-
|
|
23
|
+
} from "../chunk-55X3W2MN.js";
|
|
21
24
|
import {
|
|
25
|
+
ErrorCode,
|
|
26
|
+
ModalityType,
|
|
22
27
|
UPPError,
|
|
23
28
|
doFetch,
|
|
24
29
|
doStreamFetch,
|
|
25
30
|
normalizeHttpError,
|
|
26
31
|
toError
|
|
27
|
-
} from "../chunk-
|
|
32
|
+
} from "../chunk-QNJO7DSD.js";
|
|
28
33
|
|
|
29
34
|
// src/providers/xai/transform.completions.ts
|
|
30
35
|
function transformRequest(request, modelId) {
|
|
@@ -65,9 +70,9 @@ function normalizeSystem(system) {
|
|
|
65
70
|
if (!Array.isArray(system)) {
|
|
66
71
|
throw new UPPError(
|
|
67
72
|
"System prompt must be a string or an array of text blocks",
|
|
68
|
-
|
|
73
|
+
ErrorCode.InvalidRequest,
|
|
69
74
|
"xai",
|
|
70
|
-
|
|
75
|
+
ModalityType.LLM
|
|
71
76
|
);
|
|
72
77
|
}
|
|
73
78
|
const texts = [];
|
|
@@ -75,18 +80,18 @@ function normalizeSystem(system) {
|
|
|
75
80
|
if (!block || typeof block !== "object" || !("text" in block)) {
|
|
76
81
|
throw new UPPError(
|
|
77
82
|
"System prompt array must contain objects with a text field",
|
|
78
|
-
|
|
83
|
+
ErrorCode.InvalidRequest,
|
|
79
84
|
"xai",
|
|
80
|
-
|
|
85
|
+
ModalityType.LLM
|
|
81
86
|
);
|
|
82
87
|
}
|
|
83
88
|
const textValue = block.text;
|
|
84
89
|
if (typeof textValue !== "string") {
|
|
85
90
|
throw new UPPError(
|
|
86
91
|
"System prompt text must be a string",
|
|
87
|
-
|
|
92
|
+
ErrorCode.InvalidRequest,
|
|
88
93
|
"xai",
|
|
89
|
-
|
|
94
|
+
ModalityType.LLM
|
|
90
95
|
);
|
|
91
96
|
}
|
|
92
97
|
if (textValue.length > 0) {
|
|
@@ -318,7 +323,7 @@ function transformStreamEvent(chunk, state) {
|
|
|
318
323
|
const events = [];
|
|
319
324
|
if (chunk.id && !state.id) {
|
|
320
325
|
state.id = chunk.id;
|
|
321
|
-
events.push({ type:
|
|
326
|
+
events.push({ type: StreamEventType.MessageStart, index: 0, delta: {} });
|
|
322
327
|
}
|
|
323
328
|
if (chunk.model) {
|
|
324
329
|
state.model = chunk.model;
|
|
@@ -328,7 +333,7 @@ function transformStreamEvent(chunk, state) {
|
|
|
328
333
|
if (choice.delta.content) {
|
|
329
334
|
state.text += choice.delta.content;
|
|
330
335
|
events.push({
|
|
331
|
-
type:
|
|
336
|
+
type: StreamEventType.TextDelta,
|
|
332
337
|
index: 0,
|
|
333
338
|
delta: { text: choice.delta.content }
|
|
334
339
|
});
|
|
@@ -337,7 +342,7 @@ function transformStreamEvent(chunk, state) {
|
|
|
337
342
|
state.hadRefusal = true;
|
|
338
343
|
state.text += choice.delta.refusal;
|
|
339
344
|
events.push({
|
|
340
|
-
type:
|
|
345
|
+
type: StreamEventType.TextDelta,
|
|
341
346
|
index: 0,
|
|
342
347
|
delta: { text: choice.delta.refusal }
|
|
343
348
|
});
|
|
@@ -359,7 +364,7 @@ function transformStreamEvent(chunk, state) {
|
|
|
359
364
|
if (toolCallDelta.function?.arguments) {
|
|
360
365
|
toolCall.arguments += toolCallDelta.function.arguments;
|
|
361
366
|
events.push({
|
|
362
|
-
type:
|
|
367
|
+
type: StreamEventType.ToolCallDelta,
|
|
363
368
|
index,
|
|
364
369
|
delta: {
|
|
365
370
|
toolCallId: toolCall.id,
|
|
@@ -372,7 +377,7 @@ function transformStreamEvent(chunk, state) {
|
|
|
372
377
|
}
|
|
373
378
|
if (choice.finish_reason) {
|
|
374
379
|
state.finishReason = choice.finish_reason;
|
|
375
|
-
events.push({ type:
|
|
380
|
+
events.push({ type: StreamEventType.MessageStop, index: 0, delta: {} });
|
|
376
381
|
}
|
|
377
382
|
}
|
|
378
383
|
if (chunk.usage) {
|
|
@@ -474,9 +479,9 @@ function createCompletionsLLMHandler() {
|
|
|
474
479
|
if (!providerRef) {
|
|
475
480
|
throw new UPPError(
|
|
476
481
|
"Provider reference not set. Handler must be used with createProvider() or have _setProvider called.",
|
|
477
|
-
|
|
482
|
+
ErrorCode.InvalidRequest,
|
|
478
483
|
"xai",
|
|
479
|
-
|
|
484
|
+
ModalityType.LLM
|
|
480
485
|
);
|
|
481
486
|
}
|
|
482
487
|
const model = {
|
|
@@ -572,9 +577,9 @@ function createCompletionsLLMHandler() {
|
|
|
572
577
|
if (!response.body) {
|
|
573
578
|
const error = new UPPError(
|
|
574
579
|
"No response body for streaming request",
|
|
575
|
-
|
|
580
|
+
ErrorCode.ProviderError,
|
|
576
581
|
"xai",
|
|
577
|
-
|
|
582
|
+
ModalityType.LLM
|
|
578
583
|
);
|
|
579
584
|
responseReject(error);
|
|
580
585
|
throw error;
|
|
@@ -589,9 +594,9 @@ function createCompletionsLLMHandler() {
|
|
|
589
594
|
const errorData = chunk.error;
|
|
590
595
|
const error = new UPPError(
|
|
591
596
|
errorData.message ?? "Unknown error",
|
|
592
|
-
|
|
597
|
+
ErrorCode.ProviderError,
|
|
593
598
|
"xai",
|
|
594
|
-
|
|
599
|
+
ModalityType.LLM
|
|
595
600
|
);
|
|
596
601
|
responseReject(error);
|
|
597
602
|
throw error;
|
|
@@ -667,9 +672,9 @@ function normalizeSystem2(system) {
|
|
|
667
672
|
if (!Array.isArray(system)) {
|
|
668
673
|
throw new UPPError(
|
|
669
674
|
"System prompt must be a string or an array of text blocks",
|
|
670
|
-
|
|
675
|
+
ErrorCode.InvalidRequest,
|
|
671
676
|
"xai",
|
|
672
|
-
|
|
677
|
+
ModalityType.LLM
|
|
673
678
|
);
|
|
674
679
|
}
|
|
675
680
|
const texts = [];
|
|
@@ -677,18 +682,18 @@ function normalizeSystem2(system) {
|
|
|
677
682
|
if (!block || typeof block !== "object" || !("text" in block)) {
|
|
678
683
|
throw new UPPError(
|
|
679
684
|
"System prompt array must contain objects with a text field",
|
|
680
|
-
|
|
685
|
+
ErrorCode.InvalidRequest,
|
|
681
686
|
"xai",
|
|
682
|
-
|
|
687
|
+
ModalityType.LLM
|
|
683
688
|
);
|
|
684
689
|
}
|
|
685
690
|
const textValue = block.text;
|
|
686
691
|
if (typeof textValue !== "string") {
|
|
687
692
|
throw new UPPError(
|
|
688
693
|
"System prompt text must be a string",
|
|
689
|
-
|
|
694
|
+
ErrorCode.InvalidRequest,
|
|
690
695
|
"xai",
|
|
691
|
-
|
|
696
|
+
ModalityType.LLM
|
|
692
697
|
);
|
|
693
698
|
}
|
|
694
699
|
if (textValue.length > 0) {
|
|
@@ -938,7 +943,7 @@ function transformStreamEvent2(event, state) {
|
|
|
938
943
|
case "response.created":
|
|
939
944
|
state.id = event.response.id;
|
|
940
945
|
state.model = event.response.model;
|
|
941
|
-
events.push({ type:
|
|
946
|
+
events.push({ type: StreamEventType.MessageStart, index: 0, delta: {} });
|
|
942
947
|
break;
|
|
943
948
|
case "response.in_progress":
|
|
944
949
|
state.status = "in_progress";
|
|
@@ -950,11 +955,11 @@ function transformStreamEvent2(event, state) {
|
|
|
950
955
|
state.outputTokens = event.response.usage.output_tokens;
|
|
951
956
|
state.cacheReadTokens = event.response.usage.input_tokens_details?.cached_tokens ?? 0;
|
|
952
957
|
}
|
|
953
|
-
events.push({ type:
|
|
958
|
+
events.push({ type: StreamEventType.MessageStop, index: 0, delta: {} });
|
|
954
959
|
break;
|
|
955
960
|
case "response.failed":
|
|
956
961
|
state.status = "failed";
|
|
957
|
-
events.push({ type:
|
|
962
|
+
events.push({ type: StreamEventType.MessageStop, index: 0, delta: {} });
|
|
958
963
|
break;
|
|
959
964
|
case "response.output_item.added":
|
|
960
965
|
if (event.item.type === "function_call") {
|
|
@@ -971,7 +976,7 @@ function transformStreamEvent2(event, state) {
|
|
|
971
976
|
state.toolCalls.set(event.output_index, existing);
|
|
972
977
|
}
|
|
973
978
|
events.push({
|
|
974
|
-
type:
|
|
979
|
+
type: StreamEventType.ContentBlockStart,
|
|
975
980
|
index: event.output_index,
|
|
976
981
|
delta: {}
|
|
977
982
|
});
|
|
@@ -991,7 +996,7 @@ function transformStreamEvent2(event, state) {
|
|
|
991
996
|
state.toolCalls.set(event.output_index, existing);
|
|
992
997
|
}
|
|
993
998
|
events.push({
|
|
994
|
-
type:
|
|
999
|
+
type: StreamEventType.ContentBlockStop,
|
|
995
1000
|
index: event.output_index,
|
|
996
1001
|
delta: {}
|
|
997
1002
|
});
|
|
@@ -1000,7 +1005,7 @@ function transformStreamEvent2(event, state) {
|
|
|
1000
1005
|
const currentText = state.textByIndex.get(event.output_index) ?? "";
|
|
1001
1006
|
state.textByIndex.set(event.output_index, currentText + event.delta);
|
|
1002
1007
|
events.push({
|
|
1003
|
-
type:
|
|
1008
|
+
type: StreamEventType.TextDelta,
|
|
1004
1009
|
index: event.output_index,
|
|
1005
1010
|
delta: { text: event.delta }
|
|
1006
1011
|
});
|
|
@@ -1014,7 +1019,7 @@ function transformStreamEvent2(event, state) {
|
|
|
1014
1019
|
const currentRefusal = state.textByIndex.get(event.output_index) ?? "";
|
|
1015
1020
|
state.textByIndex.set(event.output_index, currentRefusal + event.delta);
|
|
1016
1021
|
events.push({
|
|
1017
|
-
type:
|
|
1022
|
+
type: StreamEventType.TextDelta,
|
|
1018
1023
|
index: event.output_index,
|
|
1019
1024
|
delta: { text: event.delta }
|
|
1020
1025
|
});
|
|
@@ -1038,7 +1043,7 @@ function transformStreamEvent2(event, state) {
|
|
|
1038
1043
|
}
|
|
1039
1044
|
toolCall.arguments += event.delta;
|
|
1040
1045
|
events.push({
|
|
1041
|
-
type:
|
|
1046
|
+
type: StreamEventType.ToolCallDelta,
|
|
1042
1047
|
index: event.output_index,
|
|
1043
1048
|
delta: {
|
|
1044
1049
|
toolCallId: toolCall.callId ?? toolCall.itemId ?? "",
|
|
@@ -1172,9 +1177,9 @@ function createResponsesLLMHandler() {
|
|
|
1172
1177
|
if (!providerRef) {
|
|
1173
1178
|
throw new UPPError(
|
|
1174
1179
|
"Provider reference not set. Handler must be used with createProvider() or have _setProvider called.",
|
|
1175
|
-
|
|
1180
|
+
ErrorCode.InvalidRequest,
|
|
1176
1181
|
"xai",
|
|
1177
|
-
|
|
1182
|
+
ModalityType.LLM
|
|
1178
1183
|
);
|
|
1179
1184
|
}
|
|
1180
1185
|
const model = {
|
|
@@ -1219,9 +1224,9 @@ function createResponsesLLMHandler() {
|
|
|
1219
1224
|
if (data.status === "failed" && data.error) {
|
|
1220
1225
|
throw new UPPError(
|
|
1221
1226
|
data.error.message,
|
|
1222
|
-
|
|
1227
|
+
ErrorCode.ProviderError,
|
|
1223
1228
|
"xai",
|
|
1224
|
-
|
|
1229
|
+
ModalityType.LLM
|
|
1225
1230
|
);
|
|
1226
1231
|
}
|
|
1227
1232
|
return transformResponse2(data);
|
|
@@ -1277,9 +1282,9 @@ function createResponsesLLMHandler() {
|
|
|
1277
1282
|
if (!response.body) {
|
|
1278
1283
|
const error = new UPPError(
|
|
1279
1284
|
"No response body for streaming request",
|
|
1280
|
-
|
|
1285
|
+
ErrorCode.ProviderError,
|
|
1281
1286
|
"xai",
|
|
1282
|
-
|
|
1287
|
+
ModalityType.LLM
|
|
1283
1288
|
);
|
|
1284
1289
|
responseReject(error);
|
|
1285
1290
|
throw error;
|
|
@@ -1294,9 +1299,9 @@ function createResponsesLLMHandler() {
|
|
|
1294
1299
|
const errorEvent = event;
|
|
1295
1300
|
const error = new UPPError(
|
|
1296
1301
|
errorEvent.error.message,
|
|
1297
|
-
|
|
1302
|
+
ErrorCode.ProviderError,
|
|
1298
1303
|
"xai",
|
|
1299
|
-
|
|
1304
|
+
ModalityType.LLM
|
|
1300
1305
|
);
|
|
1301
1306
|
responseReject(error);
|
|
1302
1307
|
throw error;
|
|
@@ -1334,9 +1339,9 @@ function normalizeSystem3(system) {
|
|
|
1334
1339
|
if (!Array.isArray(system)) {
|
|
1335
1340
|
throw new UPPError(
|
|
1336
1341
|
"System prompt must be a string or an array of text blocks",
|
|
1337
|
-
|
|
1342
|
+
ErrorCode.InvalidRequest,
|
|
1338
1343
|
"xai",
|
|
1339
|
-
|
|
1344
|
+
ModalityType.LLM
|
|
1340
1345
|
);
|
|
1341
1346
|
}
|
|
1342
1347
|
const texts = [];
|
|
@@ -1344,18 +1349,18 @@ function normalizeSystem3(system) {
|
|
|
1344
1349
|
if (!block || typeof block !== "object" || !("text" in block)) {
|
|
1345
1350
|
throw new UPPError(
|
|
1346
1351
|
"System prompt array must contain objects with a text field",
|
|
1347
|
-
|
|
1352
|
+
ErrorCode.InvalidRequest,
|
|
1348
1353
|
"xai",
|
|
1349
|
-
|
|
1354
|
+
ModalityType.LLM
|
|
1350
1355
|
);
|
|
1351
1356
|
}
|
|
1352
1357
|
const textValue = block.text;
|
|
1353
1358
|
if (typeof textValue !== "string") {
|
|
1354
1359
|
throw new UPPError(
|
|
1355
1360
|
"System prompt text must be a string",
|
|
1356
|
-
|
|
1361
|
+
ErrorCode.InvalidRequest,
|
|
1357
1362
|
"xai",
|
|
1358
|
-
|
|
1363
|
+
ModalityType.LLM
|
|
1359
1364
|
);
|
|
1360
1365
|
}
|
|
1361
1366
|
if (textValue.length > 0) {
|
|
@@ -1561,7 +1566,7 @@ function transformStreamEvent3(event, state) {
|
|
|
1561
1566
|
state.inputTokens = event.message.usage.input_tokens;
|
|
1562
1567
|
state.cacheReadTokens = event.message.usage.cache_read_input_tokens ?? 0;
|
|
1563
1568
|
state.cacheWriteTokens = event.message.usage.cache_creation_input_tokens ?? 0;
|
|
1564
|
-
return { type:
|
|
1569
|
+
return { type: StreamEventType.MessageStart, index: 0, delta: {} };
|
|
1565
1570
|
case "content_block_start":
|
|
1566
1571
|
state.currentIndex = event.index;
|
|
1567
1572
|
if (event.content_block.type === "text") {
|
|
@@ -1574,7 +1579,7 @@ function transformStreamEvent3(event, state) {
|
|
|
1574
1579
|
input: ""
|
|
1575
1580
|
};
|
|
1576
1581
|
}
|
|
1577
|
-
return { type:
|
|
1582
|
+
return { type: StreamEventType.ContentBlockStart, index: event.index, delta: {} };
|
|
1578
1583
|
case "content_block_delta": {
|
|
1579
1584
|
const delta = event.delta;
|
|
1580
1585
|
const index = event.index ?? state.currentIndex;
|
|
@@ -1584,7 +1589,7 @@ function transformStreamEvent3(event, state) {
|
|
|
1584
1589
|
}
|
|
1585
1590
|
state.content[index].text = (state.content[index].text ?? "") + delta.text;
|
|
1586
1591
|
return {
|
|
1587
|
-
type:
|
|
1592
|
+
type: StreamEventType.TextDelta,
|
|
1588
1593
|
index,
|
|
1589
1594
|
delta: { text: delta.text }
|
|
1590
1595
|
};
|
|
@@ -1595,7 +1600,7 @@ function transformStreamEvent3(event, state) {
|
|
|
1595
1600
|
}
|
|
1596
1601
|
state.content[index].input = (state.content[index].input ?? "") + delta.partial_json;
|
|
1597
1602
|
return {
|
|
1598
|
-
type:
|
|
1603
|
+
type: StreamEventType.ToolCallDelta,
|
|
1599
1604
|
index,
|
|
1600
1605
|
delta: {
|
|
1601
1606
|
argumentsJson: delta.partial_json,
|
|
@@ -1606,7 +1611,7 @@ function transformStreamEvent3(event, state) {
|
|
|
1606
1611
|
}
|
|
1607
1612
|
if (delta.type === "thinking_delta") {
|
|
1608
1613
|
return {
|
|
1609
|
-
type:
|
|
1614
|
+
type: StreamEventType.ReasoningDelta,
|
|
1610
1615
|
index,
|
|
1611
1616
|
delta: { text: delta.thinking }
|
|
1612
1617
|
};
|
|
@@ -1614,13 +1619,13 @@ function transformStreamEvent3(event, state) {
|
|
|
1614
1619
|
return null;
|
|
1615
1620
|
}
|
|
1616
1621
|
case "content_block_stop":
|
|
1617
|
-
return { type:
|
|
1622
|
+
return { type: StreamEventType.ContentBlockStop, index: event.index ?? state.currentIndex, delta: {} };
|
|
1618
1623
|
case "message_delta":
|
|
1619
1624
|
state.stopReason = event.delta.stop_reason;
|
|
1620
1625
|
state.outputTokens = event.usage.output_tokens;
|
|
1621
1626
|
return null;
|
|
1622
1627
|
case "message_stop":
|
|
1623
|
-
return { type:
|
|
1628
|
+
return { type: StreamEventType.MessageStop, index: 0, delta: {} };
|
|
1624
1629
|
case "ping":
|
|
1625
1630
|
case "error":
|
|
1626
1631
|
return null;
|
|
@@ -1702,9 +1707,9 @@ function createMessagesLLMHandler() {
|
|
|
1702
1707
|
if (!providerRef) {
|
|
1703
1708
|
throw new UPPError(
|
|
1704
1709
|
"Provider reference not set. Handler must be used with createProvider() or have _setProvider called.",
|
|
1705
|
-
|
|
1710
|
+
ErrorCode.InvalidRequest,
|
|
1706
1711
|
"xai",
|
|
1707
|
-
|
|
1712
|
+
ModalityType.LLM
|
|
1708
1713
|
);
|
|
1709
1714
|
}
|
|
1710
1715
|
const model = {
|
|
@@ -1801,9 +1806,9 @@ function createMessagesLLMHandler() {
|
|
|
1801
1806
|
if (!response.body) {
|
|
1802
1807
|
const error = new UPPError(
|
|
1803
1808
|
"No response body for streaming request",
|
|
1804
|
-
|
|
1809
|
+
ErrorCode.ProviderError,
|
|
1805
1810
|
"xai",
|
|
1806
|
-
|
|
1811
|
+
ModalityType.LLM
|
|
1807
1812
|
);
|
|
1808
1813
|
responseReject(error);
|
|
1809
1814
|
throw error;
|
|
@@ -1814,9 +1819,9 @@ function createMessagesLLMHandler() {
|
|
|
1814
1819
|
if (event.type === "error") {
|
|
1815
1820
|
const error = new UPPError(
|
|
1816
1821
|
event.error.message,
|
|
1817
|
-
|
|
1822
|
+
ErrorCode.ProviderError,
|
|
1818
1823
|
"xai",
|
|
1819
|
-
|
|
1824
|
+
ModalityType.LLM
|
|
1820
1825
|
);
|
|
1821
1826
|
responseReject(error);
|
|
1822
1827
|
throw error;
|
|
@@ -1867,9 +1872,9 @@ function createImageHandler() {
|
|
|
1867
1872
|
if (!providerRef) {
|
|
1868
1873
|
throw new UPPError(
|
|
1869
1874
|
"Provider reference not set. Handler must be used with createProvider().",
|
|
1870
|
-
|
|
1875
|
+
ErrorCode.InvalidRequest,
|
|
1871
1876
|
"xai",
|
|
1872
|
-
|
|
1877
|
+
ModalityType.Image
|
|
1873
1878
|
);
|
|
1874
1879
|
}
|
|
1875
1880
|
const capabilities = getCapabilities(modelId);
|
|
@@ -1935,9 +1940,9 @@ function transformResponse4(data) {
|
|
|
1935
1940
|
} else {
|
|
1936
1941
|
throw new UPPError(
|
|
1937
1942
|
"No image data in response",
|
|
1938
|
-
|
|
1943
|
+
ErrorCode.ProviderError,
|
|
1939
1944
|
"xai",
|
|
1940
|
-
|
|
1945
|
+
ModalityType.Image
|
|
1941
1946
|
);
|
|
1942
1947
|
}
|
|
1943
1948
|
return {
|