---
url: 'http://workflows-of-ai.com/blog/custom-complex-fields'
title: 'Custom Complex Fields'
author:
  name: 'Marcus Johansson'
  url: 'http://workflows-of-ai.com/about/marcus-johansson'
date: '2023-11-02T09:05:52+01:00'
updated: '2026-10-10T12:14:04+02:00'
type: article
summary: 'Use AI Interpolator and the Custom Field module to split a Beef Wellington recipe into amount, unit, ingredient and instructions.'
tags:
  - 'Marcus Johansson'
  - Workflows
  - 'Drupal AI'
image: 'http://workflows-of-ai.com/sites/default/files/previews/65f048c3fb51e1c5.jpg'
published: true
og:
  site_name: 'Workflows of AI'
  'image:width': '1280'
  'image:height': '720'
  'image:alt': 'Custom Complex Fields'
---
Drupal AI

# Custom Complex Fields

Turn a recipe stored as one text blob into structured ingredient rows with amount, unit, ingredient and extra instructions.

  Marcus Johansson

November 2, 2023 · 2 min read

 ## About this video

In this workflow, the initial step is the introduction of a substantial text blob, which contains the recipe of Gordon Ramsay's renowned Beef Wellington. This text, while informative, might lack the structured format desired for easy comprehension and reference.

To address this, the Custom Field module is employed. Within this module, a complex field is crafted, tailored to capture specific elements of a recipe. The design of this complex field encompasses separate segments for the unit (e.g., grams, tablespoons), amount (e.g., 2, 100), ingredient (e.g., beef, mushrooms), and any additional instructions or notes that are pertinent to the ingredient or the cooking step.

Once the complex field structure is set up, the large text blob containing the recipe is presented to the AI Interpolator OpenAI module. Leveraging its ability to understand and parse unstructured text, the module meticulously sifts through the Beef Wellington recipe. It identifies and extracts the various components, placing each in its respective segment within the complex field: unit, amount, ingredient, and extra instructions.

The final output is a neatly structured representation of Gordon Ramsay's Beef Wellington recipe, making it significantly more user-friendly and accessible. Every ingredient and its corresponding details are organized systematically, simplifying the cooking process for those referencing the recipe.

