Add AJAX functionality to dynamically update fields based on provider and model

Created on 7 May 2025, 2 days ago

Problem/Motivation

The AI Media Image module currently doesn't dynamically update configuration fields when switching between different AI providers or models. When a user changes the AI provider or selects a different model, the configuration options (like image size, response format, etc.) don't update to reflect the capabilities of the selected provider/model.

This is particularly problematic when switching between models that support different image sizes (e.g., DALL-E 2 vs DALL-E 3), as users may be presented with incompatible options.

Proposed Solution

This patch implements AJAX functionality to dynamically update the form elements when changing providers or models:

  1. Adds AJAX callbacks for both provider and model select fields
  2. Updates the model options when the provider is changed
  3. Updates configuration fields like image size and response format based on the selected model
  4. Adds special handling for provider-specific options (OpenAI and Stability AI)
  5. Includes proper error handling and logging

Benefits

  • Improved user experience with dynamically updated fields
  • Prevents errors from submitting incompatible configuration options
  • Maintains parity with similar functionality in the ai_audio_field 🐛 C Active module
  • Ensures proper defaults are selected based on the capabilities of each model
Feature request
Status

Needs review

Version

1.0

Component

Code

Created by

🇰🇬Kyrgyzstan dan_metille

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024