Skip to content

fix: allow setting model type when adding custom models, preserve on restart#284

Open
octo-patch wants to merge 2 commits into
11cafe:mainfrom
octo-patch:fix/issue-271-custom-image-model-type
Open

fix: allow setting model type when adding custom models, preserve on restart#284
octo-patch wants to merge 2 commits into
11cafe:mainfrom
octo-patch:fix/issue-271-custom-image-model-type

Conversation

@octo-patch

Copy link
Copy Markdown

Fixes #271

Problem

When users add a new model via the settings dialog, the model type is hardcoded to text, making it impossible to configure image or video models for custom providers (such as OpenRouter). Additionally, if a user manually edited config.toml to set a model's type to image or video for a custom provider, those models were silently dropped on app restart because config_service.initialize() only preserved text-type user-added models for all providers.

Solution

Frontend (AddModelsList.tsx)

  • Add a Model Type selector (text / image / video) to the Add Model dialog, defaulting to text to preserve existing behavior for LLM models.

Backend (config_service.py)

  • In initialize(), distinguish between built-in providers (in DEFAULT_PROVIDERS_CONFIG) and custom providers (e.g. OpenRouter, any user-added provider).
  • For built-in providers: keep the existing behavior — only user-added text models are preserved (image/video are hardcoded per-provider).
  • For custom providers: preserve all model types as configured, so image/video models survive app restarts.
  • Use dict() copy when reading DEFAULT_PROVIDERS_CONFIG models to avoid mutating the module-level default on repeated initialize() calls.

Testing

  • Add a custom provider (e.g. OpenRouter) in Settings
  • Click "Add Model", set name to an image-capable model, select type "image"
  • Save settings and restart the app — the model type is now preserved
  • Previously the model would revert to text or disappear entirely on restart

octo-patch and others added 2 commits April 21, 2026 10:28
When the Jaaz API is blocked by Cloudflare or other intermediaries,
the OpenAI SDK raises a PermissionDeniedError whose string contains the
full HTML page. This gets forwarded to the frontend, showing users raw
HTML markup instead of a helpful error message.

- In _handle_error: detect HTML responses (starting with '<') and
  replace with a clear, actionable message; truncate strings over 1000 chars
- In StreamProcessor.process_stream: remove the redundant 'done' event
  since chat_service.py already sends it in the finally block

Fixes 11cafe#258
…ge/video types on restart

When adding a new model via the settings dialog, the model type was
hardcoded to 'text', making it impossible to configure image or video
models for custom providers (e.g. OpenRouter). Additionally, if a user
edited config.toml directly to set model type to 'image' or 'video' for
a custom provider, those models were silently dropped on app restart
because config_service.initialize() only preserved text-type models for
all providers.

- Add a Model Type selector (text/image/video) to the Add Model dialog
  in AddModelsList, defaulting to 'text' to preserve existing behavior
- Fix config_service.initialize() to preserve all model types for custom
  providers (not in DEFAULT_PROVIDERS_CONFIG); built-in provider behavior
  is unchanged
- Use dict() copy when reading DEFAULT_PROVIDERS_CONFIG models to avoid
  mutating the module-level default on each initialization

Fixes 11cafe#271

Co-Authored-By: Octopus <liyuan851277048@icloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

无法选择自己配置的openrouter模型

1 participant