Use Canonical Models to set context window sizes (#6723)
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Utilities for fetching canonical model information from the backend
|
||||
*/
|
||||
|
||||
import { getCanonicalModelInfo, type ModelInfoData } from '../api';
|
||||
|
||||
/**
|
||||
* Fetch canonical model info (pricing + context limits) for a specific provider/model
|
||||
*/
|
||||
export async function fetchCanonicalModelInfo(
|
||||
provider: string,
|
||||
model: string
|
||||
): Promise<ModelInfoData | null> {
|
||||
try {
|
||||
const response = await getCanonicalModelInfo({
|
||||
body: { provider, model },
|
||||
throwOnError: true,
|
||||
});
|
||||
|
||||
return response.data.model_info ?? null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
import { getPricing, PricingData } from '../api';
|
||||
|
||||
/**
|
||||
* Fetch pricing for a specific provider/model from the backend
|
||||
*/
|
||||
export async function fetchModelPricing(
|
||||
provider: string,
|
||||
model: string
|
||||
): Promise<PricingData | null> {
|
||||
try {
|
||||
const response = await getPricing({
|
||||
body: { provider, model },
|
||||
throwOnError: false,
|
||||
});
|
||||
|
||||
if (!response.data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return response.data.pricing?.[0] ?? null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user