Unlock the Incredible Diversity of Robust AI-Driven Workflows with the AI Interpolator Module in Drupal

Jun 28 2024

Authored by Nadiia Nykolaichuk.

It seems like yesterday that people started cautiously embracing artificial intelligence with admiration, surprise, or even fear. Technology rushes forward, multiplying the number of potential ways to use AI on your website to streamline your workflows.

You might be amazed today as you discover what is possible with a relatively new Drupal module — AI Interpolator. It has a huge ecosystem of integrations and a jaw-droppingly wide range of potential features. The module helps you harness AI to generate realistic voices, make stunning visuals, perform deep analysis, easily convert multimedia between formats, and much more. 

AI Interpolator is destined to be a great addition to the golden collection of key Drupal modules for AI integration. Previously, we have explored the two other flagship Drupal AI tools, walking you through the steps of setting up the OpenAI and Augmentor AI modules. Now it’s time to dive into what AI Interpolator has to offer. As a treat, we’ll also show in detail how to use the module for generating an image gallery with the DALL-E artificial intelligence tool.  

Getting acquainted with the AI Interpolator module for Drupal

The AI Interpolator module offers a versatile and user-friendly approach to setting up AI-driven workflows on your Drupal website. You can set up any workflow you can imagine, and all of this is possible with no coding.

AI is the talk of the town, but actually non-AI tools can also be involved in these workflows. The module has the word “AI” in its original name but its use cases have become broader with time. That’s what the module’s creator Marcus Johansson said in his video demoing the module. 

Field-based transformation

The main magic of the AI Interpolator module happens in Drupal fields. The input from one field gets processed with AI modifiers and goes into another field in a different format. This is what is referred to as interpolation. For example, a long text turns into a brief summary or transforms into an image. 

Chaining steps into workflows

The module enables you to create workflows of any complexity by chaining multiple steps together. The AI Interpolator module borrows this idea from the Langchain language model integration framework. However, as the module’s maintainers particularly emphasize now and again, the AI Interpolator module is a site builder tool, so, as opposed to Langchain, it doesn’t require coding skills.

A huge ecosystem of integration modules

The AI Interpolator module does not connect you automatically to any AI tool — it functions as an API that other modules can hook into. That being said, it requires additional modules for specific functionalities. The number of integrations that can be used in AI Interpolator workflow chains is impressively vast and keeps growing. Currently, the following are listed on the module’s page:

In addition, anyone can write plugins for AI Interpolator to integrate any service you need with your Drupal website.

An impressive choice of possible tasks

Based on the above-listed tools and services, and the exciting examples from the AI Interpolator demo website, the number of available tasks will surprise even the most seasoned AI engineer. It’s probably easier to imagine what you cannot do with it.

Tasks possible with AI Interpolator include (but are not limited to):

Creating and optimizing text content:

  • generating articles in CKEditor from images or videos
  • summarizing long text
  • rewriting text for accessibility criteria
  • analyzing text and rating the sentiment on a scale of 1 to 5
  • checking facts in content and only publishing the content if the facts are true
  • translating text content into different languages
  • creating content by extracting information from PDF, PPTX, DOCX, XLSX, MD, JPG, PNG, and other file formats

Creating and optimizing images:

  • generating header images from the article text
  • removing image backgrounds
  • creating images based on text descriptions
  • generating image galleries
  • upscaling images (increasing their resolution, making them larger and clearer, and eliminating pixelation)
  • categorizing images
  • finding stock images based on the article text

Creating and optimizing audio and video content:

  • creating automatic podcasts from URLs, text, or audio
  • generating characters talking on video
  • generating realistic voice content
  • generating a natural audio dialogue from PDFs
  • creating audio versions of articles
  • searching videos for specific elements and cutting videos like a pro editor
  • optimizing audio files by reducing noise
  • improving Drupal media (images, audio, or documents)
  • creating descriptions and summaries of videos
  • answering questions about videos
  • creating transcripts for audio
A screenshot of an AI-generated video where the module’s creator talks in rhyme about the history of AI.
A screenshot of an AI-generated video where the module’s creator talks in rhyme about the history of AI.

