@wix/evalforge-evaluator 0.160.0 → 0.162.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.js +39 -9
- package/build/index.js.map +2 -2
- package/build/index.mjs +40 -9
- package/build/index.mjs.map +2 -2
- package/package.json +2 -2
package/build/index.js
CHANGED
|
@@ -3775,7 +3775,7 @@ async function executeWithAiSdk(context) {
|
|
|
3775
3775
|
const timeoutHandle = setTimeout(() => {
|
|
3776
3776
|
abortController.abort(
|
|
3777
3777
|
new Error(
|
|
3778
|
-
`Simple Agent generateText timed out after ${SDK_TIMEOUT_MS}ms (model=${modelId}, scenario=${scenario.name})`
|
|
3778
|
+
`Simple Agent generateText / streamText timed out after ${SDK_TIMEOUT_MS}ms (model=${modelId}, scenario=${scenario.name})`
|
|
3779
3779
|
)
|
|
3780
3780
|
);
|
|
3781
3781
|
}, SDK_TIMEOUT_MS);
|
|
@@ -3821,7 +3821,7 @@ async function executeWithAiSdk(context) {
|
|
|
3821
3821
|
const stepTimestamps = [];
|
|
3822
3822
|
const { triggerPromptImages } = context;
|
|
3823
3823
|
const hasImages = triggerPromptImages && triggerPromptImages.length > 0;
|
|
3824
|
-
const
|
|
3824
|
+
const sdkParams = {
|
|
3825
3825
|
...topLevelExtras,
|
|
3826
3826
|
model,
|
|
3827
3827
|
abortSignal: abortController.signal,
|
|
@@ -3878,15 +3878,32 @@ async function executeWithAiSdk(context) {
|
|
|
3878
3878
|
);
|
|
3879
3879
|
}
|
|
3880
3880
|
}
|
|
3881
|
-
}
|
|
3881
|
+
};
|
|
3882
|
+
const shouldStream = !isResponsesAPI;
|
|
3883
|
+
let text;
|
|
3884
|
+
let steps;
|
|
3885
|
+
let rawUsage;
|
|
3886
|
+
if (shouldStream) {
|
|
3887
|
+
const stream = (0, import_ai.streamText)(sdkParams);
|
|
3888
|
+
[text, steps, rawUsage] = await Promise.all([
|
|
3889
|
+
stream.text,
|
|
3890
|
+
stream.steps,
|
|
3891
|
+
stream.usage
|
|
3892
|
+
]);
|
|
3893
|
+
} else {
|
|
3894
|
+
const result = await (0, import_ai.generateText)(sdkParams);
|
|
3895
|
+
text = result.text;
|
|
3896
|
+
steps = result.steps;
|
|
3897
|
+
rawUsage = result.usage;
|
|
3898
|
+
}
|
|
3882
3899
|
const durationMs = Date.now() - startTime;
|
|
3883
3900
|
const usage = {
|
|
3884
|
-
inputTokens:
|
|
3885
|
-
outputTokens:
|
|
3886
|
-
totalTokens:
|
|
3901
|
+
inputTokens: rawUsage.inputTokens ?? 0,
|
|
3902
|
+
outputTokens: rawUsage.outputTokens ?? 0,
|
|
3903
|
+
totalTokens: rawUsage.totalTokens ?? 0
|
|
3887
3904
|
};
|
|
3888
3905
|
const llmTrace = buildLLMTrace2(
|
|
3889
|
-
|
|
3906
|
+
steps,
|
|
3890
3907
|
durationMs,
|
|
3891
3908
|
usage,
|
|
3892
3909
|
modelId,
|
|
@@ -3899,12 +3916,12 @@ async function executeWithAiSdk(context) {
|
|
|
3899
3916
|
}
|
|
3900
3917
|
const conversation = buildConversation3(
|
|
3901
3918
|
scenario.triggerPrompt,
|
|
3902
|
-
|
|
3919
|
+
steps,
|
|
3903
3920
|
startTime,
|
|
3904
3921
|
stepTimestamps
|
|
3905
3922
|
);
|
|
3906
3923
|
return {
|
|
3907
|
-
outputText:
|
|
3924
|
+
outputText: text,
|
|
3908
3925
|
durationMs,
|
|
3909
3926
|
usage,
|
|
3910
3927
|
llmTrace,
|
|
@@ -3913,6 +3930,19 @@ async function executeWithAiSdk(context) {
|
|
|
3913
3930
|
} catch (err) {
|
|
3914
3931
|
const baseMsg = err instanceof Error ? err.message : String(err);
|
|
3915
3932
|
const ctx = extractGatewayErrorContext(err);
|
|
3933
|
+
const apiError = findApiCallError(err);
|
|
3934
|
+
console.error(
|
|
3935
|
+
"[AI gateway error]",
|
|
3936
|
+
JSON.stringify({
|
|
3937
|
+
provider,
|
|
3938
|
+
model: modelId,
|
|
3939
|
+
message: baseMsg,
|
|
3940
|
+
statusCode: apiError?.statusCode,
|
|
3941
|
+
xWixRequestId: getHeader(apiError?.responseHeaders, "x-wix-request-id"),
|
|
3942
|
+
proxyRequestId: getProxyBodyFields(apiError?.responseBody).proxy_request_id,
|
|
3943
|
+
failurePhase: getProxyBodyFields(apiError?.responseBody).failure_phase
|
|
3944
|
+
})
|
|
3945
|
+
);
|
|
3916
3946
|
throw new Error(
|
|
3917
3947
|
`AI gateway request failed (provider=${provider}, model=${modelId}): ${baseMsg}${ctx}`,
|
|
3918
3948
|
{ cause: err }
|