PHP feat admin

Centralized AI Model Selection in Breniapp

This post details the implementation of a centralized AI model selection feature within the Breniapp project.

The Feature: Default AI Model Configuration

Breniapp now allows super administrators to define default AI models for different content types (text, image, video) at the platform level. This provides a centralized configuration point, streamlining the model selection process and ensuring consistency across the application.

Implementation Details

The default model selections are stored within the credit_settings table. The ContentGenerationService utilizes a priority-based system to determine which AI model to use:

  1. User-specific selection (if available)
  2. Database default (from credit_settings)
  3. Environment configuration
  4. First active model (as a fallback)

This layered approach offers flexibility while guaranteeing a functional default.

Configuration Example

While the admin interface provides a user-friendly way to manage these settings, the underlying logic relies on retrieving and applying the configured defaults. Here's an illustrative example of how the default model might be retrieved in PHP:

<?php

namespace App\Services;

class ContentGenerationService
{
    public function getDefaultTextModel(): string
    {
        // Retrieve the default text model from the app_config table.
        $defaultModel = AppConfig::where('key', 'default_text_model')->value('value');

        return $defaultModel ?? 'default-text-model'; // Return the model or a hardcoded default if not found.
    }
}

In this example, the getDefaultTextModel function retrieves the configured default text model from a generic app_config table. If no default is found in the database, it falls back to a hardcoded default to ensure that a model is always available.

Benefits

  • Centralized Management: Simplifies model selection and ensures platform-wide consistency.
  • Flexibility: The priority-based system allows for user-specific overrides and fallback mechanisms.
  • Maintainability: Configuration is stored in the database, allowing for easy updates and version control.

Conclusion

By centralizing the AI model selection process, Breniapp enhances its flexibility, maintainability, and user experience. The layered priority system ensures that the most appropriate model is always selected, whether configured at the user level, platform level, or via environment settings. This new feature provides a robust and scalable solution for managing AI model configurations.

Centralized AI Model Selection in Breniapp
GERARDO RUIZ

GERARDO RUIZ

Author

Share: