Create new action for simple provider setup

Created on 19 December 2024, 3 days ago

Problem/Motivation

When setting up the AI module within a recipe, the problem always arises that a lot of the functionality is dependent on there being a setup provider available and a default operation type for what the 3rd party module is trying to achieve.

We have this issue in Drupal CMS and tried to fix it by creating the AI Simple Provider Installer, where it would take care of this post install. This had one general issue on how to make the link available for it and it also made it necessary for 3rd party modules to have a graceful fallback, so they will not break just because a default provider is not set.

There is now a way of using input variables Make it possible for recipes to prompt for input values Fixed in D11. This works well in terminal and will soon be available when applying a recipe in the GUI as well.

On top of that there are custom action plugins for recipes, meaning that the AI core module can add a custom action plugin for recipes that will take care of:

  1. Creating the key entity from an api key.
  2. Linking the key to a specific configuration key.
  3. Allowing the user to change the default models for operation types for a provider.
  4. (or) allow the provider, as is at the moment, to apply to be a default provider for an operation type.

Proposed resolution

  1. The AI Provider creates a new action plugin called setupAiProvider
  2. The action plugin can take optional key_config_key, that is the config key to attach a generated key entity to.
  3. The action plugin can take optional key_value, that is the value to store in the keys entity. This is required if key_config_key is set. It will store as configuration.
  4. The action plugin can take optional default_models, that is an object of key/values, where key is one of the operation types and value is the model to set.
  5. The AI Providers base class will also introduce an optional method for the provider to set these, which will be used if nothing is set above.
  6. Document the above action.

Example of integration

input:
  api_key:
    data_type: string
    description: The OpenAI API Key if you want to use OpenAI.
    prompt:
      method: ask
      arguments:
        question: 'Please provide your OpenAI API Key:'
    default:
      source: value
      value: ''
config:
  actions:
    ai_provider_openai.settings:
      setupAiProvider: # The new action
        key_config_key: api_key # The (optional) config key that should take the keys entity id.
        key_value: ${openai_api_key} # The (optional) value to take.
        default_models: # The (optional) default models for operation types
          chat: gpt-4o
          text_to_image: dall-e3
      simpleConfigUpdate: # This is to set other configurations
        moderation: true

So as example for something like Ollama that doesn't set key entities, you could do

config:
  actions:
    ai_provider_ollama.settings:
      setupAiProvider: [] # This just makes sure that the default operation types are set, if any
      simpleConfigUpdate:
        host: localhost
        port: 11343
Feature request
Status

Active

Version

1.0

Component

AI Core module

Created by

🇩🇪Germany marcus_johansson

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

Comments & Activities

Production build 0.71.5 2024