*This video is from before the AI Interpolator module became AI Automators, part of the [AI module](https://www.drupal.org/project/ai). Module and menu names have changed since, and some steps look different today.*

## Watch the video

[Watch on YouTube: Custom Complex Fields](https://www.youtube.com/watch?v=agO-1e6iCJ4)

### Video chapters

- 0:00 What the Custom Field module does
- 1:32 A recipe stored as one blob
- 2:32 Modules you need
- 3:15 Building the ingredients field
- 5:38 The custom field rule prompt
- 6:46 One-shot examples per subfield
- 8:17 Running it on Beef Wellington
- 9:29 Checking the extracted ingredients

## Transcript

YouTube's automatic captions, lightly corrected. Click a line to jump to that moment in the video.

### Transcript

- 0:01 hi there uh Marcus here today we're going to talk about uh how you can integrate custom Fields uh using the uh AI Interpolator OpenAI module so the custom Fields
- 0:15 module uh is an uh external module it's not part of core so what this does is basically it creates a complex field uh for your uh use case so I mean there are many comp field like uh Geofield the
- 0:32 location Field address field and stuff like that that has multiple values right uh but they are usually for one use case so what this does is it it creates it for the use case that you want that
- 0:45 there might not be a a module taken care of for Drupal right um and it does it in a way where it doesn't create a new entity so it's not comparable to paragraphs for
- 0:58 instance where you would create a new new entity uh for for the uh complex field basically uh this also means that it's if you add one uh unit of it it's just stored in one table right it's the same
- 1:13 if you add multiple it's still just one table uh which is very good from performance reasons um so while Drupal's entity system is super it's it's not very performant when you start nesting down a
- 1:28 lot of uh empties so this is a very good solution for it uh the example I will give today is that I basically have a recipe here and it's just a Big Blob so this is Gordon
- 1:40 Ramsay's Beef Wellington so it has just stored everything as one big text field where we have the ingredients and we have the uh uh instructions and in this case we maybe want to split up the
- 1:55 ingredients so we actually uh store it in basically in amount uh unit ingredient and extra instructions right uh because that way we can make it transformable so we can do something
- 2:13 like if you look here at 750 m beef stock we could uh add a converter so if someone comes from USA they can uh convert this then from metric units into in this case cups I guess and see uh
- 2:29 their units um so before I start this is tro p uh with AI Interpolator module and in this case we have installed the custom field module then it's required for this rule
- 2:43 to kick in uh everything is open source everything is free you can download it after you watch this instruction video um it's uh there's going to be descriptions in the uh there's going to
- 2:57 be links in the video descriptions that you can use basically Al to figure out how to use Drupal how to set it up and so on but that has not come yet I I hope I will find time for that soon so we start
- 3:09 by logging in and then we're going to go to the recipe um a recipe um content type that we have you can see here then we have just one big text long uh for the recipe so what
- 3:28 we're going to do now is create a new field uh that is a custom field then that we call the ingredients oh we have it here already and we're going to add four o
- 3:41 four different um Fields here so that's what I'm adding here add another uh where the first is uh no the first is amount and that should of course be then a float because we don't
- 3:58 know if there's going to be uh commas in there uh the next one is unit so something like deciliter look up and uh then we have the \[Music\] ingredient and then extra instructions right should be
- 4:21 underscore instructions uh and this can be unlimited because ingredients you can add many of course right right so it's going to create one row of each of this for each ingredient that we saw in this
- 4:37 content uh then we come to the settings page and here is very important because this set settings the time when I save this the AI Interpolator is not just uh uh
- 4:52 aware of um how how this is built up and I actually see error now so I'm going to do this it's not going to be text long it should be text plain we just want 255
- 5:09 characters extra instructions could maybe be longer but I I keep it at text plan right now so anyway this means you have to save it and then go back to edit it and
- 5:20 then it's aware basically of uh which Fields exist because this is very important for the AI Interpolator because we're going to use one shot learning here so that's basically
- 5:31 instructing OpenAI an example what can be in this field and this generates a lot better output so we're going to take the AI Interpolator and use the custom field
- 5:43 rule uh we're going to base it on their recipe right uh and then we're going to do based on their reci uh get all ingredients so this is the prompt now then and split them up in
- 6:05 amount uh unit ingredient and extra instructions uh and then we write recipe and then we use the context so this context then is going to um basically add uh the recipe under
- 6:30 here and that's the prompt that goes in but then under advanced settings we're going to have to fill out now uh oh maybe I need to save here I didn't click save here before so it wasn't aware I'm
- 6:43 going to click edit again and then it's going to show up now hopefully yeah so you see here now basically that it has um added a lot of field so this is first of all it is an text ual description
- 7:00 what's supposed to happen in the amount field so there we write uh the numeric amount of units so we take two for instance uh the unit and that could be a cup ingredient
- 7:25 uh the ingredient floor and uh extra instructions extra instructions or preparations uh and therefore the floor it could be uh uh yeah what could it be uh sifted
- 7:50 should be sifted right um I'm not a native English speaker but I hope that's the correct term uh then we take GPT 4 here you all you more or less want to take GPT 4 here always because it's very
- 8:07 this creates a very complex prompt in the end that basically creates JSON output and that's the uh way we can read this complex output then we save this we don't I don't think
- 8:20 we need a roll here uh and then we go to the beef wellington we see that we have the custom field here then where we could manually fill it out now that but we're going to just save and hopefully
- 8:32 this will be able to basically read ingredients and fill this out for us uh and then we have this complex field fill out um oh I I didn't put on uh uh batch mode
- 8:48 like I usually do when I do this instructions so you don't see actual progress now but it shouldn't be that slow I think yeah it takes some time so I don't do any video editing in these uh videos
- 9:18 because I basically want to show you actually what how long time it actually takes to uh use any of these fields so you get a a sense of it there we go so if we click on it now we
- 9:32 should have under here well this doesn't look very nice we would have to style this of course but you can see here two tablespoons of olive oil so that's what we have here
- 9:45 right um and then we should take the beef trimmings because that has extra instructions so we have 200 gam of beef trimmings extra instruction ask the butcher to reserve these when the when
- 9:57 trimming the fet so and we can just check the forms as well so you can see it there as well that it fills out everything right uh and you can see here four large
- 10:09 shots there isn't a unit because they are just shots right uh so that's basically how you use the custom field to uh output complex fields from uh some text block uh yeah thanks for
- 10:27 watching

  Filed under [Workflows](/blog?category=6) [Drupal AI](/blog?category=2)

Parts of this content were produced by AI.

This site has not assessed whether a label is required for this content.

  How was AI used?The video and the introduction are Marcus's own, first published on workflows-of-ai.com. AI wrote the subtitle, the summary and the video chapters from the transcript, and corrected misheard names in YouTube's automatic captions.

   Marcus Johansson

Tinkers with AI and Drupal

 [About Marcus](/about/marcus-johansson)[Drupal.org profile](https://www.drupal.org/u/marcus_johansson)[Drupal AI](https://www.drupal.org/project/ai)

## The post in three sentences

The Custom Field module stores multi-value complex fields in one table without extra entities. Marcus adds an ingredients field with amount, unit, ingredient and extra instructions subfields, then uses the AI Interpolator custom field rule with GPT-4 and a one-shot example per subfield. Saving the Beef Wellington recipe fills in one row per ingredient.