make use of ai module

Created on 11 September 2024, 4 months ago

Problem/Motivation

Your module is tied to openai.
There is a module (the AI module) https://www.drupal.org/project/ai that provides a connector where you can easily switch to other AI providers.

Proposed resolution

Use the AI modules connector so your module is not tied to openai only.

Example image generation call via AI module


   $config = [
      "n" => 1,
      "response_format" => "url",
      "size" => "1024x1024",
      "quality" => "standard",
      "style" => "vivid",
    ];
    $tags = ["tag_1", "tag_2"];
    try {
      $ai_provider->setConfiguration($config);
      $input = new TextToImageInput($prompt);
      $response = $ai_provider->textToImage($input_prompt, $default_model, $tags);
      $url = $this->saveAndGetImageUrl($response);
Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇧🇪Belgium wouters_f Leuven

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

Comments & Activities

Production build 0.71.5 2024