840
return [];
841
}
843
>
const actions: IAction[] = [];
844
>
845
>
for (const [key, propSchema] of Object.entries(schema.properties)) {
846
>
if (!propSchema.enum || !Array.isArray(propSchema.enum) || propSchema.enum.length < 1) {
847
>
continue;
848
>
}
849
>
const currentValue = currentConfig[key] ?? propSchema.default;
850
>
const label = (typeof propSchema.title === 'string' ? propSchema.title : undefined)
851
>
?? key.replace(/([a-z])([A-Z])/g, '$1 $2')
852
>
.replace(/^./, s => s.toUpperCase());
853
>
const defaultValue = propSchema.default;
854
>
const enumItemLabels = propSchema.enumItemLabels;
855
>
const enumDescriptions = propSchema.enumDescriptions;
856
>
const enumActions: IAction[] = propSchema.enum.map((value: unknown, index: number) => {
857
>
const itemLabel = enumItemLabels?.[index] ?? String(value);
858
>
const displayLabel = value === defaultValue ? localize('models.enumDefault', "{0} (default)", itemLabel) : itemLabel;
859
>
const tooltip = enumDescriptions?.[index] ?? '';
860
>
return {
861
>
id: `configureModel.${key}.${value}`,
862
>
label: displayLabel,
863
>
class: undefined,
864
>
enabled: true,
865
>
tooltip,
866
>
checked: currentValue === value,
867
>
run: () => setValue(key, value)
868
>
};
869
>
});
870
>
actions.push(new SubmenuAction(`configureModel.${key}`, label, enumActions));
871
>
}
872
>
873
>
return actions;
874
>
}
875
876
export class LanguageModelsService implements ILanguageModelsService {