@wix/evalforge-evaluator 0.161.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 +26 -9
- package/build/index.js.map +2 -2
- package/build/index.mjs +27 -9
- package/build/index.mjs.map +2 -2
- package/package.json +2 -2
package/build/index.mjs
CHANGED
|
@@ -3457,6 +3457,7 @@ defaultRegistry.register(openCodeAdapter);
|
|
|
3457
3457
|
import {
|
|
3458
3458
|
APICallError,
|
|
3459
3459
|
generateText,
|
|
3460
|
+
streamText,
|
|
3460
3461
|
stepCountIs
|
|
3461
3462
|
} from "ai";
|
|
3462
3463
|
import { createAnthropic } from "@ai-sdk/anthropic";
|
|
@@ -3794,7 +3795,7 @@ async function executeWithAiSdk(context) {
|
|
|
3794
3795
|
const timeoutHandle = setTimeout(() => {
|
|
3795
3796
|
abortController.abort(
|
|
3796
3797
|
new Error(
|
|
3797
|
-
`Simple Agent generateText timed out after ${SDK_TIMEOUT_MS}ms (model=${modelId}, scenario=${scenario.name})`
|
|
3798
|
+
`Simple Agent generateText / streamText timed out after ${SDK_TIMEOUT_MS}ms (model=${modelId}, scenario=${scenario.name})`
|
|
3798
3799
|
)
|
|
3799
3800
|
);
|
|
3800
3801
|
}, SDK_TIMEOUT_MS);
|
|
@@ -3840,7 +3841,7 @@ async function executeWithAiSdk(context) {
|
|
|
3840
3841
|
const stepTimestamps = [];
|
|
3841
3842
|
const { triggerPromptImages } = context;
|
|
3842
3843
|
const hasImages = triggerPromptImages && triggerPromptImages.length > 0;
|
|
3843
|
-
const
|
|
3844
|
+
const sdkParams = {
|
|
3844
3845
|
...topLevelExtras,
|
|
3845
3846
|
model,
|
|
3846
3847
|
abortSignal: abortController.signal,
|
|
@@ -3897,15 +3898,32 @@ async function executeWithAiSdk(context) {
|
|
|
3897
3898
|
);
|
|
3898
3899
|
}
|
|
3899
3900
|
}
|
|
3900
|
-
}
|
|
3901
|
+
};
|
|
3902
|
+
const shouldStream = !isResponsesAPI;
|
|
3903
|
+
let text;
|
|
3904
|
+
let steps;
|
|
3905
|
+
let rawUsage;
|
|
3906
|
+
if (shouldStream) {
|
|
3907
|
+
const stream = streamText(sdkParams);
|
|
3908
|
+
[text, steps, rawUsage] = await Promise.all([
|
|
3909
|
+
stream.text,
|
|
3910
|
+
stream.steps,
|
|
3911
|
+
stream.usage
|
|
3912
|
+
]);
|
|
3913
|
+
} else {
|
|
3914
|
+
const result = await generateText(sdkParams);
|
|
3915
|
+
text = result.text;
|
|
3916
|
+
steps = result.steps;
|
|
3917
|
+
rawUsage = result.usage;
|
|
3918
|
+
}
|
|
3901
3919
|
const durationMs = Date.now() - startTime;
|
|
3902
3920
|
const usage = {
|
|
3903
|
-
inputTokens:
|
|
3904
|
-
outputTokens:
|
|
3905
|
-
totalTokens:
|
|
3921
|
+
inputTokens: rawUsage.inputTokens ?? 0,
|
|
3922
|
+
outputTokens: rawUsage.outputTokens ?? 0,
|
|
3923
|
+
totalTokens: rawUsage.totalTokens ?? 0
|
|
3906
3924
|
};
|
|
3907
3925
|
const llmTrace = buildLLMTrace2(
|
|
3908
|
-
|
|
3926
|
+
steps,
|
|
3909
3927
|
durationMs,
|
|
3910
3928
|
usage,
|
|
3911
3929
|
modelId,
|
|
@@ -3918,12 +3936,12 @@ async function executeWithAiSdk(context) {
|
|
|
3918
3936
|
}
|
|
3919
3937
|
const conversation = buildConversation3(
|
|
3920
3938
|
scenario.triggerPrompt,
|
|
3921
|
-
|
|
3939
|
+
steps,
|
|
3922
3940
|
startTime,
|
|
3923
3941
|
stepTimestamps
|
|
3924
3942
|
);
|
|
3925
3943
|
return {
|
|
3926
|
-
outputText:
|
|
3944
|
+
outputText: text,
|
|
3927
3945
|
durationMs,
|
|
3928
3946
|
usage,
|
|
3929
3947
|
llmTrace,
|