feat: consume server model reasoning capabilities
This commit is contained in:
@@ -17,7 +17,10 @@ import {
|
||||
normalizeImportedUserModelId,
|
||||
selectUserModelRuntimeAccounts,
|
||||
} from '../../../shared/user-model-config';
|
||||
import { getImportedModelProfile } from '../../../shared/imported-model-profile';
|
||||
import {
|
||||
getImportedModelProfile,
|
||||
thinkingLevelMapForImportedModelCapability,
|
||||
} from '../../../shared/imported-model-profile';
|
||||
|
||||
const PI_ENV_PREFIX = 'MAKELORE_PI';
|
||||
const WORKS_SQUARE_AI_GATEWAY_CREDENTIAL_MODE = 'works_square_ai_gateway';
|
||||
@@ -302,6 +305,7 @@ function modelDescriptor(
|
||||
));
|
||||
const backend = backendModels.get(modelId);
|
||||
const profile = getImportedModelProfile(modelId);
|
||||
const serverCapability = account.metadata?.worksSquareModelCapabilities?.[modelId];
|
||||
const backendInput = Array.isArray(backend?.input)
|
||||
? backend.input.filter((input): input is 'text' | 'image' => input === 'text' || input === 'image')
|
||||
: [];
|
||||
@@ -319,17 +323,28 @@ function modelDescriptor(
|
||||
id: modelId,
|
||||
name: summary?.name || (typeof backend?.name === 'string' && backend.name.trim()) || modelId,
|
||||
input: supportsImage ? ['text', 'image'] : ['text'],
|
||||
reasoning: summary?.supportsReasoning === true
|
||||
|| profile?.pi?.reasoning === true
|
||||
|| backend?.reasoning === true,
|
||||
reasoning: serverCapability
|
||||
? serverCapability.reasoningEfforts.length > 0
|
||||
: summary?.supportsReasoning === true
|
||||
|| profile?.pi?.reasoning === true
|
||||
|| backend?.reasoning === true,
|
||||
...(contextWindow ? { contextWindow } : {}),
|
||||
...(maxOutputTokens ? { maxOutputTokens } : {}),
|
||||
...(compat || profile?.pi?.compat || enforcedCompat
|
||||
? { compat: { ...compat, ...profile?.pi?.compat, ...enforcedCompat } }
|
||||
: {}),
|
||||
...(profile?.pi?.thinkingLevelMap
|
||||
? { thinkingLevelMap: { ...profile.pi.thinkingLevelMap } }
|
||||
...(compat || profile?.pi?.compat || enforcedCompat || serverCapability
|
||||
? {
|
||||
compat: {
|
||||
...compat,
|
||||
...profile?.pi?.compat,
|
||||
...enforcedCompat,
|
||||
...(serverCapability ? { supportsReasoningEffort: true } : {}),
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
...(serverCapability
|
||||
? { thinkingLevelMap: thinkingLevelMapForImportedModelCapability(serverCapability) }
|
||||
: profile?.pi?.thinkingLevelMap
|
||||
? { thinkingLevelMap: { ...profile.pi.thinkingLevelMap } }
|
||||
: {}),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -459,6 +459,7 @@ const PRODUCT_THINKING_LEVELS = new Set<ProductModelRef['thinkingLevel']>([
|
||||
'low',
|
||||
'medium',
|
||||
'high',
|
||||
'max',
|
||||
]);
|
||||
|
||||
function productThinkingLevel(value: unknown): ProductModelRef['thinkingLevel'] | null {
|
||||
|
||||
Reference in New Issue
Block a user