smoltalk 0.11.1 → 0.12.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/model.js +2 -2
- package/dist/models.d.ts +7 -0
- package/dist/models.js +30 -1
- package/package.json +1 -1
package/dist/model.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getModel,
|
|
1
|
+
import { getModel, resolveModelForProvider, isSpeechToTextModel, isTextToSpeechModel, ModelNameSchema, } from "./models.js";
|
|
2
2
|
import { SmolError } from "./smolError.js";
|
|
3
3
|
import { round } from "./util/util.js";
|
|
4
4
|
const TOKEN_COST_UNIT = 1_000_000;
|
|
@@ -27,7 +27,7 @@ export class Model {
|
|
|
27
27
|
calculateCost(usage) {
|
|
28
28
|
let model;
|
|
29
29
|
if (this.provider !== undefined) {
|
|
30
|
-
model =
|
|
30
|
+
model = resolveModelForProvider(this.provider, this.model, this.modelData);
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
33
33
|
model = getModel(this.model, this.modelData);
|
package/dist/models.d.ts
CHANGED
|
@@ -1805,6 +1805,13 @@ export declare function getModel(modelName: ModelName, requestData?: ModelDataBl
|
|
|
1805
1805
|
* matching entry comes first and can silently pick the wrong provider.
|
|
1806
1806
|
*/
|
|
1807
1807
|
export declare function getModelForProvider(provider: string, modelName: ModelName, requestData?: ModelDataBlob): ModelType | undefined;
|
|
1808
|
+
/**
|
|
1809
|
+
* Like `getModelForProvider`, but when the exact provider key misses and the
|
|
1810
|
+
* provider is a known API variant (e.g. "openai-responses"), retries under
|
|
1811
|
+
* its catalog family ("openai"). The exact match always wins so
|
|
1812
|
+
* variant-exclusive entries (o3-pro etc.) keep their own data.
|
|
1813
|
+
*/
|
|
1814
|
+
export declare function resolveModelForProvider(provider: string, modelName: ModelName, requestData?: ModelDataBlob): ModelType | undefined;
|
|
1808
1815
|
/**
|
|
1809
1816
|
* Whether a model is known to accept the given input modality ("image", "pdf", …).
|
|
1810
1817
|
* Returns undefined when the model is unknown or carries no `modalities` data —
|
package/dist/models.js
CHANGED
|
@@ -1954,6 +1954,35 @@ export function getModel(modelName, requestData) {
|
|
|
1954
1954
|
export function getModelForProvider(provider, modelName, requestData) {
|
|
1955
1955
|
return getAllModels(requestData).find((model) => model.modelName === modelName && model.provider === provider);
|
|
1956
1956
|
}
|
|
1957
|
+
/**
|
|
1958
|
+
* API-variant provider names mapped to the catalog family whose entries they
|
|
1959
|
+
* share. "openai-responses" is the same vendor with the same pricing and
|
|
1960
|
+
* modalities as "openai" — only Responses-exclusive models are cataloged
|
|
1961
|
+
* under "openai-responses" itself. Unrelated providers (gateways like
|
|
1962
|
+
* "openrouter"/"openai-compat", custom registrations) are deliberately NOT
|
|
1963
|
+
* aliased: a same-named model under another provider must not lend its
|
|
1964
|
+
* pricing or capabilities across providers.
|
|
1965
|
+
*/
|
|
1966
|
+
const PROVIDER_FAMILY_ALIAS = {
|
|
1967
|
+
"openai-responses": "openai",
|
|
1968
|
+
};
|
|
1969
|
+
/**
|
|
1970
|
+
* Like `getModelForProvider`, but when the exact provider key misses and the
|
|
1971
|
+
* provider is a known API variant (e.g. "openai-responses"), retries under
|
|
1972
|
+
* its catalog family ("openai"). The exact match always wins so
|
|
1973
|
+
* variant-exclusive entries (o3-pro etc.) keep their own data.
|
|
1974
|
+
*/
|
|
1975
|
+
export function resolveModelForProvider(provider, modelName, requestData) {
|
|
1976
|
+
const exact = getModelForProvider(provider, modelName, requestData);
|
|
1977
|
+
if (exact) {
|
|
1978
|
+
return exact;
|
|
1979
|
+
}
|
|
1980
|
+
const family = PROVIDER_FAMILY_ALIAS[provider];
|
|
1981
|
+
if (family === undefined) {
|
|
1982
|
+
return undefined;
|
|
1983
|
+
}
|
|
1984
|
+
return getModelForProvider(family, modelName, requestData);
|
|
1985
|
+
}
|
|
1957
1986
|
/**
|
|
1958
1987
|
* Whether a model is known to accept the given input modality ("image", "pdf", …).
|
|
1959
1988
|
* Returns undefined when the model is unknown or carries no `modalities` data —
|
|
@@ -1962,7 +1991,7 @@ export function getModelForProvider(provider, modelName, requestData) {
|
|
|
1962
1991
|
export function modelSupportsInputModality(modelName, modality, requestData, provider) {
|
|
1963
1992
|
let model;
|
|
1964
1993
|
if (provider !== undefined) {
|
|
1965
|
-
model =
|
|
1994
|
+
model = resolveModelForProvider(provider, modelName, requestData);
|
|
1966
1995
|
}
|
|
1967
1996
|
else {
|
|
1968
1997
|
model = getModel(modelName, requestData);
|