feat: consume server model reasoning capabilities

This commit is contained in:
2026-09-01 14:16:18 +08:00
parent 850947c092
commit ae79361742
20 changed files with 711 additions and 20 deletions

View File

@@ -1,6 +1,28 @@
export type ImportedModelModality = 'text' | 'audio' | 'image' | 'pdf';
export type ImportedVisionTokenEstimator = 'qwen-32px-grid';
export type ImportedThinkingLevel = 'off' | 'minimal' | 'low' | 'medium' | 'high';
export type ImportedThinkingLevel = 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'max';
export const IMPORTED_REASONING_EFFORTS = ['low', 'high', 'max'] as const;
export type ImportedReasoningEffort = (typeof IMPORTED_REASONING_EFFORTS)[number];
export interface ImportedModelCapability {
reasoningEfforts: ImportedReasoningEffort[];
reasoningCanDisable: boolean;
}
export type ImportedModelCapabilities = Record<string, ImportedModelCapability>;
export function thinkingLevelMapForImportedModelCapability(
capability: ImportedModelCapability,
): Partial<Record<ImportedThinkingLevel, string | null>> {
return {
...(capability.reasoningCanDisable ? {} : { off: null }),
minimal: null,
low: capability.reasoningEfforts.includes('low') ? 'low' : null,
medium: null,
high: capability.reasoningEfforts.includes('high') ? 'high' : null,
max: capability.reasoningEfforts.includes('max') ? 'max' : null,
};
}
export interface ImportedPiModelProfile {
reasoning: boolean;
@@ -62,14 +84,15 @@ export function getImportedModelProfile(rawModelId: string): ImportedModelProfil
pi: {
reasoning: true,
thinkingLevelMap: {
off: null,
minimal: null,
low: null,
low: 'low',
medium: null,
high: 'high',
max: 'max',
},
compat: {
thinkingFormat: 'deepseek',
supportsReasoningEffort: true,
requiresReasoningContentOnAssistantMessages: true,
},
},