@sixb/azure-ai-foundry 0.1.4 → 0.1.5
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 +3 -2
- package/dist/accounting.d.ts +7 -3
- package/dist/accounting.d.ts.map +1 -1
- package/dist/catalog.d.ts +3 -3
- package/dist/catalog.d.ts.map +1 -1
- package/dist/chat-accounting.d.ts +3 -2
- package/dist/chat-accounting.d.ts.map +1 -1
- package/dist/embedding.d.ts +2 -2
- package/dist/embedding.d.ts.map +1 -1
- package/dist/index.js +13 -3
- package/dist/index.js.map +9 -9
- package/dist/messages-accounting.d.ts +3 -2
- package/dist/messages-accounting.d.ts.map +1 -1
- package/dist/provider.d.ts +7 -7
- package/dist/provider.d.ts.map +1 -1
- package/dist/resolution.d.ts +1 -1
- package/dist/resolution.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/accounting.ts +9 -5
- package/src/catalog.ts +7 -9
- package/src/chat-accounting.ts +5 -9
- package/src/embedding.ts +2 -2
- package/src/messages-accounting.ts +4 -9
- package/src/provider.ts +16 -9
- package/src/resolution.ts +4 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { JsonObject,
|
|
1
|
+
import type { JsonObject, ModelRateCard, ModelUsage } from "@sixb/core/models";
|
|
2
|
+
import { type PricedEstimator } from "./accounting";
|
|
2
3
|
/** Native Messages counters are additive; absent cache/thinking counters stay unknown. */
|
|
3
4
|
export declare function foundryMessagesUsage(raw: JsonObject): ModelUsage;
|
|
4
|
-
export declare function foundryMessagesEstimator(card:
|
|
5
|
+
export declare function foundryMessagesEstimator(card: ModelRateCard | undefined, request: JsonObject | undefined, modelName?: string, modelVersion?: string, aliases?: readonly string[]): PricedEstimator;
|
|
5
6
|
//# sourceMappingURL=messages-accounting.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages-accounting.d.ts","sourceRoot":"","sources":["../src/messages-accounting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"messages-accounting.d.ts","sourceRoot":"","sources":["../src/messages-accounting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAsB,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAClG,OAAO,EAAE,KAAK,eAAe,EAAkB,MAAM,cAAc,CAAA;AAGnE,0FAA0F;AAC1F,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU,CA6BhE;AAED,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,aAAa,GAAG,SAAS,EAC/B,OAAO,EAAE,UAAU,GAAG,SAAS,EAC/B,SAAS,CAAC,EAAE,MAAM,EAClB,YAAY,CAAC,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,GAC1B,eAAe,CAoBjB"}
|
package/dist/provider.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type LanguageModel, type LanguageModelDefinition, type
|
|
1
|
+
import { type LanguageModel, type LanguageModelDefinition, type LanguageModelLabel, type LanguageModelProvider, type ModelCostEstimator, type ModelRateCard, type ModelReasoningLevel } from "@sixb/core/models";
|
|
2
2
|
import { type AzureAIFoundryCatalogOptions } from "./catalog";
|
|
3
3
|
import { type ChatRequestOptions } from "./chat-request";
|
|
4
4
|
import { type AzureAIFoundryCatalog, type AzureAIFoundryDeployment, type AzureAIFoundryDiscoveryOptions } from "./discovery";
|
|
@@ -30,25 +30,25 @@ export interface AzureAIFoundryModelMetadata {
|
|
|
30
30
|
readonly deployment?: AzureAIFoundryDeployment;
|
|
31
31
|
readonly discoveredAt?: string;
|
|
32
32
|
}
|
|
33
|
-
export interface AzureAIFoundryModelOptions extends RequestOptions {
|
|
33
|
+
export interface AzureAIFoundryModelOptions extends RequestOptions, LanguageModelLabel {
|
|
34
34
|
/** Reasoning Sixb applies when this model runs without an explicit choice. */
|
|
35
35
|
readonly reasoning?: ModelReasoningLevel;
|
|
36
36
|
readonly definition?: Omit<LanguageModelDefinition, "kind" | "providerId" | "modelId">;
|
|
37
|
-
readonly rateCard?:
|
|
37
|
+
readonly rateCard?: ModelRateCard;
|
|
38
38
|
readonly costEstimator?: ModelCostEstimator;
|
|
39
39
|
/** Default: preserve positive reports; trust zero only for OpenAI. "unknown" omits all reasoning counts. */
|
|
40
40
|
readonly reasoningUsage?: "reported" | "unknown";
|
|
41
41
|
}
|
|
42
|
-
export interface AzureAIFoundryMessagesOptions extends MessagesRequestOptions {
|
|
42
|
+
export interface AzureAIFoundryMessagesOptions extends MessagesRequestOptions, LanguageModelLabel {
|
|
43
43
|
readonly reasoning?: ModelReasoningLevel;
|
|
44
44
|
readonly definition?: AzureAIFoundryModelOptions["definition"];
|
|
45
|
-
readonly rateCard?:
|
|
45
|
+
readonly rateCard?: ModelRateCard;
|
|
46
46
|
readonly costEstimator?: ModelCostEstimator;
|
|
47
47
|
}
|
|
48
|
-
export interface AzureAIFoundryChatOptions extends ChatRequestOptions {
|
|
48
|
+
export interface AzureAIFoundryChatOptions extends ChatRequestOptions, LanguageModelLabel {
|
|
49
49
|
readonly reasoning?: ModelReasoningLevel;
|
|
50
50
|
readonly definition?: AzureAIFoundryModelOptions["definition"];
|
|
51
|
-
readonly rateCard?:
|
|
51
|
+
readonly rateCard?: ModelRateCard;
|
|
52
52
|
readonly costEstimator?: ModelCostEstimator;
|
|
53
53
|
readonly reasoningUsage?: "reported" | "unknown";
|
|
54
54
|
}
|
package/dist/provider.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,uBAAuB,EAC5B,KAAK,
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,uBAA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
|
deployment?: AzureAIFoundryDeployment;
|
|
31
31
|
discoveredAt?: string;
|
|
32
32
|
}>;
|
|
33
|
-
rateCard: import("@sixb/core/models").
|
|
33
|
+
rateCard: import("@sixb/core/models").ModelRateCard | undefined;
|
|
34
34
|
aliases: readonly string[];
|
|
35
35
|
};
|
|
36
36
|
//# sourceMappingURL=resolution.d.ts.map
|
package/dist/resolution.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolution.d.ts","sourceRoot":"","sources":["../src/resolution.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"resolution.d.ts","sourceRoot":"","sources":["../src/resolution.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,uBAAuB,EAE7B,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACxD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAC3D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAChE,OAAO,KAAK,EAA+B,0BAA0B,EAAE,MAAM,YAAY,CAAA;AAEzF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAIlD,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,eAAe,CAAA;IAC1B,OAAO,EAAE,0BAA0B,GAAG,kBAAkB,GAAG,sBAAsB,CAAA;IACjF,UAAU,CAAC,EAAE,wBAAwB,CAAA;IACrC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,YAAY,CAAA;CAC5B;;;;;;;;;;;;;;;;;;;EAmGA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sixb/azure-ai-foundry",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Azure AI Foundry model provider for Sixb",
|
|
5
5
|
"homepage": "https://sixb.ai",
|
|
6
6
|
"bugs": {
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"prepack": "bun run build"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@sixb/core": "^0.1.
|
|
35
|
-
"@sixb/model-protocols": "0.1.
|
|
34
|
+
"@sixb/core": "^0.1.22",
|
|
35
|
+
"@sixb/model-protocols": "0.1.2"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/bun": "latest",
|
package/src/accounting.ts
CHANGED
|
@@ -2,8 +2,8 @@ import {
|
|
|
2
2
|
defineModelRateCard,
|
|
3
3
|
estimateModelReservation,
|
|
4
4
|
type JsonObject,
|
|
5
|
-
type LanguageModelRateCard,
|
|
6
5
|
type ModelCostEstimator,
|
|
6
|
+
type ModelRateCard,
|
|
7
7
|
type ModelUsage,
|
|
8
8
|
rateModelCall,
|
|
9
9
|
} from "@sixb/core/models"
|
|
@@ -43,13 +43,16 @@ export function foundryUsage(
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
/** An estimator, with the card it prices by when it prices this configuration at all. */
|
|
47
|
+
export type PricedEstimator = ModelCostEstimator & { readonly rateCard?: ModelRateCard }
|
|
48
|
+
|
|
46
49
|
export function foundryEstimator(
|
|
47
|
-
card:
|
|
50
|
+
card: ModelRateCard | undefined,
|
|
48
51
|
request: JsonObject | undefined,
|
|
49
52
|
modelName?: string,
|
|
50
53
|
modelVersion?: string,
|
|
51
54
|
aliases?: readonly string[]
|
|
52
|
-
):
|
|
55
|
+
): PricedEstimator {
|
|
53
56
|
return tokenEstimator(
|
|
54
57
|
card,
|
|
55
58
|
request,
|
|
@@ -62,17 +65,18 @@ export function foundryEstimator(
|
|
|
62
65
|
}
|
|
63
66
|
|
|
64
67
|
export function tokenEstimator(
|
|
65
|
-
card:
|
|
68
|
+
card: ModelRateCard | undefined,
|
|
66
69
|
request: JsonObject | undefined,
|
|
67
70
|
requestKeys: readonly string[],
|
|
68
71
|
tokenMeters: (raw: JsonObject | undefined) => boolean,
|
|
69
72
|
modelName?: string,
|
|
70
73
|
modelVersion?: string,
|
|
71
74
|
aliases?: readonly string[]
|
|
72
|
-
):
|
|
75
|
+
): PricedEstimator {
|
|
73
76
|
const rateCard = card && defineModelRateCard(card)
|
|
74
77
|
const fixed = Object.keys(request ?? {}).every((key) => requestKeys.includes(key))
|
|
75
78
|
return {
|
|
79
|
+
...(fixed && rateCard ? { rateCard } : {}),
|
|
76
80
|
estimateReservation: (tokens) =>
|
|
77
81
|
fixed ? estimateModelReservation({ ...tokens, rateCard }) : undefined,
|
|
78
82
|
estimate: ({ usage, responseModelId, route }) => {
|
package/src/catalog.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defineLanguageModel,
|
|
3
3
|
defineModelRateCard,
|
|
4
|
-
type LanguageModelRateCard,
|
|
5
4
|
MODEL_REASONING_EFFORTS,
|
|
6
5
|
ModelCatalogUnavailableError,
|
|
6
|
+
type ModelRateCard,
|
|
7
7
|
type ModelReasoningCapabilities,
|
|
8
8
|
} from "@sixb/core/models"
|
|
9
9
|
import { fireworksPublisher } from "./publisher"
|
|
@@ -23,14 +23,14 @@ export interface CatalogModel {
|
|
|
23
23
|
readonly modelName: string
|
|
24
24
|
readonly protocol?: FoundryProtocol
|
|
25
25
|
readonly definition: ReturnType<typeof defineLanguageModel>
|
|
26
|
-
readonly rateCard?:
|
|
26
|
+
readonly rateCard?: ModelRateCard
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export interface CatalogEmbeddingModel {
|
|
30
30
|
readonly kind: "embedding"
|
|
31
31
|
readonly catalogProvider: "azure" | "fireworks-ai"
|
|
32
32
|
readonly modelName: string
|
|
33
|
-
readonly rateCard?:
|
|
33
|
+
readonly rateCard?: ModelRateCard
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
type CatalogEntry = CatalogModel | CatalogEmbeddingModel
|
|
@@ -262,7 +262,7 @@ function reasoning(
|
|
|
262
262
|
function rates(
|
|
263
263
|
raw: Record<string, unknown> | undefined,
|
|
264
264
|
protocol: FoundryProtocol | undefined
|
|
265
|
-
):
|
|
265
|
+
): ModelRateCard | undefined {
|
|
266
266
|
const card = parseRates(raw)
|
|
267
267
|
if (protocol !== "messages" || card?.cacheWriteInput === undefined) return card
|
|
268
268
|
// models.dev's Messages cache_write is five-minute creation, including in context tiers.
|
|
@@ -271,12 +271,12 @@ function rates(
|
|
|
271
271
|
return defineModelRateCard({ ...rest, cacheWriteInput5m: cacheWriteInput })
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
-
function parseRates(raw: Record<string, unknown> | undefined):
|
|
274
|
+
function parseRates(raw: Record<string, unknown> | undefined): ModelRateCard | undefined {
|
|
275
275
|
if (!raw || raw.tiers === undefined) return flatRates(raw)
|
|
276
276
|
const { tiers, context_over_200k: legacy, ...base } = raw
|
|
277
277
|
const card = flatRates(base)
|
|
278
278
|
if (!card || !Array.isArray(tiers)) return undefined
|
|
279
|
-
const parsed: { size: number; card:
|
|
279
|
+
const parsed: { size: number; card: ModelRateCard }[] = []
|
|
280
280
|
for (const value of tiers) {
|
|
281
281
|
const entry = object(value)
|
|
282
282
|
if (!entry) return undefined
|
|
@@ -328,7 +328,6 @@ function parseRates(raw: Record<string, unknown> | undefined): LanguageModelRate
|
|
|
328
328
|
}
|
|
329
329
|
return defineModelRateCard({
|
|
330
330
|
currency: "USD",
|
|
331
|
-
unit: "million-tokens",
|
|
332
331
|
input: price("input")!,
|
|
333
332
|
output: price("output")!,
|
|
334
333
|
...(card.cacheReadInput === undefined ? {} : { cacheReadInput: price("cacheReadInput")! }),
|
|
@@ -336,7 +335,7 @@ function parseRates(raw: Record<string, unknown> | undefined): LanguageModelRate
|
|
|
336
335
|
})
|
|
337
336
|
}
|
|
338
337
|
|
|
339
|
-
function flatRates(raw: Record<string, unknown> | undefined):
|
|
338
|
+
function flatRates(raw: Record<string, unknown> | undefined): ModelRateCard | undefined {
|
|
340
339
|
if (!raw) return undefined
|
|
341
340
|
// These are reference prices per million tokens. Unrepresented tiers/dimensions must not
|
|
342
341
|
// silently become flat prices; callers can supply an estimator for those billing contracts.
|
|
@@ -358,7 +357,6 @@ function flatRates(raw: Record<string, unknown> | undefined): LanguageModelRateC
|
|
|
358
357
|
return undefined
|
|
359
358
|
return defineModelRateCard({
|
|
360
359
|
currency: "USD",
|
|
361
|
-
unit: "million-tokens",
|
|
362
360
|
input,
|
|
363
361
|
output,
|
|
364
362
|
...(read === undefined ? {} : { cacheReadInput: read }),
|
package/src/chat-accounting.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
LanguageModelRateCard,
|
|
4
|
-
ModelCostEstimator,
|
|
5
|
-
ModelUsage,
|
|
6
|
-
} from "@sixb/core/models"
|
|
7
|
-
import { tokenEstimator } from "./accounting"
|
|
1
|
+
import type { JsonObject, ModelCostEstimator, ModelRateCard, ModelUsage } from "@sixb/core/models"
|
|
2
|
+
import { type PricedEstimator, tokenEstimator } from "./accounting"
|
|
8
3
|
import { counter, object } from "./util"
|
|
9
4
|
|
|
10
5
|
// Interpret Chat counters directly. Cache reads overlap prompt_tokens; reasoning overlaps
|
|
@@ -43,12 +38,12 @@ export function foundryChatUsage(
|
|
|
43
38
|
}
|
|
44
39
|
|
|
45
40
|
export function foundryChatEstimator(
|
|
46
|
-
card:
|
|
41
|
+
card: ModelRateCard | undefined,
|
|
47
42
|
request: JsonObject | undefined,
|
|
48
43
|
modelName?: string,
|
|
49
44
|
modelVersion?: string,
|
|
50
45
|
aliases?: readonly string[]
|
|
51
|
-
):
|
|
46
|
+
): PricedEstimator {
|
|
52
47
|
const estimator = tokenEstimator(
|
|
53
48
|
card,
|
|
54
49
|
request,
|
|
@@ -59,6 +54,7 @@ export function foundryChatEstimator(
|
|
|
59
54
|
aliases
|
|
60
55
|
)
|
|
61
56
|
return {
|
|
57
|
+
...(estimator.rateCard ? { rateCard: estimator.rateCard } : {}),
|
|
62
58
|
estimateReservation: estimator.estimateReservation,
|
|
63
59
|
estimate: (input) =>
|
|
64
60
|
estimator.estimate({
|
package/src/embedding.ts
CHANGED
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
type EmbeddingModelResponseMetadata,
|
|
8
8
|
type EmbeddingModelResult,
|
|
9
9
|
type JsonObject,
|
|
10
|
-
type LanguageModelRateCard,
|
|
11
10
|
ModelCatalogUnavailableError,
|
|
12
11
|
type ModelCostEstimator,
|
|
12
|
+
type ModelRateCard,
|
|
13
13
|
type ModelUsage,
|
|
14
14
|
UnsupportedModelFeatureError,
|
|
15
15
|
} from "@sixb/core/models"
|
|
@@ -30,7 +30,7 @@ export interface AzureAIFoundryEmbeddingOptions {
|
|
|
30
30
|
readonly model: { readonly name: string; readonly version: string }
|
|
31
31
|
/** Expected output size; sent to text-embedding-3 models, validated locally for ada-002. */
|
|
32
32
|
readonly dimensions: number
|
|
33
|
-
readonly rateCard?:
|
|
33
|
+
readonly rateCard?: ModelRateCard
|
|
34
34
|
readonly costEstimator?: ModelCostEstimator
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
LanguageModelRateCard,
|
|
4
|
-
ModelCostEstimator,
|
|
5
|
-
ModelUsage,
|
|
6
|
-
} from "@sixb/core/models"
|
|
7
|
-
import { tokenEstimator } from "./accounting"
|
|
1
|
+
import type { JsonObject, ModelCostEstimator, ModelRateCard, ModelUsage } from "@sixb/core/models"
|
|
2
|
+
import { type PricedEstimator, tokenEstimator } from "./accounting"
|
|
8
3
|
import { counter, object } from "./util"
|
|
9
4
|
|
|
10
5
|
/** Native Messages counters are additive; absent cache/thinking counters stay unknown. */
|
|
@@ -40,12 +35,12 @@ export function foundryMessagesUsage(raw: JsonObject): ModelUsage {
|
|
|
40
35
|
}
|
|
41
36
|
|
|
42
37
|
export function foundryMessagesEstimator(
|
|
43
|
-
card:
|
|
38
|
+
card: ModelRateCard | undefined,
|
|
44
39
|
request: JsonObject | undefined,
|
|
45
40
|
modelName?: string,
|
|
46
41
|
modelVersion?: string,
|
|
47
42
|
aliases?: readonly string[]
|
|
48
|
-
):
|
|
43
|
+
): PricedEstimator {
|
|
49
44
|
const estimator = tokenEstimator(
|
|
50
45
|
card,
|
|
51
46
|
request,
|
package/src/provider.ts
CHANGED
|
@@ -3,8 +3,8 @@ import {
|
|
|
3
3
|
type JsonObject,
|
|
4
4
|
type LanguageModel,
|
|
5
5
|
type LanguageModelDefinition,
|
|
6
|
+
type LanguageModelLabel,
|
|
6
7
|
type LanguageModelProvider,
|
|
7
|
-
type LanguageModelRateCard,
|
|
8
8
|
type LanguageModelRequest,
|
|
9
9
|
type LanguageModelStream,
|
|
10
10
|
type LanguageModelStreamEvent,
|
|
@@ -12,13 +12,14 @@ import {
|
|
|
12
12
|
ModelCatalogUnavailableError,
|
|
13
13
|
type ModelCostEstimator,
|
|
14
14
|
ModelProviderError,
|
|
15
|
+
type ModelRateCard,
|
|
15
16
|
type ModelReasoningLevel,
|
|
16
17
|
UnsupportedModelFeatureError,
|
|
17
18
|
} from "@sixb/core/models"
|
|
18
19
|
import { chatEvents } from "@sixb/model-protocols/chat"
|
|
19
20
|
import { messagesEvents } from "@sixb/model-protocols/messages"
|
|
20
21
|
import { responsesEvents } from "@sixb/model-protocols/responses"
|
|
21
|
-
import { foundryEstimator, foundryUsage } from "./accounting"
|
|
22
|
+
import { foundryEstimator, foundryUsage, type PricedEstimator } from "./accounting"
|
|
22
23
|
import {
|
|
23
24
|
type AzureAIFoundryCatalogOptions,
|
|
24
25
|
type CatalogModel,
|
|
@@ -82,27 +83,27 @@ export interface AzureAIFoundryModelMetadata {
|
|
|
82
83
|
readonly discoveredAt?: string
|
|
83
84
|
}
|
|
84
85
|
|
|
85
|
-
export interface AzureAIFoundryModelOptions extends RequestOptions {
|
|
86
|
+
export interface AzureAIFoundryModelOptions extends RequestOptions, LanguageModelLabel {
|
|
86
87
|
/** Reasoning Sixb applies when this model runs without an explicit choice. */
|
|
87
88
|
readonly reasoning?: ModelReasoningLevel
|
|
88
89
|
readonly definition?: Omit<LanguageModelDefinition, "kind" | "providerId" | "modelId">
|
|
89
|
-
readonly rateCard?:
|
|
90
|
+
readonly rateCard?: ModelRateCard
|
|
90
91
|
readonly costEstimator?: ModelCostEstimator
|
|
91
92
|
/** Default: preserve positive reports; trust zero only for OpenAI. "unknown" omits all reasoning counts. */
|
|
92
93
|
readonly reasoningUsage?: "reported" | "unknown"
|
|
93
94
|
}
|
|
94
95
|
|
|
95
|
-
export interface AzureAIFoundryMessagesOptions extends MessagesRequestOptions {
|
|
96
|
+
export interface AzureAIFoundryMessagesOptions extends MessagesRequestOptions, LanguageModelLabel {
|
|
96
97
|
readonly reasoning?: ModelReasoningLevel
|
|
97
98
|
readonly definition?: AzureAIFoundryModelOptions["definition"]
|
|
98
|
-
readonly rateCard?:
|
|
99
|
+
readonly rateCard?: ModelRateCard
|
|
99
100
|
readonly costEstimator?: ModelCostEstimator
|
|
100
101
|
}
|
|
101
102
|
|
|
102
|
-
export interface AzureAIFoundryChatOptions extends ChatRequestOptions {
|
|
103
|
+
export interface AzureAIFoundryChatOptions extends ChatRequestOptions, LanguageModelLabel {
|
|
103
104
|
readonly reasoning?: ModelReasoningLevel
|
|
104
105
|
readonly definition?: AzureAIFoundryModelOptions["definition"]
|
|
105
|
-
readonly rateCard?:
|
|
106
|
+
readonly rateCard?: ModelRateCard
|
|
106
107
|
readonly costEstimator?: ModelCostEstimator
|
|
107
108
|
readonly reasoningUsage?: "reported" | "unknown"
|
|
108
109
|
}
|
|
@@ -230,7 +231,7 @@ export function createAzureAIFoundry(options: AzureAIFoundryOptions): AzureAIFou
|
|
|
230
231
|
|
|
231
232
|
class FoundryModel<Protocol extends FoundryProtocol> implements AzureAIFoundryModel<Protocol> {
|
|
232
233
|
private readonly profile: ReturnType<typeof resolveModel>
|
|
233
|
-
private readonly estimator:
|
|
234
|
+
private readonly estimator: PricedEstimator
|
|
234
235
|
#execution?: FoundryModel<Protocol>
|
|
235
236
|
#pendingExecution?: Promise<FoundryModel<Protocol>>
|
|
236
237
|
get protocol(): Protocol {
|
|
@@ -245,10 +246,15 @@ class FoundryModel<Protocol extends FoundryProtocol> implements AzureAIFoundryMo
|
|
|
245
246
|
get costEstimator() {
|
|
246
247
|
return this.#execution?.estimator ?? this.estimator
|
|
247
248
|
}
|
|
249
|
+
/** The card the estimator prices by; none with a custom costEstimator or unpriced options. */
|
|
250
|
+
get rateCard() {
|
|
251
|
+
return (this.#execution?.estimator ?? this.estimator).rateCard
|
|
252
|
+
}
|
|
248
253
|
private readonly options: AzureAIFoundryModelOptions & MessagesRequestOptions & ChatRequestOptions
|
|
249
254
|
private readonly scope: string
|
|
250
255
|
private readonly reliableReasoning: boolean | undefined
|
|
251
256
|
readonly defaultReasoning?: ModelReasoningLevel
|
|
257
|
+
readonly maxOutputTokens?: number
|
|
252
258
|
|
|
253
259
|
constructor(
|
|
254
260
|
private readonly requestedProtocol: Protocol | undefined,
|
|
@@ -287,6 +293,7 @@ class FoundryModel<Protocol extends FoundryProtocol> implements AzureAIFoundryMo
|
|
|
287
293
|
if (protocol === "messages") validateMessagesOptions(options)
|
|
288
294
|
else if (protocol === "chat") validateChatOptions(options)
|
|
289
295
|
else validateOptions(options)
|
|
296
|
+
if (options.maxOutputTokens !== undefined) this.maxOutputTokens = options.maxOutputTokens
|
|
290
297
|
const { costEstimator, ...serializable } = options
|
|
291
298
|
this.options = {
|
|
292
299
|
...structuredClone(serializable),
|
package/src/resolution.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defineLanguageModel,
|
|
3
|
+
defineLanguageModelLabel,
|
|
3
4
|
defineModelRateCard,
|
|
4
5
|
type LanguageModelDefinition,
|
|
5
6
|
UnsupportedModelFeatureError,
|
|
@@ -67,6 +68,7 @@ export function resolveModel(input: {
|
|
|
67
68
|
publisher,
|
|
68
69
|
via: "Azure AI Foundry",
|
|
69
70
|
...options.definition,
|
|
71
|
+
...defineLanguageModelLabel(options, PREFIX),
|
|
70
72
|
kind: "language",
|
|
71
73
|
providerId: input.providerId,
|
|
72
74
|
modelId: input.modelId,
|
|
@@ -85,6 +87,8 @@ export function resolveModel(input: {
|
|
|
85
87
|
kind: "language",
|
|
86
88
|
providerId: input.providerId,
|
|
87
89
|
modelId: input.modelId,
|
|
90
|
+
name: definition.name,
|
|
91
|
+
description: definition.description,
|
|
88
92
|
publisher: definition.publisher,
|
|
89
93
|
via: definition.via,
|
|
90
94
|
capabilities: {},
|