Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix: hide image/video from custom model type options (#20007)

YuTengjing6e6d166ae3f2
diff --git a/src/features/Settings/provider/features/ModelList/CreateNewModelModal/Form.tsx b/src/features/Settings/provider/features/ModelList/CreateNewModelModal/Form.tsx
index 95ae819d60f..2702e180736 100644
--- a/src/features/Settings/provider/features/ModelList/CreateNewModelModal/Form.tsx
+++ b/src/features/Settings/provider/features/ModelList/CreateNewModelModal/Form.tsx
@@ -11,7 +11,7 @@ import { useIsMobile } from '@/hooks/useIsMobile';
import { type ChatModelCard } from '@/types/llm';
import ExtendParamsSelect from './ExtendParamsSelect';
-import { hasDuplicateModelId } from './utils';
+import { CUSTOM_MODEL_TYPES, hasDuplicateModelId } from './utils';
interface ModelConfigFormProps {
disabled?: boolean;
@@ -40,18 +40,7 @@ const ModelConfigForm = memo<ModelConfigFormProps>(
const modelTypeOptions = useMemo(
() =>
- (
- [
- 'chat',
- 'embedding',
- 'tts',
- 'asr',
- 'image',
- 'video',
- 'text2music',
- 'realtime',
- ] as AiModelType[]
- ).map((value) => {
+ CUSTOM_MODEL_TYPES.map((value) => {
const label = t(`providerModels.item.modelConfig.type.options.${value}`);
return {
diff --git a/src/features/Settings/provider/features/ModelList/CreateNewModelModal/__tests__/utils.test.ts b/src/features/Settings/provider/features/ModelList/CreateNewModelModal/__tests__/utils.test.ts
index 2878fbbf40e..c5bd565b687 100644
--- a/src/features/Settings/provider/features/ModelList/CreateNewModelModal/__tests__/utils.test.ts
+++ b/src/features/Settings/provider/features/ModelList/CreateNewModelModal/__tests__/utils.test.ts
@@ -1,6 +1,17 @@
import { describe, expect, it } from 'vitest';
-import { hasDuplicateModelId } from '../utils';
+import { CUSTOM_MODEL_TYPES, hasDuplicateModelId } from '../utils';
+
+describe('CUSTOM_MODEL_TYPES', () => {
+ it('should not offer image or video, which require a parameters schema', () => {
+ expect(CUSTOM_MODEL_TYPES).not.toContain('image');
+ expect(CUSTOM_MODEL_TYPES).not.toContain('video');
+ });
+
+ it('should keep the other generation types selectable', () => {
+ expect(CUSTOM_MODEL_TYPES).toContain('text2music');
+ });
+});
describe('hasDuplicateModelId', () => {
it('should detect an existing model id', () => {
diff --git a/src/features/Settings/provider/features/ModelList/CreateNewModelModal/utils.ts b/src/features/Settings/provider/features/ModelList/CreateNewModelModal/utils.ts
index 4ea7cd44bae..d1dbb1012e5 100644
--- a/src/features/Settings/provider/features/ModelList/CreateNewModelModal/utils.ts
+++ b/src/features/Settings/provider/features/ModelList/CreateNewModelModal/utils.ts
@@ -1,3 +1,21 @@
+import type { AiModelType } from 'model-bank';
+
+/**
+ * Model types selectable when creating or editing a custom model.
+ *
+ * `image` and `video` are intentionally excluded: generation relies on a model-bank
+ * `parameters` schema that this form cannot edit yet, so custom image/video models end up
+ * schema-less and break model switching on the generation pages.
+ */
+export const CUSTOM_MODEL_TYPES: AiModelType[] = [
+ 'chat',
+ 'embedding',
+ 'tts',
+ 'asr',
+ 'text2music',
+ 'realtime',
+];
+
export const hasDuplicateModelId = (id: string | undefined, existingModelIds: string[]) => {
const modelId = id?.trim();
if (!modelId) return false;