Skip to content

feat: per-chat model configuration override#1291

Open
cezarlugullo wants to merge 1 commit intoagent0ai:developmentfrom
cezarlugullo:feat/per-chat-model-override
Open

feat: per-chat model configuration override#1291
cezarlugullo wants to merge 1 commit intoagent0ai:developmentfrom
cezarlugullo:feat/per-chat-model-override

Conversation

@cezarlugullo
Copy link
Copy Markdown

Summary

This PR adds the ability for users to set a custom model for individual chats without changing the global settings.

Problem

Currently, changing the chat model affects all conversations. Users who want to test different models or use a specific model for a particular task must change the global settings back and forth.

Solution

A per-chat model override that lets users toggle a custom model configuration on any chat:

  • Toggle on: the chat uses its own provider, model name, and parameters
  • Toggle off: the chat reverts to the global settings
  • The override is persisted and automatically re-applied when the chat is reloaded from disk

How it works

Backend

  • helpers/chat_model_override.py — core logic: get_override(), set_override(), apply_override()
  • api/chat_model_get.py — GET endpoint returning current model config (global or custom)
  • api/chat_model_set.py — SET endpoint to enable/disable/update the override
  • helpers/persist_chat.py — 4 lines added to re-apply override on chat deserialization

Frontend

  • A tune button (🎵) next to each chat in the sidebar
  • Opens a modal where users can:
    • Toggle custom model on/off
    • Select provider and model name
    • Configure API base, context length, vision support, rate limits, and extra kwargs
  • Built with Alpine.js following the existing modal pattern (x-data store, dynamic import)

Tests

  • tests/test_chat_model_per_chat_override.py — unit tests covering:
    • Setting/removing override data
    • Type normalization (string numbers, booleans, kwargs parsing)
    • Fallback behavior when fields are empty or invalid

Screenshots

The modal follows the existing UI style. A small tune icon appears next to each chat name in the sidebar.

Checklist

  • Feature branch based on development
  • Follows existing code patterns (ApiHandler, Alpine.js stores, modal structure)
  • Includes unit tests
  • No unrelated changes

Allow users to set a custom model for individual chats without
changing the global settings.

- Add a 'tune' button next to each chat in the sidebar
- Opens a modal where users can toggle custom model on/off
- When enabled, the chat uses its own provider/model/params
- Override is persisted and re-applied when chat is reloaded
- Fallback to global settings when custom override is disabled

New files:
- helpers/chat_model_override.py - helper (get/set/apply)
- api/chat_model_get.py - GET endpoint
- api/chat_model_set.py - SET endpoint
- webui/components/modals/chat-model/ - modal UI + Alpine.js store
- tests/test_chat_model_per_chat_override.py
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.

1 participant