0:00
This video is sponsored by FreelyGive. Uh if you need help with group or any please get in contact with us. Uh I'm going to showcase a very simple agent but uh I'm going to showcase some of the
0:17
most maybe important tools that you can be using in Drupal to actually create content. So what we're going to do is create a agent that can create one specific content type
0:30
um and also has access to actually reading PDFs. So we're going to have like a PDF like this title some information and we're just going to run an agent where we say could you look at
0:42
the restaurant Tim on the PDF of the file this and we just show you here there's many uh restaurant then but it's going to be able to you know select it run it and actually create a version of
0:56
the content for this. So, if we go to the content and reload, we're going to see there is a Tim Raue here that has set up the correct phone address, uh, pricing, description, and
1:11
so on. So, let's go. Hey everyone, it's been a while. Um, I've been busy with one or two preparations, but now I should hopefully be able to start creating videos all the
1:23
time. Um today we will show uh a simple agent that can take a PDF and generate content from it. Um it will be based on uh on modules that doesn't require infrastructure. So we're
1:41
going to use something called AI Simple PDF to text. Um this has two things. Uh so it can create automated rules. Um I'm going to showcase this in a second uh in
1:52
some video later where you you know can create a chatbot talk to your PDF content. Uh but it also then has a function call uh that you can use. I'm also going to show uh the Tool API. So
2:07
this is the first time I show the Tool API. I will say that the Tool API is the way uh to solve things going forward for functioning calling as well. If you want
2:19
to create a function call, you should always consider using Tool API instead for the simple reason that it creates a function call. But whatever you do will also in the future be available in ECA.
2:31
You see Jürgen is one of the maintainers there. Uh uh Views Bulk Operations and it's it's it's a more structured way of uh doing tools. also solves uh the problem with security of creating
2:50
generic tools. So my recommendations going uh so far has been basically create a function call that solves your issue because that will make the agent more reliable
3:04
uh and it will be more secure. But of course you might end up with uh hundreds of function calls then and a lot of function calls that are basically just iterations of other function calls. So
3:16
the idea is here to create more generic tools that you can reuse over and over and that's not saying you can use Tool API to solve your specific uh uh u problem anyway.
3:31
uh of course so the it's a plug-in system if you know how to write function calls you will know how to write Tool API it's not that different uh I also want to just give a huge shout out so
3:43
Michael is the main maintainer he has done like 99% of the work on Tool API uh or even 100% maybe uh and he's actually uh looking for a position right now uh if you want someone someone who knows
4:00
Drupal and AI that combination and is has a much stronger Drupal knowledge than me. I would recommend him uh highly recommended.
4:11
So I will just show the modules I have installed. So what I have installed already is the agent framework AI module. I've set up OpenAI in this case but use any provider you want. uh uh uh
4:25
uh I mean if you if you use smaller models you might not get the same result of course. Uh then I have installed the tool uh tool AI connector and for the 1.0 uh 1.x X branch in AI you're going
4:39
to have to use AI connector for two it might just work without it let's see that's a decision still to be taken you can look in the issue if you have uh opinions about this and tool content and
4:50
tool entity and then I have also installed the AI Simple PDF to text all these modules you just have to install and that's it they're going to be available I have created a content type
5:03
that has address description phone price website and a title and it's called restaurant and I'm going to showcase this is the PDF then that I have and the idea is that I can tell it hey look at
5:14
this PDF uh and import Burgermeister for instance create a content around Burgermeister but not the other ones uh oh I oh wait I added that we need to install media module as well so it is a
5:33
little bit clunky now we're trying to solve how you can actually upload non-im images into an agent and assistant. Uh for now, the tool takes a URL URI or a file ID.
5:48
Uh so we're going to use file ID in this case. So we're just going to add a document here.
5:55
Uh which we have here. So we're just saving this restaurant. Uh uh so we know can look in the files and this has a file ID here that is 25. We can just use this when we're uh talking. So we go to
6:17
configuration AI AI agent. That's where you can add a agent. And we're just going to uh create then the uh rest creator agent.
6:29
Um this agent can create notes on type restaurant. Um we set like 10 loops. Now we can say 20 loops. Maybe you want want to import like I don't know you want to import 20
6:50
restaurant setup in one go. Then you might need a lot of loops actually. uh agent instruction. We're going to improve this as we go along. Uh but we just start with you are agent
7:07
that is expert on creating creating content on the node type restaurant in Drupal.
7:24
Um let's just start there. Uh um and going to add more things as we go along. Uh the next thing we need to do is add tools and these then the Tool API comes with a
7:46
lot of tools. Uh what we need to add here are um we need to add see here uh we need to add save entity.
8:07
We need to say set get fields values uh and we need to create the entity as well.
8:20
Where is it? Create create unsaved entity. Right? This is what we want to do. So how this works is it's creating an unsaved entity.
8:34
Uh so that just becomes a placeholder. So that you can think of that similar to how you open the no creation form. Uh oh, get field values is important if we want to update this actually set field
8:48
values. So get field values would be important if we want to create so the agent also can update one of the nodes then if we want to uh maybe we can add that right away just to showcase that as
8:59
well. Uh so what's happening is going to do the create unsaved entity. Then it's going to start adding field values similar to how you add the field values on the form. But it's not until you
9:10
actually save the entity it actually saves it. Right? Uh and the important thing here is of course it needs to be able to see how to create this.
9:22
So what is the actual structure for this? And this is uh uh what we need here is get field information. we can just test the tool. So if you have the API explorer uh enabled, you can just
9:34
test it. So we can just test node restaurant just to see this is what the uh uh agent is going to see. But what we can do in this case is that we don't necessarily actually need uh to
9:50
uh uh we don't necessarily need to uh you know run this in a loop because we know we always need to get the field information about the how to save our restaurant because the only thing this
10:05
is going to be concerned with is actually creating restaurants and because of this we're going to use then the default information to us. Um, and this is something where I mean the whole
10:18
thing here we're we're working on improving how it's working. There's a UX group uh uh for this. If you're interested in joining those conversations if you know like um how
10:30
this can be worked then just you know there is AIUX channel in Slack or you know contact us. We need all the help we can get how to make those stuff better.
10:41
So, we're going to say get restaurant information. Uh, this is just a unique key. Doesn't matter. The AI is not aware of it. What it is aware of is this um field information
10:59
restaurant. Uh, and a description. This is the information about how you create the fields for the rest of node types and the tool AI we can get tool ID we can get here then so it's
11:21
this you see it's URL encoded colon there but is this and the parameters you can also get here that's this so we just set this to node uh and bundle should be restaurant
11:42
and then this whole thing is going to be uh saved into memory. So the agent is always aware of that it's always part of the memo. So we don't need to tell it to
11:54
use this. The other things are of course dynamic because if a if you uh tell it to um tell it to I I don't know create uh create an article shouldn't really use all of this. It
12:14
should just tell you that that won't work. Oh, I realized we also need to be able to load uh uh load entity by ID because if we're going to be able to edit, we also need to load a entity that
12:30
exists. So the important things now before this is built into Tool API is that we need to constrain this.
12:39
So it's very important that you say say that the entity that can be saved should have a forced value of node. You should just be able to so save nodes with this.
12:52
Uh it would be very very bad especially load and save if it could load a key instance for instance your API keys or something and save those right. So we need to constrain the same thing here.
13:08
Uh and here we can go e uh no we just set the entity type ID entity ID it should be choose itself of course.
13:18
So what you're saying here is basically some of these things we don't really want um the AI to take a decision about. Uh it should just uh uh always be node in this case.
13:36
uh and in this case we're also going to set node. So set the field value and you should just be able to create uh uh oh sorry this should be restaurant of course. So you should just be able to
14:00
create a restaurant. Save this. This is not going to work, I think, yet because we didn't give it any instructions.
14:09
Uh, and we Oh, I forgot the tool. Of course, if we're going to read a PDF, well, we can try this first just to see if it's anywhere close to actually being able to create something.
14:23
Uh, could you create a new restaurant title? Hello. and the description cool because no uh nothing except title was required I think. So this should in theory maybe actually work.
14:45
So it creates tool entity stuff then is that it actually creates a version. It sets a value. Oh so okay save tells it it saved it and if we go to content it actually probably just worked. Yeah we
14:58
created a hello restaurant with a description. Cool. That was actually worked better than I thought. Um, so anyway, let's let's see how much we actually need to shape it. So, what we're going
15:15
to do here is we're going to add uh then the simple PDF reader. So, simple PDF to text.
15:25
Okay, just try it just for fun to see if we might not actually need to write such a big system pump. So now I have of course forgotten the uh uh 25 it is.
15:38
Could you look at the rest Burgermeister in the PDF of file ID 25 and generate it? Let's see. I think the address field the address field might be so complex that it actually needs some
15:58
help there but it will still be interesting to see just to try it out without actually writing something.
16:05
So, it seems to actually incredibly enough uh work. Well, it's seems like it's failing when it's trying to save the website.
16:25
I wonder why it doesn't allow it to save. So, you see it's trying to resave and resave until it can set it correctly. So, here it worked.
16:35
So, it actually probably need uh some system prompt to how to save the URL URI at least if we're going to make it uh work better. But let's just start with checking here if this actually work. No,
16:49
this didn't work. Uh okay, it can't solve the link. Requires that the link title not be null.
17:04
Okay, I'm just going to see how we set this up first. I actually thought I said that the link title is not needed on this case.
17:15
Uh, it's disabled, so it should not be needed. Uh, let's see here. UI can see it's actually trying everything here to try to figure out how to fill it in. But this might be uh I mean this
17:35
might be a problem in the actual tool rather than the agent being wrong because what but I can see it's actually doing everything correct. I know it you shouldn't be able to save a title so
17:52
that shouldn't work but this should work. Um just to see so everything else works first.
18:01
uh do not include the link. So, uh while we're doing this, I'm just going to showcase uh a module here that's super important when you're doing this because uh you know, I talked a lot about the
18:22
automators and the automators kind of just works when you have a feeling that it works.
18:27
uh when you feel like I mean if you run it like 50 times it just works it kind of works and you know there might be edge cases that you run into when you go into production that you have to fix but
18:40
mostly it works this is not true for agents and this is something we saw when we created the Drupal CMS agents that it's very hard to test them because you can be as expressive as you want
18:54
it's a free text field where you write anything to them. So you you have to try to think of all the use cases people will use them for, but you will not be able to think of all
19:06
of them. So you're going to have to improve them. So we have this module AI agents test and you should install it.
19:13
Basically what you can do there is you can uh run tests against your agents over and over and over and over to see that they are doing the right decision based on instructions memory. So you
19:29
might have a long chat history and so on. Um because of this I I would just recommend using it. That's the only way you can get something that's you know getting close that is like production
19:41
ready that solves most of the things. Of course you can talk about a restaurant creator agent for your use case. You could maybe even you know do this do not include link. Uh so
19:55
let's see if this worked better. Okay, so now it worked because it didn't have to create the website then. Uh, and it did fill in. Okay, we have first name, last name there, but it was smart
20:10
enough to actually figure out that it shouldn't uh fill that in. Janalia 45 10435 Berlin one star.
20:23
Uh this description they copied phone worked. So it's working now actually except for the link and this might uh might be something that we have to create an issue for actually to be
20:41
honest. Um let's see. Um yeah, I will end this uh video cast here because I think I have shown the most important things. I will just do a heads up here because this is
20:58
the first time I showcase how you can create I mean with automators of course you can create content and you can extrapolate stuff uh so you know start from a small title
21:13
and write a long description or something for that AI just creates lot from this this is super important uh and I know you know there's there's just going to be people that's using it
21:26
for this and that will you know it's a race to the bottom because all the tools that has AI will do this but I would just urge you use this to interpolate take a lot of big content and summarize
21:43
this this is something AI is actually good at it creates good content from this anytime you try to extrapolate when where the AI is the one that actually write the content
21:54
It's crap. It's crap. Don't use this. This becomes AI slop. This is the dead internet where, you know, we're just flooding the internet with too much information
22:06
that no one will read. It will just be AIS that reads this in the future. That's just a waste of resources. So, please don't do it for the this. There are hundreds of use cases where this is
22:18
useful but you know creating another sloppy website where you didn't write anything is not one of them. So please don't use it for this. Um yeah, thank you for watching.