modelfusion 0.45.0 → 0.45.2
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/core/getRun.cjs
CHANGED
@@ -51,10 +51,10 @@ exports.getRun = getRun;
|
|
51
51
|
async function withRun(run, callback) {
|
52
52
|
await ensureLoaded();
|
53
53
|
if (runStorage != null) {
|
54
|
-
await runStorage.run(run, callback);
|
54
|
+
await runStorage.run(run, () => callback(run));
|
55
55
|
}
|
56
56
|
else {
|
57
|
-
await callback();
|
57
|
+
await callback(run);
|
58
58
|
}
|
59
59
|
}
|
60
60
|
exports.withRun = withRun;
|
package/core/getRun.d.ts
CHANGED
@@ -6,4 +6,4 @@ export declare function getRun(run?: Run): Promise<Run | undefined>;
|
|
6
6
|
/**
|
7
7
|
* Stores the run in an AsyncLocalStorage if running in Node.js. It can be retrieved with `getRun()`.
|
8
8
|
*/
|
9
|
-
export declare function withRun(run: Run, callback: () => PromiseLike<void>): Promise<void>;
|
9
|
+
export declare function withRun(run: Run, callback: (run: Run) => PromiseLike<void>): Promise<void>;
|
package/core/getRun.js
CHANGED
@@ -24,9 +24,9 @@ export async function getRun(run) {
|
|
24
24
|
export async function withRun(run, callback) {
|
25
25
|
await ensureLoaded();
|
26
26
|
if (runStorage != null) {
|
27
|
-
await runStorage.run(run, callback);
|
27
|
+
await runStorage.run(run, () => callback(run));
|
28
28
|
}
|
29
29
|
else {
|
30
|
-
await callback();
|
30
|
+
await callback(run);
|
31
31
|
}
|
32
32
|
}
|
@@ -29,9 +29,12 @@ class OpenAICostCalculator {
|
|
29
29
|
return null;
|
30
30
|
}
|
31
31
|
if ((0, OpenAITextEmbeddingModel_js_1.isOpenAIEmbeddingModel)(model)) {
|
32
|
+
const responses = Array.isArray(call.result.response)
|
33
|
+
? call.result.response
|
34
|
+
: [call.result.response];
|
32
35
|
return (0, OpenAITextEmbeddingModel_js_1.calculateOpenAIEmbeddingCostInMillicents)({
|
33
36
|
model,
|
34
|
-
responses
|
37
|
+
responses,
|
35
38
|
});
|
36
39
|
}
|
37
40
|
break;
|
@@ -26,9 +26,12 @@ export class OpenAICostCalculator {
|
|
26
26
|
return null;
|
27
27
|
}
|
28
28
|
if (isOpenAIEmbeddingModel(model)) {
|
29
|
+
const responses = Array.isArray(call.result.response)
|
30
|
+
? call.result.response
|
31
|
+
: [call.result.response];
|
29
32
|
return calculateOpenAIEmbeddingCostInMillicents({
|
30
33
|
model,
|
31
|
-
responses
|
34
|
+
responses,
|
32
35
|
});
|
33
36
|
}
|
34
37
|
break;
|
package/package.json
CHANGED