Initial commit
This commit is contained in:
34
src/shared/constants/models.js
Normal file
34
src/shared/constants/models.js
Normal file
@@ -0,0 +1,34 @@
|
||||
// Re-export from open-sse (single source of truth)
|
||||
export {
|
||||
PROVIDER_MODELS,
|
||||
getProviderModels,
|
||||
getDefaultModel,
|
||||
isValidModel as isValidModelCore,
|
||||
findModelName,
|
||||
getModelTargetFormat,
|
||||
PROVIDER_ID_TO_ALIAS,
|
||||
getModelsByProviderId
|
||||
} from "open-sse";
|
||||
|
||||
import { AI_PROVIDERS } from "./providers.js";
|
||||
import { PROVIDER_MODELS as MODELS } from "open-sse";
|
||||
|
||||
// Providers that accept any model (passthrough)
|
||||
const PASSTHROUGH_PROVIDERS = new Set(
|
||||
Object.entries(AI_PROVIDERS)
|
||||
.filter(([, p]) => p.passthroughModels)
|
||||
.map(([key]) => key)
|
||||
);
|
||||
|
||||
// Wrap isValidModel with passthrough providers
|
||||
export function isValidModel(aliasOrId, modelId) {
|
||||
if (PASSTHROUGH_PROVIDERS.has(aliasOrId)) return true;
|
||||
const models = MODELS[aliasOrId];
|
||||
if (!models) return false;
|
||||
return models.some(m => m.id === modelId);
|
||||
}
|
||||
|
||||
// Legacy AI_MODELS for backward compatibility
|
||||
export const AI_MODELS = Object.entries(MODELS).flatMap(([alias, models]) =>
|
||||
models.map(m => ({ provider: alias, model: m.id, name: m.name }))
|
||||
);
|
||||
Reference in New Issue
Block a user