---
title: "AI Module #2"
video_id: LFFoGfYFMn4
url: https://www.youtube.com/watch?v=LFFoGfYFMn4
workflow_page: https://workflows-of-ai.com/workflow/ai-module-2
language: en
captions: generated
---

0:00 as always these videos are sponsored by
0:02 freely give freely give pays my salary
0:04 and I can do a lot to the AI Community
0:07 for this um we have Drupal and AI
0:10 experts not just me but other people so
0:13 if you need help please get in contact
0:15 with us so another video about the
0:18 triple AI module and what it can do uh
0:21 and help you with um before I start
0:24 going into what I want to showcase I
0:26 just wanted to say because I didn't
0:28 mention it yesterday this is still very
0:29 much in Alpha hopefully the actual API
0:32 that you as a developer work with should
0:34 not change much so the internals might
0:37 change but not that um what I'm going to
0:40 Showcase today is a very uh like a hello
0:44 world example of the of AI uh so what
0:48 we're going to use is the druple a
0:49 module we're going to use something
0:51 called the AI uh API explorer that comes
0:54 with the AI module and we're going to
0:56 use AMA and AMA then is a rapper service
1:00 that starts a service
1:03 um for llms that you can host locally
1:06 which means that you're not going to
1:07 need a a third party service or
1:09 something like that you're not going to
1:11 need to pay for this and I'm going to
1:13 run a model called Gemma that runs on
1:15 any computer that has 16 gab of ram so I
1:18 will just showcase this first now I am
1:20 running this on Linux so how this setup
1:24 works on Windows and Mac might differ
1:27 especially on Windows uh but the general
1:29 idea with a command for lamb and so on
1:31 is the same so you will see I have 16 GB
1:35 of RAM if I run this N videoi I don't
1:38 have a graphic card in this case so
1:42 we're just going to start by downloading
1:44 a Lama so this is different my Goos
1:46 windows it's just executables that you
1:48 install for uh Linux we have to do this
1:52 um and while that's downloading I'm
1:55 going to talk about what we're going to
1:56 solve today so we had this article that
1:58 we created an image for yesterday that's
2:00 about food uh hoarding and I now I just
2:03 want to create a summary around this so
2:04 I have already created uh on my article
2:07 manage Fields I have created a summary
2:10 field right uh here I just have some
2:13 pseudo code that I've written so if on
2:16 pre-save of the node if the node type is
2:19 article then the field summary should be
2:22 filled with some AI summary right that's
2:25 what we're trying to
2:27 solve uh so to be able to do that we can
2:31 start installing the modules already
2:33 what we need is the AI Core module so
2:36 that is installed already we're going to
2:37 need the AI API
2:39 Explorer uh to basically test out the
2:42 API and we're going to need the
2:45 providers well that is
2:47 AMA so we install those three
2:51 things so now we have Ama here it's
2:54 going to start as a service I guess so I
2:57 have to stop this this is a typical uh
3:00 well it's not even typical Linux it's
3:03 typical systemd that doesn't exist on
3:05 all Linux systems so I'm going to show
3:07 you the pure command here instead so you
3:10 can do AMA serve so now I stopped the
3:13 service um but you can do AMA serve and
3:16 this would start the service the problem
3:18 now then is that I'm running ddev and
3:21 ddev runs in Docker and Docker uh is
3:25 basically running its own virtual
3:27 Network and this only listens to local
3:30 host which is problematic because in
3:32 this case my DD machine is not Local
3:35 Host so it will not be allowed to uh
3:38 connect to this so I have to do this
3:40 lost equals
3:42 0.0.0.0 meaning that it listens to the
3:45 world uh and after that I have to
3:48 download the model that we want and in
3:50 our case we want Gemma because Gemma is
3:53 something that we can run on 16 gab of
3:56 RAM and that you can usually see in the
3:59 the parameter size so you see this is 2
4:00 billion parameters very very small it's
4:03 not very very uh smart of course but
4:06 hopefully enough for a summary or kind
4:09 of a
4:10 summary so I would just write AMA P GMA
4:13 to B so it's pulling in the model this
4:16 is not built into the web interface in
4:17 Drupal yet it's hopefully going to be in
4:19 the future uh I already installed this
4:22 so it's already there so now I have done
4:25 everything I need to do on uh online
4:28 because I got everything I need need so
4:30 I'm just going to Showcase something I
4:31 will just turn off the actual um Wi-Fi
4:35 here so if I try to reload this page
4:38 doesn't work I don't have internet
4:39 anymore right um so now I just need to
4:43 set this up this is configuration AI
4:46 settings provider settings for every
4:47 provider that you're going to use uh
4:50 Port is
4:51 11434 that's the default Port you can
4:54 open on any using this uh uh command I
4:57 showed you and then you have to use this
4:59 if you're inside a Docker container when
5:01 you want to talk to your actual physical
5:03 machine so that's host. doer. internal
5:06 and this connects to your physical
5:07 machine so the actual host of
5:10 Docker and after we set this up there is
5:12 then under AI settings AI API explorers
5:15 and these are explorers where you can
5:17 try making calls to the different
5:20 providers that you have set up uh doing
5:22 different operation types so with AMA we
5:25 can do embeddings and chat generation
5:27 that's what it supports currently
5:30 so we're going to use the chat
5:31 generation Explorer choose our provider
5:34 choose our model can use some settings
5:36 here if you want but we keep it as it is
5:38 because it's Gemma it doesn't take a
5:41 system actually it would throw a error
5:43 in this case and then I can just ask
5:45 here who are you I'm the user and I'm
5:48 asking who are
5:49 you and this if we go back here you will
5:53 see it's going to log that a call was
5:56 sent here yeah and then it's answering
5:59 yes has a large language machine
6:01 developed by Google blah blah blah and
6:04 this happens without internet now right
6:05 so I'm just running this on my machine
6:08 but what's cool here now this is the
6:10 call I want to make right I can just go
6:12 to normalist code example and copy
6:15 this and this is the code I need to
6:17 create the exact same
6:20 call uh and what I can do then the or
6:24 let's go through this first
6:26 so uh it first sets up the config this
6:29 is default values we could actually not
6:32 do that but I I keep it there then it
6:35 normalizes the input so you could also
6:37 have unnormalized example here where
6:40 it's less code because you can actually
6:43 you know just put it in directly but the
6:47 good thing with doing normalized and as
6:49 I talked about in the last episode is
6:52 that you can do switch over to open ey
6:54 for instance if you want that in the
6:55 future when you think that okay GMA is
6:57 not good enough
7:00 um and okay these are using full name
7:04 spaces you should usually put those up
7:06 into use there right I'm just going to
7:10 fix that but that's how it has to be in
7:13 this example code of course uh so it's
7:16 creating a normalized input in this case
7:18 of course we have to do
7:21 this um
7:24 summarize this article in one sentence
7:29 just answer with the
7:32 summary and then we're going to do uh
7:35 strip tags because it might not take
7:38 HTML some models doesn't like that um
7:43 we're probably going to have helper
7:44 functions for this later depending on
7:46 model what you can and can't have
7:48 because that's different for different
7:50 mod models so anyway we're creating the
7:52 instance of Lama we're setting the
7:54 configuration and then we're just doing
7:56 the call to Gemma to B in this case we
7:58 don't need to to tag it if you're going
8:00 to make a contributor module please tag
8:02 stuff because that means that uh anyone
8:04 listening to events so they want to do
8:07 something before the request is sent or
8:09 after the request is done can search for
8:12 a specific tag or in the logs you can
8:15 filter on these tags right the tags from
8:18 module that's being used uh provider and
8:22 and operation type is set automatically
8:24 then we get our normalized response and
8:26 the normalized response in this case
8:28 then is is
8:31 um is uh uh chat message so we can just
8:36 open that it should be a helper message
8:38 here if you use the VAR it would
8:40 autocomplete because I'm using the
8:42 druple pig Drupal static uh object here
8:45 it doesn't actually autocomplete unless
8:47 I'm telling it what it is I'm getting in
8:50 this case
8:52 um
8:54 so uh the response is under
8:57 response get message message then right
9:01 so we just do this function and we're
9:02 going to put this into the field summary
9:04 and that's it now we go to our
9:07 content I just show you so you see there
9:10 is no
9:12 summary press
9:14 save oh that was a little bit too fast
9:17 what did I do wrong
9:21 now oh maybe this module is not
9:25 installed uh yeah AI summary local so so
9:29 I'm I am having this test module it it's
9:32 good to install it if I'm going to run
9:34 my code
9:36 I didn't think of that uh so we're just
9:39 going to edit and save it and hopefully
9:41 it takes yeah now it starts
9:44 thinking and then hopefully Gemma is not
9:47 the smartest model so sometimes it
9:49 answers like sure here's a summary and
9:51 then the summary which is of course not
9:53 what you want there that's why I asked
9:55 it specifically just answer with the
9:58 summary but it's not the smartest model
10:00 and this is what you can get without
10:01 having a graphic card or a third party
10:04 summary so yeah unfortunately it didn't
10:07 understand that but still you see it
10:08 actually created something and this is
10:11 actually something that you then can
10:13 have on your
10:15 servers uh that you don't need a very
10:18 expensive GPU or a third party service
10:20 for and it doesn't need to leave
10:22 internet uh or go out on public internet
10:25 so you can keep your data
10:27 safe um
10:30 and that's it thank you for watching
