feat(coding): add model tools and device packages
This commit is contained in:
1 parent
841273b433
commit
664b8823a0
60 files changed
+3847
-2068
No files matched your search
@@ -2,6 +2,7 @@ import {
|
||||
IMPORTED_REASONING_EFFORTS,
|
||||
type ImportedModelCapabilities,
|
||||
type ImportedModelCapability,
|
||||
type ImportedModelWebSearchCapability,
|
||||
type ImportedReasoningEffort,
|
||||
} from './imported-model-profile';
|
||||
|
||||
@@ -40,7 +41,64 @@ function normalizeImportedModelCapability(value: unknown): ImportedModelCapabili
|
||||
rawEfforts.some((candidate) => candidate === effort)
|
||||
)) as ImportedReasoningEffort[];
|
||||
if (reasoningEfforts.length === 0 && rawEfforts.length > 0) return null;
|
||||
return { reasoningEfforts, reasoningCanDisable };
|
||||
const webSearch = normalizeImportedModelWebSearchCapability(
|
||||
record.web_search ?? record.webSearch,
|
||||
);
|
||||
return {
|
||||
reasoningEfforts,
|
||||
reasoningCanDisable,
|
||||
...(webSearch ? { webSearch } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
function normalizeImportedModelWebSearchCapability(
|
||||
value: unknown,
|
||||
): ImportedModelWebSearchCapability | null {
|
||||
if (!value || typeof value !== 'object' || Array.isArray(value)) return null;
|
||||
const record = value as Record<string, unknown>;
|
||||
const schemaVersion = record.schema_version ?? record.schemaVersion;
|
||||
const rawAdapter = record.adapter;
|
||||
const supportsForcedSearch = record.supports_forced_search ?? record.supportsForcedSearch;
|
||||
const rawSourceMode = record.source_mode ?? record.sourceMode;
|
||||
const rawBillingAuthority = record.billing_authority ?? record.billingAuthority;
|
||||
const adapters: Record<string, ImportedModelWebSearchCapability['adapter']> = {
|
||||
openai_responses: 'openai-responses',
|
||||
'openai-responses': 'openai-responses',
|
||||
bailian_responses: 'bailian-responses',
|
||||
'bailian-responses': 'bailian-responses',
|
||||
bailian_chat_completions: 'bailian-chat-completions',
|
||||
'bailian-chat-completions': 'bailian-chat-completions',
|
||||
};
|
||||
const sourceModes: Record<string, ImportedModelWebSearchCapability['sourceMode']> = {
|
||||
structured: 'structured',
|
||||
inline_or_structured: 'inline-or-structured',
|
||||
'inline-or-structured': 'inline-or-structured',
|
||||
};
|
||||
const billingAuthorities: Record<string, ImportedModelWebSearchCapability['billingAuthority']> = {
|
||||
model_request: 'model-request',
|
||||
'model-request': 'model-request',
|
||||
};
|
||||
const adapter = typeof rawAdapter === 'string' ? adapters[rawAdapter] : undefined;
|
||||
const sourceMode = typeof rawSourceMode === 'string' ? sourceModes[rawSourceMode] : undefined;
|
||||
const billingAuthority = typeof rawBillingAuthority === 'string'
|
||||
? billingAuthorities[rawBillingAuthority]
|
||||
: undefined;
|
||||
if (
|
||||
schemaVersion !== 1
|
||||
|| !adapter
|
||||
|| supportsForcedSearch !== true
|
||||
|| !sourceMode
|
||||
|| !billingAuthority
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
schemaVersion: 1,
|
||||
adapter,
|
||||
supportsForcedSearch: true,
|
||||
sourceMode,
|
||||
billingAuthority,
|
||||
};
|
||||
}
|
||||
|
||||
export function normalizeImportedModelCapabilities(
|
||||
|
||||
Reference in new issue
Block a user