feat(models): freeze provider request contracts and observe actual headers
This commit is contained in:
@@ -29,10 +29,11 @@ export function modelSnapshot(config) {
|
||||
...modelIdentitySettings(config),
|
||||
...(config.protocol ? { protocol: config.protocol, streaming: config.streaming === true } : {}),
|
||||
...(config.protocol === 'anthropic-messages' ? { messagesAuth: config.messagesAuth ?? 'api-key' } : {}),
|
||||
...(config.requestContract ? { requestContract: structuredClone(config.requestContract) } : {}),
|
||||
...(config.nativeParameters ? { nativeParameters: structuredClone(config.nativeParameters), outputTokenField: config.outputTokenField } : {}),
|
||||
...(config.parameterProfile ? { parameterProfile: config.parameterProfile } : {}),
|
||||
...(config.modelSpecification ? { modelSpecification: structuredClone(config.modelSpecification), modelSpecificationFrozen: config.modelSpecificationFrozen === true } : {}),
|
||||
...(config.modelConnectionId ? { modelConnectionId: config.modelConnectionId, modelCredentialRevision: config.modelCredentialRevision } : {}),
|
||||
...(config.modelConnectionId ? { modelConnectionId: config.modelConnectionId, modelConnectionRevision: config.modelConnectionRevision, modelCredentialRevision: config.modelCredentialRevision } : {}),
|
||||
...(config.modelRouting ? { routing: structuredClone(config.modelRouting) } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -6,11 +6,12 @@ export interface CatalogModel {
|
||||
inputModalities?: string[]; outputModalities?: string[]; nativeTools?: string[];
|
||||
apiCapabilities?: Record<string, Record<string, unknown>>; rawItem?: Record<string, unknown>; rawRepresentation?: string; rawSha256?: string; rawBytes?: number;
|
||||
endpoint?: string; fetchedAt?: string;
|
||||
requestBinding?: { contract: ReturnType<typeof import('./model-request-contract.mjs').requestCatalogBinding>; credentialRevision: number };
|
||||
}
|
||||
export interface CatalogPreview {
|
||||
id: string; entries: CatalogModel[]; fetchedAt: string; expiresAt: string; complete: boolean; warning: string;
|
||||
source: { name: string; baseUrl: string; protocol: string }; limits: { connections: number | null; poolMembers: number | null; catalog: number | null };
|
||||
source: { name: string; baseUrl: string; protocol: string; requestContract?: import('./model-request-contract.mjs').RequestContract }; limits: { connections: number | null; poolMembers: number | null; catalog: number | null };
|
||||
}
|
||||
export function catalogRoute(config: { protocol?: string; baseUrl: string }): string;
|
||||
export function catalogRoute(config: { protocol?: string; baseUrl: string; requestContract?: import('./model-request-contract.mjs').RequestContract }): string;
|
||||
export function catalogModel(item: unknown, config?: { executionMode?: string }): CatalogModel;
|
||||
export function catalogPage(response: unknown, config?: { executionMode?: string }): { entries: CatalogModel[]; hasMore: boolean; cursor: string; cursorParameter: 'pageToken' | 'after_id' };
|
||||
|
||||
@@ -17,6 +17,7 @@ function rawDeclaration(value) {
|
||||
}
|
||||
|
||||
export function catalogRoute(config) {
|
||||
if (config.requestContract?.modelsPath != null) return config.requestContract.modelsPath;
|
||||
const protocol = modelProtocol(config.protocol);
|
||||
return protocol === 'anthropic-messages' && !/\/v1$/i.test(new URL(config.baseUrl).pathname.replace(/\/+$/, ''))
|
||||
? '/v1/models' : '/models';
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
export function protocolLabel(protocol: string): string;
|
||||
export function protocolRoute(config: { protocol?: string; baseUrl: string }): string;
|
||||
export function modelRequestUrl(config: { protocol?: string; baseUrl: string }): string;
|
||||
export function protocolRoute(config: { protocol?: string; baseUrl: string; requestContract?: import('./model-request-contract.mjs').RequestContract }): string;
|
||||
export function endpointRequestUrl(config: { protocol?: string; baseUrl: string; requestContract?: import('./model-request-contract.mjs').RequestContract }, route: string, purpose?: string): string;
|
||||
export function modelRequestUrl(config: { protocol?: string; baseUrl: string; requestContract?: import('./model-request-contract.mjs').RequestContract }): string;
|
||||
export function messagesAuthSettings(protocol?: string, value?: string): { messagesAuth?: string };
|
||||
export function validateProtocolEndpoint(protocol: string, baseUrl: string): string;
|
||||
|
||||
@@ -3,6 +3,7 @@ import { modelProtocol } from './model-capabilities.mjs';
|
||||
export const protocolLabel = protocol => ({ 'chat-completions': 'Chat Completions', responses: 'Responses', 'anthropic-messages': 'Anthropic Messages' }[protocol] ?? protocol);
|
||||
|
||||
export function protocolRoute(config) {
|
||||
if (config.requestContract?.completionPath != null) return config.requestContract.completionPath;
|
||||
const protocol = modelProtocol(config.protocol);
|
||||
if (protocol === 'responses') return '/responses';
|
||||
if (protocol === 'anthropic-messages') {
|
||||
@@ -12,7 +13,11 @@ export function protocolRoute(config) {
|
||||
return '/chat/completions';
|
||||
}
|
||||
|
||||
export function modelRequestUrl(config) { return config.baseUrl.replace(/\/+$/, '') + protocolRoute(config); }
|
||||
export function endpointRequestUrl(config, route, purpose = 'completion') {
|
||||
return config.requestContract?.[purpose === 'models' ? 'modelsPath' : 'completionPath'] != null
|
||||
? new URL(route, new URL(config.baseUrl).origin).href : config.baseUrl.replace(/\/+$/, '') + route;
|
||||
}
|
||||
export function modelRequestUrl(config) { return endpointRequestUrl(config, protocolRoute(config)); }
|
||||
|
||||
export function messagesAuthSettings(protocol, value) {
|
||||
if (protocol !== 'anthropic-messages') return {};
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
export interface RequestContract { schemaVersion: 1; defaultsVersion: string; anthropicVersion: string | null; versionSource: string; anthropicBetas: string[]; auth: 'default' | 'none'; headers: Record<string, string | null>; completionPath: string | null; modelsPath: string | null }
|
||||
export interface RequestConnection { baseUrl?: string; protocol?: string; messagesAuth?: string; requestContract?: RequestContract; model?: string; id?: string; revision?: number; modelConnectionId?: string; credentialRevision?: number; modelCredentialRevision?: number }
|
||||
export const REQUEST_CONTRACT_SCHEMA: number;
|
||||
export const REQUEST_CONTRACT_DEFAULTS_VERSION: string;
|
||||
export const REQUEST_CONTRACT_SOURCES: Record<string, { url: string; checkedAt: string; sha256: string }>;
|
||||
export function credentialHeader(name: string): boolean;
|
||||
export function officialRequestProvider(connection?: RequestConnection): string | null;
|
||||
export function defaultMessagesAuth(connection: RequestConnection, options?: { existing?: boolean }): string;
|
||||
export function requestContractSettings(value: unknown, connection?: RequestConnection, options?: { existing?: boolean; previous?: RequestContract | null; trusted?: boolean }): RequestContract;
|
||||
export function effectiveRequestContract(connection?: RequestConnection): RequestContract;
|
||||
export function requestHeaders(connection: RequestConnection, key?: string): Headers;
|
||||
export function requestCredentialIdentity(connection: RequestConnection): { auth: string; headers: (string | null)[][]; completionPath: string | null; modelsPath: string | null } | null;
|
||||
export function requestCatalogBinding(connection: RequestConnection): { schemaVersion: number; protocol: string; requestUrl: string; headers: [string, string][] };
|
||||
@@ -0,0 +1,98 @@
|
||||
export const REQUEST_CONTRACT_SCHEMA = 1;
|
||||
export const REQUEST_CONTRACT_DEFAULTS_VERSION = '2026-11-07.1';
|
||||
export const REQUEST_CONTRACT_SOURCES = Object.freeze({
|
||||
anthropicVersion: { url: 'https://platform.claude.com/docs/en/api/versioning', checkedAt: '2026-11-07', sha256: '47b7a604ef4d29427a8b02de7404d2146359371ac2c865c06be6e34cf385f990' },
|
||||
anthropicAuth: { url: 'https://platform.claude.com/docs/en/api/overview', checkedAt: '2026-11-07', sha256: 'e01f368e0ced0dd2aeec56ed76810eecaf3ba470490afea4f22dfdffd858c9e2' },
|
||||
anthropicBetas: { url: 'https://platform.claude.com/docs/en/api/beta-headers', checkedAt: '2026-11-07', sha256: 'a5eaed2894dee4da4dc9f80f7e58383e53545b42eea69f9aa780c7048280245d' },
|
||||
openai: { url: 'https://developers.openai.com/api/reference/overview', checkedAt: '2026-11-07', sha256: '23f1fae74b726b95d06dd195411b06e97c1d1356e0bbb58da54a15a8ce1f89af' },
|
||||
deepseek: { url: 'https://api-docs.deepseek.com/api/create-message.md', checkedAt: '2026-11-07', sha256: '46b31d10f429910bf93ea2166537fb803cd2f49f7c5b4ad2ee4f08257b2e17e8' },
|
||||
});
|
||||
const fail = message => { throw Object.assign(new Error(message), { status: 400 }); };
|
||||
const object = value => value && typeof value === 'object' && !Array.isArray(value);
|
||||
export const credentialHeader = name => /^(?:authorization|proxy-authorization|x-api-key|api-key|cookie|set-cookie|.*(?:api[-_]?key|access[-_]?token|auth[-_]?token|secret))$/i.test(name);
|
||||
export function officialRequestProvider(connection = {}) {
|
||||
try { const url = new URL(connection.baseUrl); return url.protocol === 'https:' && !url.port ? { 'api.anthropic.com': 'anthropic', 'api.openai.com': 'openai', 'api.deepseek.com': 'deepseek' }[url.hostname] ?? null : null; }
|
||||
catch { return null; }
|
||||
}
|
||||
export function defaultMessagesAuth(connection, { existing = true } = {}) {
|
||||
return connection.messagesAuth ?? (!existing && officialRequestProvider(connection) === 'anthropic' ? 'bearer' : 'api-key');
|
||||
}
|
||||
function defaults(connection, existing) {
|
||||
const provider = officialRequestProvider(connection), messages = connection.protocol === 'anthropic-messages';
|
||||
return { schemaVersion: REQUEST_CONTRACT_SCHEMA, defaultsVersion: REQUEST_CONTRACT_DEFAULTS_VERSION,
|
||||
anthropicVersion: messages ? !existing && provider === 'anthropic' ? '2026-10-21' : !existing && provider === 'deepseek' ? null : '2023-06-01' : null,
|
||||
versionSource: existing ? 'legacy-default' : provider ? 'official-default' : 'compatibility-default',
|
||||
anthropicBetas: [], auth: 'default', headers: {},
|
||||
completionPath: !existing && messages && provider === 'deepseek' ? '/anthropic/v1/messages' : null,
|
||||
modelsPath: !existing && provider === 'deepseek' ? '/models' : null };
|
||||
}
|
||||
// Validate HTTP representation, not vendor semantics or an artificial quota.
|
||||
// Version/beta names remain explicit and unknown values go to the upstream.
|
||||
export function requestContractSettings(value, connection = {}, { existing = true, previous = null, trusted = false } = {}) {
|
||||
const initial = previous ?? defaults(connection, existing);
|
||||
if (value === undefined) return structuredClone(initial);
|
||||
if (!object(value) || value.schemaVersion !== undefined && value.schemaVersion !== REQUEST_CONTRACT_SCHEMA) fail('请求协议设置需要已支持版本的 JSON 对象。');
|
||||
const keys = ['schemaVersion', 'defaultsVersion', 'anthropicVersion', 'versionSource', 'anthropicBetas', 'auth', 'headers', 'completionPath', 'modelsPath'];
|
||||
if (Object.keys(value).some(key => !keys.includes(key))) fail('请求协议设置含未知字段,请在原生参数或对应设置中填写。');
|
||||
const result = { ...structuredClone(initial), ...structuredClone(value), schemaVersion: REQUEST_CONTRACT_SCHEMA };
|
||||
if (typeof result.defaultsVersion !== 'string' || !result.defaultsVersion) fail('请求协议资料版本无效。');
|
||||
if (result.anthropicVersion !== null && typeof result.anthropicVersion !== 'string') fail('API 版本需要字符串或 null(省略)。');
|
||||
if (!Array.isArray(result.anthropicBetas) || result.anthropicBetas.some(item => typeof item !== 'string')) fail('Beta 需要字符串数组。');
|
||||
if (!['default', 'none'].includes(result.auth)) fail('鉴权请选择连接默认或不自动添加。');
|
||||
if (!object(result.headers) || Object.values(result.headers).some(item => item !== null && typeof item !== 'string')) fail('额外请求头需要字符串或 null(移除)的 JSON 对象。');
|
||||
for (const [name, header] of Object.entries(result.headers)) {
|
||||
// Keys are managed in their existing memory/DPAPI store, never copied into
|
||||
// ordinary connection metadata, Run snapshots or diagnostic fingerprints.
|
||||
if (header && credentialHeader(name) && !header.includes('{{credential}}')) fail('鉴权或会话头请用 {{credential}} 引用独立 Key;凭据在 API Key 设置中填写。');
|
||||
try { new Headers([[name, (header ?? '').replaceAll('{{credential}}', 'credential')]]); }
|
||||
catch { fail('请求头名称或值不符合 HTTP 格式:' + name); }
|
||||
}
|
||||
try { if (result.anthropicVersion !== null) new Headers([['anthropic-version', result.anthropicVersion]]); new Headers([['anthropic-beta', result.anthropicBetas.join(',')]]); }
|
||||
catch { fail('API 版本或 Beta 值不符合 HTTP 头格式。'); }
|
||||
for (const name of ['completionPath', 'modelsPath']) {
|
||||
const route = result[name];
|
||||
if (route !== null && (typeof route !== 'string' || !route.startsWith('/') || route.startsWith('//') || /[\x00-\x20\x7f#\\]/.test(route))) fail('请求路径需要从 / 开始的同源路径,或 null(使用协议默认)。');
|
||||
if (route !== null) {
|
||||
const base = new URL(connection.baseUrl), url = new URL(route, base.origin);
|
||||
if (url.origin !== base.origin || url.username || url.password) fail('自定义请求路径必须与连接同源。');
|
||||
}
|
||||
}
|
||||
if (!trusted) result.versionSource = Object.hasOwn(value, 'anthropicVersion') && (!previous || value.anthropicVersion !== previous.anthropicVersion) ? 'explicit' : initial.versionSource;
|
||||
if (!['legacy-default', 'official-default', 'compatibility-default', 'explicit'].includes(result.versionSource)) fail('请求版本来源无效。');
|
||||
return result;
|
||||
}
|
||||
export function effectiveRequestContract(connection = {}) {
|
||||
return requestContractSettings(connection.requestContract, connection, { trusted: true });
|
||||
}
|
||||
export function requestHeaders(connection, key = '') {
|
||||
const contract = effectiveRequestContract(connection), headers = new Headers({ 'Content-Type': 'application/json' });
|
||||
if (connection.protocol === 'anthropic-messages') {
|
||||
if (contract.anthropicVersion !== null) headers.set('anthropic-version', contract.anthropicVersion);
|
||||
if (contract.anthropicBetas.length) headers.set('anthropic-beta', contract.anthropicBetas.join(','));
|
||||
}
|
||||
if (contract.auth === 'default' && key) {
|
||||
const apiKey = connection.protocol === 'anthropic-messages' && defaultMessagesAuth(connection) !== 'bearer';
|
||||
headers.set(apiKey ? 'x-api-key' : 'Authorization', apiKey ? key : 'Bearer ' + key);
|
||||
}
|
||||
for (const [name, value] of Object.entries(contract.headers)) {
|
||||
if (value === null) headers.delete(name);
|
||||
else headers.set(name, value.replaceAll('{{credential}}', key));
|
||||
}
|
||||
return headers;
|
||||
}
|
||||
// Keep legacy hashes exactly when only non-authentication settings were added.
|
||||
export function requestCredentialIdentity(connection) {
|
||||
if (!connection.requestContract) return null;
|
||||
const contract = effectiveRequestContract(connection);
|
||||
const headers = Object.entries(contract.headers).filter(([name, value]) => credentialHeader(name) || value?.includes('{{credential}}'))
|
||||
.map(([name, value]) => [name.toLowerCase(), value]).sort(([left], [right]) => left.localeCompare(right));
|
||||
return contract.auth !== 'default' || headers.length || contract.completionPath !== null || contract.modelsPath !== null
|
||||
? { auth: contract.auth, headers, completionPath: contract.completionPath, modelsPath: contract.modelsPath } : null;
|
||||
}
|
||||
|
||||
export function requestCatalogBinding(connection) {
|
||||
const contract = effectiveRequestContract(connection), base = new URL(connection.baseUrl), protocol = connection.protocol ?? 'chat-completions';
|
||||
const defaultPath = protocol === 'anthropic-messages' && !/\/v1$/i.test(base.pathname.replace(/\/+$/, '')) ? '/v1/models' : '/models';
|
||||
const requestUrl = contract.modelsPath === null ? connection.baseUrl.replace(/\/+$/, '') + defaultPath : new URL(contract.modelsPath, base.origin).href;
|
||||
return { schemaVersion: 1, protocol, requestUrl, headers: [...requestHeaders(connection, '{{credential}}')] };
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
export interface ModelSpecField { value: unknown; kind: string; note?: string; provider?: string; apiVersion?: string; url?: string | null; checkedAt?: string | null; sha256?: string | null; sourceId?: string; alternatives: Omit<ModelSpecField, 'alternatives' | 'conflict'>[]; conflict: boolean }
|
||||
export interface ModelSpecification { schemaVersion: number; registryVersion: string; model: string; protocol: string; provider: string | null; providerSource: string; apiVersion: string | null; officialRecord: { provider: string; protocol: string; apiVersion: string; model: string } | null; fields: Record<string, ModelSpecField>; conflicts: string[]; liveCompatibility: string }
|
||||
export interface ModelSpecConnection { model?: string; protocol?: string; baseUrl?: string; providerId?: string; apiVersion?: string; nativeParameters?: Record<string, unknown>; modelOverrides?: Record<string, unknown>; modelSpecification?: ModelSpecification; modelSpecificationFrozen?: boolean; upstreamModel?: import('./model-catalog.mjs').CatalogModel; capabilityDeclarations?: Record<string, string>; capabilityDeclarationSources?: Record<string, string>; credentialRevision?: number; revision?: number; capabilityEvidence?: { connectionRevision?: number; credentialRevision?: number; results?: Record<string, string>; checkedAt?: string } }
|
||||
export interface ModelSpecification { schemaVersion: number; registryVersion: string; model: string; protocol: string; provider: string | null; providerSource: string; apiVersion: string | null; connectionBinding?: { baseUrl: string | null; providerId: string | null; apiVersion: string | null; messagesAuth: string | null; requestContract: import('./model-request-contract.mjs').RequestContract; credentialRevision: number }; officialRecord: { provider: string; protocol: string; apiVersion: string; model: string } | null; fields: Record<string, ModelSpecField>; conflicts: string[]; liveCompatibility: string }
|
||||
export interface ModelSpecConnection { model?: string; protocol?: string; baseUrl?: string; providerId?: string; apiVersion?: string; requestContract?: import('./model-request-contract.mjs').RequestContract; messagesAuth?: string; nativeParameters?: Record<string, unknown>; modelOverrides?: Record<string, unknown>; modelSpecification?: ModelSpecification; modelSpecificationFrozen?: boolean; upstreamModel?: import('./model-catalog.mjs').CatalogModel; capabilityDeclarations?: Record<string, string>; capabilityDeclarationSources?: Record<string, string>; credentialRevision?: number; modelCredentialRevision?: number; revision?: number; capabilityEvidence?: { connectionRevision?: number; credentialRevision?: number; results?: Record<string, string>; checkedAt?: string } }
|
||||
export const MODEL_REGISTRY_SCHEMA: number;
|
||||
export const MODEL_REGISTRY_VERSION: string;
|
||||
export const modelRegistry: Readonly<{ schemaVersion: number; version: string; sources: readonly { id: string; provider: string; url: string; checkedAt: string; sha256: string }[]; records: readonly { provider: string; protocol: string; apiVersion: string; model: string; fields: Record<string, { value: unknown; source: string; anchor: string }> }[] }>;
|
||||
export function validateModelRegistry(input: unknown): unknown;
|
||||
export function modelProvider(connection?: ModelSpecConnection): { id: string | null; source: string };
|
||||
export function officialModelRecord(connection?: ModelSpecConnection): (typeof modelRegistry.records)[number] | null;
|
||||
export function matchingUpstreamModel(connection?: ModelSpecConnection): import('./model-catalog.mjs').CatalogModel | null;
|
||||
export function matchingUpstreamModel(connection?: ModelSpecConnection, credentialRevision?: number): import('./model-catalog.mjs').CatalogModel | null;
|
||||
export function modelOverrideSettings(input?: unknown, previous?: Record<string, unknown>): Record<string, unknown>;
|
||||
export function resolveModelSpecification(connection?: ModelSpecConnection, credentialRevision?: number): ModelSpecification;
|
||||
export function specificationField(connection: ModelSpecConnection, field: string): ModelSpecField | null;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import sources from './official-model-sources.json' with { type: 'json' };
|
||||
import { officialModelRecords } from './official-model-registry-data.mjs';
|
||||
import { effectiveRequestContract, requestCatalogBinding, defaultMessagesAuth } from './model-request-contract.mjs';
|
||||
|
||||
export const MODEL_REGISTRY_SCHEMA = 1;
|
||||
export const MODEL_REGISTRY_VERSION = sources.registryVersion;
|
||||
@@ -64,9 +65,12 @@ export function officialModelRecord(connection = {}) {
|
||||
return rows.length === 1 ? rows[0] : null;
|
||||
}
|
||||
|
||||
export function matchingUpstreamModel(connection = {}) {
|
||||
export function matchingUpstreamModel(connection = {}, credentialRevision = connection.modelCredentialRevision ?? connection.credentialRevision) {
|
||||
const item = connection.upstreamModel;
|
||||
return item?.id === connection.model && (!item.endpoint || item.endpoint === connection.baseUrl) ? item : null;
|
||||
if (!item || item.id !== connection.model || item.endpoint && item.endpoint !== connection.baseUrl) return null;
|
||||
if (item.requestBinding && (JSON.stringify(item.requestBinding.contract) !== JSON.stringify(requestCatalogBinding(connection))
|
||||
|| credentialRevision !== undefined && item.requestBinding.credentialRevision !== credentialRevision)) return null;
|
||||
return item;
|
||||
}
|
||||
|
||||
export function modelOverrideSettings(input, previous = {}) {
|
||||
@@ -111,9 +115,13 @@ function overrideFacts(value) {
|
||||
return fields;
|
||||
}
|
||||
|
||||
export function resolveModelSpecification(connection = {}, credentialRevision = connection.credentialRevision ?? 0) {
|
||||
if (connection.modelSpecificationFrozen === true && connection.modelSpecification?.model === connection.model && connection.modelSpecification.protocol === (connection.protocol ?? 'chat-completions')) return structuredClone(connection.modelSpecification);
|
||||
const provider = modelProvider(connection), entry = officialModelRecord(connection), catalog = matchingUpstreamModel(connection);
|
||||
export function resolveModelSpecification(connection = {}, credentialRevision = connection.modelCredentialRevision ?? connection.credentialRevision ?? 0) {
|
||||
const connectionBinding = { baseUrl: connection.baseUrl ?? null, providerId: connection.providerId ?? null, apiVersion: connection.apiVersion ?? null,
|
||||
messagesAuth: connection.protocol === 'anthropic-messages' ? defaultMessagesAuth(connection) : null,
|
||||
requestContract: effectiveRequestContract(connection), credentialRevision };
|
||||
if (connection.modelSpecificationFrozen === true && connection.modelSpecification?.model === connection.model && connection.modelSpecification.protocol === (connection.protocol ?? 'chat-completions')
|
||||
&& (!connection.modelSpecification.connectionBinding || JSON.stringify(connection.modelSpecification.connectionBinding) === JSON.stringify(connectionBinding))) return structuredClone(connection.modelSpecification);
|
||||
const provider = modelProvider(connection), entry = officialModelRecord(connection), catalog = matchingUpstreamModel(connection, credentialRevision);
|
||||
const candidates = new Map(), add = (key, value, origin) => {
|
||||
const values = candidates.get(key) ?? [];
|
||||
values.push({ value: structuredClone(value), ...origin }); candidates.set(key, values);
|
||||
@@ -144,7 +152,7 @@ export function resolveModelSpecification(connection = {}, credentialRevision =
|
||||
return [key, { ...selected, alternatives: values.filter(value => value !== selected), conflict: values.some(value => JSON.stringify(value.value) !== JSON.stringify(selected.value)) }];
|
||||
}));
|
||||
return { schemaVersion: MODEL_REGISTRY_SCHEMA, registryVersion: MODEL_REGISTRY_VERSION, model: connection.model ?? '', protocol: connection.protocol ?? 'chat-completions',
|
||||
provider: provider.id, providerSource: provider.source, apiVersion: connection.apiVersion && connection.apiVersion !== 'auto' ? connection.apiVersion : entry?.apiVersion ?? null,
|
||||
provider: provider.id, providerSource: provider.source, apiVersion: connection.apiVersion && connection.apiVersion !== 'auto' ? connection.apiVersion : entry?.apiVersion ?? null, connectionBinding,
|
||||
officialRecord: entry ? { provider: entry.provider, protocol: entry.protocol, apiVersion: entry.apiVersion, model: entry.model } : null,
|
||||
fields, conflicts: Object.entries(fields).filter(([, value]) => value.conflict).map(([key]) => key),
|
||||
liveCompatibility: 'not_established_by_registry' };
|
||||
|
||||
Reference in New Issue
Block a user