---
title: "Custom Complex Fields"
video_id: agO-1e6iCJ4
url: https://www.youtube.com/watch?v=agO-1e6iCJ4
workflow_page: https://workflows-of-ai.com/workflow/custom-complex-fields
language: en
captions: generated
---

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