feat(project-config): simplify plugin and model drawers
This commit is contained in:
@@ -1,11 +1,44 @@
|
||||
import type { ProviderAccount, ProviderVendorInfo } from '@/lib/providers';
|
||||
import type { ProductModelRef } from '@/types/coding-conversation';
|
||||
import type { ConversationThinkingLevel, ProductModelRef } from '@/types/coding-conversation';
|
||||
import { getImportedModelProfile } from '../../shared/imported-model-profile';
|
||||
|
||||
export interface CodingModelOption {
|
||||
key: string;
|
||||
accountId: string;
|
||||
modelId: string;
|
||||
label: string;
|
||||
availableThinkingLevels: ConversationThinkingLevel[] | null;
|
||||
}
|
||||
|
||||
const STANDARD_THINKING_LEVELS: readonly ConversationThinkingLevel[] = [
|
||||
'off',
|
||||
'minimal',
|
||||
'low',
|
||||
'medium',
|
||||
'high',
|
||||
];
|
||||
const SERVER_REASONING_LEVELS = ['low', 'high', 'max'] as const;
|
||||
|
||||
function availableThinkingLevels(
|
||||
account: ProviderAccount,
|
||||
modelId: string,
|
||||
): ConversationThinkingLevel[] | null {
|
||||
const serverCapability = account.metadata?.worksSquareModelCapabilities?.[modelId];
|
||||
if (serverCapability) {
|
||||
return [
|
||||
...(serverCapability.reasoningCanDisable ? ['off' as const] : []),
|
||||
...SERVER_REASONING_LEVELS.filter((level) => serverCapability.reasoningEfforts.includes(level)),
|
||||
];
|
||||
}
|
||||
|
||||
const profile = getImportedModelProfile(modelId)?.pi;
|
||||
if (!profile) return null;
|
||||
if (!profile.reasoning) return ['off'];
|
||||
if (!profile.thinkingLevelMap) return [...STANDARD_THINKING_LEVELS];
|
||||
return [
|
||||
...STANDARD_THINKING_LEVELS.filter((level) => profile.thinkingLevelMap?.[level] !== null),
|
||||
...(typeof profile.thinkingLevelMap.max === 'string' ? ['max' as const] : []),
|
||||
];
|
||||
}
|
||||
|
||||
export function codingModelKey(model: Pick<ProductModelRef, 'accountId' | 'modelId'>): string {
|
||||
@@ -51,6 +84,7 @@ export function buildCodingModelOptions(
|
||||
accountId: account.id,
|
||||
modelId,
|
||||
label: `${account.label}${vendor && vendor !== account.label ? ` · ${vendor}` : ''} / ${modelId}`,
|
||||
availableThinkingLevels: availableThinkingLevels(account, modelId),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user