mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
refactor(open-sse): P3§7 model defaults schema — centralize type/quotaFamily/strip/targetFormat
- Add providers/models/schema.js (MODEL_DEFAULTS + field resolvers) - Accessors getModelTargetFormat/QuotaFamily/Strip use shared default resolvers - getModelType keeps null contract unchanged; behavior verified equal - No catalog forced into registry (models stay self-contained per docs decision) Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { PROVIDERS } from "./providers.js";
|
||||
// PROVIDER_MODELS now built from providers/registry (transport + models co-located)
|
||||
import { PROVIDER_MODELS } from "../providers/index.js";
|
||||
import { modelQuotaFamily, modelStrip, modelTargetFormat } from "../providers/models/schema.js";
|
||||
|
||||
export { PROVIDER_MODELS };
|
||||
|
||||
@@ -34,8 +35,7 @@ export function findModelName(aliasOrId, modelId) {
|
||||
export function getModelTargetFormat(aliasOrId, modelId) {
|
||||
const models = PROVIDER_MODELS[aliasOrId];
|
||||
if (!models) return null;
|
||||
const found = models.find(m => m.id === modelId);
|
||||
return found?.targetFormat || null;
|
||||
return modelTargetFormat(models.find(m => m.id === modelId));
|
||||
}
|
||||
|
||||
export function getModelType(aliasOrId, modelId) {
|
||||
@@ -57,8 +57,7 @@ export function getModelUpstreamId(aliasOrId, modelId) {
|
||||
|
||||
export function getModelQuotaFamily(aliasOrId, modelId) {
|
||||
const models = PROVIDER_MODELS[aliasOrId];
|
||||
const found = models?.find(m => m.id === modelId);
|
||||
return found?.quotaFamily || "normal";
|
||||
return modelQuotaFamily(models?.find(m => m.id === modelId));
|
||||
}
|
||||
|
||||
// OAuth providers that use short aliases (everything else: alias = id)
|
||||
@@ -96,6 +95,5 @@ export function getModelsByProviderId(providerId) {
|
||||
// Get strip list for a model entry (explicit opt-in only)
|
||||
// Returns array of content types to strip, e.g. ["image", "audio"]
|
||||
export function getModelStrip(alias, modelId) {
|
||||
const entry = PROVIDER_MODELS[alias]?.find(m => m.id === modelId);
|
||||
return entry?.strip || [];
|
||||
return modelStrip(PROVIDER_MODELS[alias]?.find(m => m.id === modelId));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user