Boosting SEO:

  • deep-crawling websites on the Internet
  • auto-generating tags from images and text
  • auto-populating taxonomy terms into the “Tags” field
  • using Google’s search results to find relevant web pages and then “scrape” them — extract useful information from them (disclaimer: the website's terms of service should be checked first)

And more:

  • creating automated workflows based on events and conditions with the ECA module
  • converting documents between different formats
  • finding locations from text and auto-populating maps
  • using free resources like Wikipedia to answer questions

Efficiency and accessibility in one tool

Of course, the first thing that comes to mind when looking at all those capabilities is that AI Interpolator primarily streamlines content management, raising its efficiency sky-high. And this is definitely true (of course, with a careful and ethical approach).

But there’s also another area for AI Interpolator to shine. Considering plenty of options for converting content from one format to another, just imagine how much can also be achieved in the realm of creating accessible content. In particular, this is essential for multimedia accessibility. Subtitles, transcripts, captions, and audio descriptions ensure that a diverse audience can enjoy multimedia, regardless of whether they need a visual or aural alternative.

AI Interpolator in action: a guide to generating an image gallery with DALL-E 3

It’s time to take a more detailed look at how you can put AI Interpolator to work. However, it’s a real challenge to choose only one example from the huge collection of videos by Marcus Johansson on the earlier-mentioned module’s demo website.

Let’s choose a colorful one that might be a common case for many teams — generating image galleries with DALL-E 3. The gallery will be based on an article about the 2024 Olympic Ceremony in Paris. 

DALL-E 3 is a famous tool by OpenAI for creating images from textual prompts. A prompt is the input text (question, request, or additional information) that a user provides to the AI to generate a response. So in addition to DALL-E, this example setup will include tools for creating textual prompts — OpenAI and PromptPerfect.

The planned workflow

  • OpenAI creates prompts. First, OpenAI will be asked to generate 4 image prompts that visualize this article. 
  • PromptPerfect improves prompts. Although prompts by OpenAI are usually fairly ok, the result is actually more visually stunning if you also use the PromptPerfect tool, says Marcus Johansson.
  • DALL-E 3 creates images. Next, DALL-E 3 will process the improved prompts to generate images.
  • Slick Carousel arranges them as a carousel. Finally, the Slick Carousel, one of the top Drupal modules for image carousels, will create a carousel with the images. 

Installation

You’ll need to install and enable all the modules involved:

The recommended way to install the modules is via Composer. This is especially important for the Slick Carousel module which will only work properly with the libraries. 

Setting up the API keys

Of course, you’ll need your own accounts with all the AI services you’d like to use with AI Interpolator. You can add their API keys in the Drupal admin dashboard:

  • for PromptPerfect: at Web Services > PromptPerfect Config
  • for OpenAI: at Configuration > OpenAI

Configuring field #1: the pre-prompt field

Go to Structure > Content types > Article > Manage fields > Add field, create a field of the “Plain text long” type, and name it “Pre-Prompt.” This is the initial prompt that OpenAI generates from the article. 

Creating a text field for pre-prompts.
Creating a text field for pre-prompts.

Proceed with the field settings. Set the allowed value number to 4 since the plan is to generate 4 images for the gallery.

Check the “Enable AI Interpolator” checkbox at the final part of the field settings page. In the “Choose AI Interpolator Rule” dropdown, select “OpenAI String Long.”

Configure the AI Interpolator settings:

  • Interpolator Input Mode: Base Mode.
  • Interpolator Base Field: Body. 

This means OpenAI should use text from the article’s body.

  • Interpolator Prompt: “Based on the context, create 4 one-sentence prompts that visualize the context of the article. Make the images abstract and in an oil canvas.” Use placeholders in the prompt like ‘{{ context }}’ by copying it from “Placeholders available” right below the prompt.
AI Interpolator settings for the Pre-Prompt field.
AI Interpolator settings for the Pre-Prompt field.

Open the advanced settings and configure the following:

  • Interpolator Worker: Batch mode

The direct mode takes all the AI chaining and tries to do everything with one request, and the batch mode uses JavaScript and splits things up. If you generate 30, 40, or 50 images, this will take some time that even the batch mode might time out, explains Marcus. 

  • OpenAI model: GPT-4 Turbo Preview
AI Interpolator advanced settings for the Pre-Prompt field.
AI Interpolator advanced settings for the Pre-Prompt field.

Configuring field #2: the “Image Prompt” field

Create another field of the “Plain text long” type and name it “Image Prompt.” This is the field for the actual prompt that appears as a result of the initial prompt being improved by PromptPerfect. Like with the previous field, set the value number to 4.

Check the “Enable AI Interpolator” checkbox at the bottom of the page. In the “Choose AI Interpolator Rule” dropdown, select “PromptPerfect Prompt.”

Configure the AI Interpolator settings:

  • Target Model: DALL-E 3

This means the improved prompts will be created for DALL-E 3 to further generate images on their basis. 

  • Iterations: 2

Two iterations are used in the example for the demo simplicity, but according to Marcus, a larger number of iterations should create even better prompts. 

  • Interpolator Base Field: Pre-Prompt

This means PromptPerfect takes the pre-prompt and generates a better prompt on its basis.

AI Interpolator settings for the Image Prompt field.
AI Interpolator settings for the Image Prompt field.

Open the advanced settings and configure the following:

  • Interpolator Weight: 101

The weight of the prompt needs to be higher than the weight of the pre-prompt, which was 100. If there are fields depending on each other, you can order their processing via weight. The higher the value, the later it will be processed.

  • Interpolator: Batch mode
AI Interpolator advanced settings for the Image Prompt field.
AI Interpolator advanced settings for the Image Prompt field.

Configuring field #3: the “Gallery” field

Create a field of the “File upload” type. This field type has options, so select one for uploading images. Name the field “Gallery.” This will be the actual gallery for images generated by DALL-E.

You can safely set the number of allowed values in this field to unlimited since you can also add your own images to the gallery, explains Marcus.

Check the “Enable AI Interpolator” checkbox at the bottom of the page. In the “Choose AI Interpolator Rule” dropdown, select “DALL-E 3.”

Configure the AI Interpolator settings:

  • Interpolator Input Mode: Base Mode
  • Interpolator Base Field: Image Prompt
  • Interpolator Prompt: ‘{{ context }}’ 
AI Interpolator settings for the Gallery field.
AI Interpolator settings for the Gallery field.

After opening the advanced settings, configure the following:

  • Interpolator Weight: 102 
  • Interpolator Worker: Batch mode
  • DALL-E Engine: DALL-E 3
  • DALL-E Quality: Standard
  • DALL-E Size: 1792x1024

The 1792x1024 resolution has been used in the example because it’s good for the future image gallery and also because it’s not the largest one so generating images shouldn’t take too much time in the demo. Feel free to choose HD for the best quality.

  • Dalle-E Style: Vivid
AI Interpolator advanced settings for the Gallery field.
AI Interpolator advanced settings for the Gallery field.

Customizing the field display

Go to Structure > Content types > Article > Manage display and hide the prompt fields from being displayed on the front end. You can do it by just dragging them to the “Disabled” section.

Drag the “Gallery” field to the top and hide its label from users. Set the “Gallery” field’s format to “Slick image” by selecting it from the dropdown menu.

Customizing the field display for the AI-generated gallery.
Customizing the field display for the AI-generated gallery.

Configuring the Slick carousel

The gearbox next to the “Slick image” format opens the carousel settings. Based on this example by Marcus, you can configure them as follows (or do your own Slick setup):

  • Display Style: Flexbox Masonry
  • Skin Main: Default
  • Skin Thumbnail: Thumbnail asNavFor
  • Thumbnail Style: Thumbnail 100x100
The Slick carousel settings for the AI-generated gallery.
The Slick carousel settings for the AI-generated gallery.

Setting AI in motion — generating the gallery

The most exciting moment of this guide is approaching. As you go to “Content” and open the article about the Olympic Ceremony, you’ll see all the fields you’ve created. They include 4 instances of the pre-prompt field, 4 instances of the image prompt field, and the gallery field with a button for downloading image files.

Everything is currently empty because the processing has not started. Click “Save” for the article — and the interpolation will start. 

Clicking “Save” on the content editing form to start interpolation.
Clicking “Save” on the content editing form to start interpolation.

You’ll see the progress bar for how AI Interpolator processes all the steps of the setup.

AI interpolation in progress.
AI interpolation in progress.

Once the interpolation is done, the article is there with the image gallery of the Olympic Ceremony in Paris. They are pretty abstract as asked by AI in the prompts. 

An image gallery generated by DALL-E 3 for the article about the Olympic Ceremony.
An image gallery generated by DALL-E 3 for the article about the Olympic Ceremony.

As you come back to the article editing form, you’ll see the pre-prompt and image prompt fields already filled out.

The filled-out prompt fields in the article editing form.
The filled-out prompt fields in the article editing form.

Final thoughts

As Marcus emphasized now and again in the demo, this setup might have been a little simplified and abstract just to give you an idea of how to work with AI Interpolator, and at the same time make the presentation faster. You can write your own prompts specifically for your website’s goals, set the image quality to the maximum, create your own interpolation chains, connect your preferred AI tools, and so on.

AI is here to stay. Ready to dive into its exhilarating world and create unimaginably cool setups on your Drupal website? Drop us a line to share your thoughts about it! 

Learn from us
Sign up and receive our monthly insights directly in your inbox!

Subcribe to newsletter (no spam)

Fields