Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe('ModelSettingsPage loading and provider actions', () => {
for (const key of ['acquisition.noneConfigured', 'acquisition.noneImported', 'pool.empty']) {
expect(container.textContent).not.toContain(copy(key));
}
expect(selectors()).toHaveLength(4);
expect(selectors()).toHaveLength(5);
expect(selectors().every(element => element.disabled)).toBe(true);
expect(button('actions.addModel').disabled).toBe(true);
expect(button('acquisition.import').disabled).toBe(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ const ModelSettingsPage: React.FC = () => {
() => [
{ label: t('category.general_chat'), value: 'general_chat' },
{ label: t('category.multimodal'), value: 'multimodal' },
{ label: t('category.image_generation'), value: 'image_generation' },
{ label: t('category.speech_recognition'), value: 'speech_recognition' },
],
[t]
Expand Down Expand Up @@ -2438,6 +2439,7 @@ const ModelSettingsPage: React.FC = () => {
{ modelId: poolDefaults.primary, label: tDefault('core.primary.label') },
{ modelId: poolDefaults.fast, label: tDefault('core.fast.label') },
{ modelId: poolDefaults.image_understanding, label: tDefault('optional.capabilities.image_understanding.label') },
{ modelId: poolDefaults.image_generation, label: tDefault('optional.capabilities.image_generation.label') },
{ modelId: poolDefaults.speech_recognition, label: tDefault('optional.capabilities.speech_recognition.label') },
], [poolDefaults, tDefault]);

Expand Down Expand Up @@ -4207,6 +4209,7 @@ const ModelSettingsPage: React.FC = () => {
{ value: '', label: t('pool.allCapabilities') },
{ value: 'text_chat', label: t('capabilities.text_chat') },
{ value: 'image_understanding', label: t('capabilities.image_understanding') },
{ value: 'image_generation', label: t('capabilities.image_generation') },
{ value: 'speech_recognition', label: t('capabilities.speech_recognition') },
{ value: 'function_calling', label: t('capabilities.function_calling') },
]} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const log = createLogger('DefaultModelConfig');
const normalizeSelectValue = (value: string | number | (string | number)[]): string | number =>
Array.isArray(value) ? (value[0] ?? '') : value;

type DefaultModelSlot = 'primary' | 'fast' | 'image_understanding' | 'speech_recognition';
type DefaultModelSlot = 'primary' | 'fast' | 'image_understanding' | 'image_generation' | 'speech_recognition';

interface DefaultModelConfigProps {
compact?: boolean;
Expand Down Expand Up @@ -82,6 +82,8 @@ export const DefaultModelConfig: React.FC<DefaultModelConfigProps> = ({
return t('core.fast.label');
case 'image_understanding':
return t('optional.capabilities.image_understanding.label');
case 'image_generation':
return t('optional.capabilities.image_generation.label');
case 'speech_recognition':
return t('optional.capabilities.speech_recognition.label');
default: {
Expand Down Expand Up @@ -133,6 +135,9 @@ export const DefaultModelConfig: React.FC<DefaultModelConfigProps> = ({
const imageUnderstandingModels = models.filter(model => (
isSelectableModelForCapability(model, 'image_understanding')
));
const imageGenerationModels = models.filter(model => (
isSelectableModelForCapability(model, 'image_generation')
));
const speechRecognitionModels = models.filter(model => (
isSelectableModelForCapability(model, 'speech_recognition')
));
Expand Down Expand Up @@ -204,6 +209,29 @@ export const DefaultModelConfig: React.FC<DefaultModelConfigProps> = ({
/>
</ConfigPageRow>

<ConfigPageRow
label={renderSlotLabel(
t('optional.capabilities.image_generation.label'),
t('optional.capabilities.image_generation.description'),
)}
multiline={compact}
align="center"
>
<Combobox
aria-label={t('optional.capabilities.image_generation.label')}
value={defaultModels.image_generation || ''}
onValueChange={(value) => handleDefaultModelChange('image_generation', normalizeSelectValue(value))}
placeholder={pendingPlaceholder ?? t('optional.notSet')}
options={[
{ label: t('optional.notSet'), value: '' },
...imageGenerationModels.map(buildModelOption),
]}
className="default-model-config__model-select"
disabled={controlsDisabled || imageGenerationModels.length === 0}
size="sm"
/>
</ConfigPageRow>

<ConfigPageRow
label={renderSlotLabel(
t('optional.capabilities.speech_recognition.label'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,17 @@ describe('model capability selection', () => {
capabilities: [],
})).toBe(false);
});

it('maps image_generation category to the image_generation capability', () => {
const imageGenModel = {
id: 'dall-e-3',
enabled: true,
category: 'image_generation',
capabilities: [],
};

expect(getEffectiveModelCapabilities(imageGenModel)).toEqual(['image_generation']);
expect(isSelectableModelForCapability(imageGenModel, 'image_generation')).toBe(true);
expect(isSelectableTextChatModel(imageGenModel)).toBe(false);
});
});
26 changes: 26 additions & 0 deletions src/web-ui/src/infrastructure/config/services/modelCategory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ const SPEECH_RECOGNITION_MODEL_HINTS = [
'speech',
];

const IMAGE_GENERATION_MODEL_HINTS = [
'dall-e',
'dalle',
'image',
'flux',
'sdxl',
'stable-diffusion',
'midjourney',
'imagen',
'draw',
];

export function inferModelCategory(
modelName: string,
_provider?: string
Expand All @@ -33,6 +45,9 @@ export function inferModelCategory(
if (SPEECH_RECOGNITION_MODEL_HINTS.some(hint => normalized.includes(hint))) {
return 'speech_recognition';
}
if (IMAGE_GENERATION_MODEL_HINTS.some(hint => normalized.includes(hint))) {
return 'image_generation';
}
if (MULTIMODAL_MODEL_HINTS.some(hint => normalized.includes(hint))) {
return 'multimodal';
}
Expand All @@ -50,6 +65,10 @@ export function resolveModelCategory(
return 'multimodal';
}

if (category === 'image_generation') {
return 'image_generation';
}

if (category === 'speech_recognition') {
return 'speech_recognition';
}
Expand All @@ -62,13 +81,19 @@ export function resolveModelCategory(
return 'speech_recognition';
}

if (category === 'general_chat' && inferred === 'image_generation') {
return 'image_generation';
}

return category ?? inferred;
}

export function getCapabilitiesByCategory(category?: ModelCategory | string | null): ModelCapability[] {
switch (category) {
case 'speech_recognition':
return ['speech_recognition'];
case 'image_generation':
return ['image_generation'];
case 'multimodal':
return ['text_chat', 'image_understanding', 'function_calling'];
case 'general_chat':
Expand All @@ -88,6 +113,7 @@ export function getEffectiveModelCapabilities(model: ModelCapabilitySource): Mod
capability === 'text_chat'
|| capability === 'function_calling'
|| capability === 'image_understanding'
|| capability === 'image_generation'
|| capability === 'speech_recognition'
))
: [];
Expand Down
5 changes: 5 additions & 0 deletions src/web-ui/src/infrastructure/config/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,13 @@ export type ModelCapability =
| 'text_chat'
| 'function_calling'
| 'image_understanding'
| 'image_generation'
| 'speech_recognition';

export type ModelCategory =
| 'general_chat'
| 'multimodal'
| 'image_generation'
| 'speech_recognition';

export type ReasoningCatalogBinding =
Expand Down Expand Up @@ -260,12 +262,14 @@ export interface ModelMetadata {
export const CATEGORY_LABELS: Record<ModelCategory, string> = {
general_chat: t('settings/models:category.general_chat'),
multimodal: t('settings/models:category.multimodal'),
image_generation: t('settings/models:category.image_generation'),
speech_recognition: t('settings/models:category.speech_recognition')
};

export const CATEGORY_ICONS: Record<ModelCategory, string> = {
general_chat: t('settings/models:categoryIcons.general_chat'),
multimodal: t('settings/models:categoryIcons.multimodal'),
image_generation: t('settings/models:categoryIcons.image_generation'),
speech_recognition: t('settings/models:categoryIcons.speech_recognition')
};

Expand Down Expand Up @@ -332,6 +336,7 @@ export interface DefaultModelsConfig {
primary?: string | null;
fast?: string | null;
image_understanding?: string | null;
image_generation?: string | null;
speech_recognition?: string | null;
}

Expand Down
Loading