@purista/harness-azure-foundry 1.5.1 → 1.6.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/dist/index.js +11 -5
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -41,7 +41,7 @@ class AzureFoundryModelProvider extends BaseModelProvider {
|
|
|
41
41
|
return {
|
|
42
42
|
content: choice?.message?.content ?? '',
|
|
43
43
|
...(toolCalls ? { toolCalls } : {}),
|
|
44
|
-
usage:
|
|
44
|
+
usage: toOpenAiCompatibleUsage(body.usage),
|
|
45
45
|
finishReason: toFinishReason(choice?.finish_reason),
|
|
46
46
|
outcome: toOutcome(choice?.finish_reason),
|
|
47
47
|
raw: response
|
|
@@ -71,7 +71,7 @@ class AzureFoundryModelProvider extends BaseModelProvider {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
if (data.usage) {
|
|
74
|
-
usage =
|
|
74
|
+
usage = toOpenAiCompatibleUsage(data.usage);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
for (const call of finalizeStreamToolCalls(toolState, callContext(req, 'textStream'), MALFORMED_JSON_MESSAGE)) {
|
|
@@ -89,7 +89,7 @@ class AzureFoundryModelProvider extends BaseModelProvider {
|
|
|
89
89
|
return {
|
|
90
90
|
object: parseJson(text, req, 'object'),
|
|
91
91
|
...(toolCalls ? { toolCalls } : {}),
|
|
92
|
-
usage:
|
|
92
|
+
usage: toOpenAiCompatibleUsage(body.usage),
|
|
93
93
|
finishReason: toFinishReason(choice?.finish_reason),
|
|
94
94
|
outcome: toOutcome(choice?.finish_reason),
|
|
95
95
|
raw: response
|
|
@@ -121,7 +121,7 @@ class AzureFoundryModelProvider extends BaseModelProvider {
|
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
if (data.usage) {
|
|
124
|
-
usage =
|
|
124
|
+
usage = toOpenAiCompatibleUsage(data.usage);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
for (const call of finalizeStreamToolCalls(toolState, callContext(req, 'objectStream'), MALFORMED_JSON_MESSAGE)) {
|
|
@@ -152,7 +152,7 @@ class AzureFoundryModelProvider extends BaseModelProvider {
|
|
|
152
152
|
index: item.index,
|
|
153
153
|
vector: Array.isArray(item.embedding) ? item.embedding : []
|
|
154
154
|
})),
|
|
155
|
-
usage:
|
|
155
|
+
usage: toOpenAiCompatibleUsage(body.usage, 0),
|
|
156
156
|
raw: response
|
|
157
157
|
};
|
|
158
158
|
}
|
|
@@ -316,6 +316,12 @@ function parseStreamData(event, req, method) {
|
|
|
316
316
|
return event;
|
|
317
317
|
}
|
|
318
318
|
const MALFORMED_JSON_MESSAGE = 'Azure AI Foundry returned malformed JSON.';
|
|
319
|
+
function toOpenAiCompatibleUsage(usage, fallbackOutputTokens) {
|
|
320
|
+
return toTokenUsage(usage?.prompt_tokens, usage?.completion_tokens ?? fallbackOutputTokens, usage?.total_tokens, {
|
|
321
|
+
cachedInputTokens: usage?.prompt_tokens_details?.cached_tokens,
|
|
322
|
+
reasoningTokens: usage?.completion_tokens_details?.reasoning_tokens
|
|
323
|
+
});
|
|
324
|
+
}
|
|
319
325
|
function callContext(req, method) {
|
|
320
326
|
return { provider: 'azure-foundry', model: req.model, method };
|
|
321
327
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@purista/harness-azure-foundry",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Azure AI Foundry model provider adapter for @purista/harness.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"vitest": "^4.1.9"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@purista/harness": "^1.
|
|
53
|
+
"@purista/harness": "^1.6.0"
|
|
54
54
|
},
|
|
55
55
|
"engines": {
|
|
56
56
|
"node": ">=24.15.0"
|