00:00:00.680
yeah okay so uh I'm going to talk to you about a new crawler uh via longchain RB
00:00:07.080
and G apis and showcase to you um some function calling functionalities and uh
00:00:14.080
I had to amend the slides after I see my predecessor um couple of words about me
00:00:19.400
I'm Ricardo I as a developer advocate for Google Cloud what I do is Advocate about SAR Dev vops Dora everything
00:00:26.199
operations CU I've been in operation for quite a while the guy you know where the knock at your door when things break and
00:00:31.400
they don't care that you exist when things are working fine and among my like the things that I love the most in
00:00:37.040
life are rubby as a language which my company doesn't really support much so everybody's like are you still in love
00:01:02.440
so this is me last night uh drinking uh with with a friend and um I really want
00:01:09.200
to I'm super scared because I'm going to give to show you four demos so if the network is not going to work I'm screwed
00:01:16.439
and um uh before I do the demos I I won't like to do like 15 minutes of demo so I go really fast on the rest I'm
00:01:23.280
going to talk to you about J I know you know everything about it but I want to pinpoint a couple of facts that might not be familiar to all of you I want to
00:01:30.320
show you the problem I'm trying to solve how my ugly uh application demonstrates it and then get to the demos with race
00:01:38.320
console so I will ask you this question uh time by time so what's gen I know
00:01:43.880
most of you know or think they know what it is and I'm pretty sure you do you probably use a lot of uh uh of llms in
00:01:50.000
at work can you raise your hand if you use llm at work particularly with okay raise your hand if you use them okay
00:01:56.280
that's a lot who use them in Ruby who does uh Ruby gen
00:02:02.039
stuff okay so you you probably know the gem I'm going to talk about couple words about llms llms like back in the days
00:02:09.239
you would tell you tell me this is a cat these are the properties of a cat then you take pictures you get 10,000
00:02:15.920
pictures of a cat 10,000 picture of an of a dog and say hey is this a cat and
00:02:21.160
he says yes that's kind of like 10 years ago and today you just say like read the whole internet and now tell me what dant
00:02:28.200
lii thinks about beatric or tell me what is a cat llms are not as magical as they
00:02:35.160
think they basically are a very smart autoc completion tool and when people forget that I think that when the
00:02:40.720
problem start llms are a big autoc completion tool which means that the more autocomplete the more stuff would
00:02:46.280
they make up so token in output you don't want to exceed them token input that's good Gemini is uh is uh our our
00:02:54.920
top llm that we use in Google but I'm not here to publicize that and actually everything that I'm doing today you can
00:03:00.800
do it with any other uh llm in the market from open AI to llama Etc uh what
00:03:06.480
I really want to point out is what embeddings are give me raise your hand if you know what embeddings are in the context of
00:03:13.040
gen okay so that's a minority which is good so only a few people are going to be bored a bendings are uh in a natural
00:03:20.799
are vectors so an array of a thousand think of an array of a thousand numbers every vendor has a different number and
00:03:27.959
the the magic part about embeddings is that represent numerically the aspects about an object like or it could be a
00:03:35.640
picture it could be a video a YouTube video that's we use embedding a lot for YouTube videos for example or it could
00:03:41.840
be for just a word for today think of just for Strings so you have an u a big Vector representing a king a queen
00:03:48.519
swimming swam walking walked anara turkey Russia Moscow and then if it's a
00:03:54.200
vector so a little magical Arrow if you studied math this magical Arrow also the difference between two vectors has a
00:04:00.000
meaning and the difference between men and woman could be very similar to king and queen and represents femininity
00:04:05.599
represent a gender property and the one between turkey and Ankara might be in an
00:04:10.959
ideal world where there embedding Rock very similar to the Ottawa and Canada and have and signify capital or country
00:04:18.759
of so you know uh and if I didn't persuade you I have a little video that
00:04:23.840
shows you embeddings this is a very famous data set called Mist I think it's the oldest data set in the world I think
00:04:29.600
it's is from the 60s where all the digits from 0 to night are represented and you can see 9 and seven here I kind
00:04:36.280
there are points where is it a nine is it a seven I don't know imagine if a computer knows this is another example
00:04:42.160
where you can see some uh uh YouTube videos all of these blobs here are
00:04:47.440
around the city of Brugge probably this is Japanese for Bru and then there's
00:04:53.039
another aalia um group of uh words for
00:04:58.240
stratosphere and uh the the the big part about
00:05:04.320
embeddings is that the idea is that similar thing with hit a similar vectors so you can do Vector similarity to
00:05:09.960
search semantically stuff that looks the same and this is this is actually my
00:05:15.080
first demo which is Trivial but still I think is quite important because probably I think everybody would want
00:05:20.639
some functionality in a rubian raay application where you say I have articles and I want to see the five
00:05:25.880
closest articles I have people I want to see the five closest people so think of it as a function that takes a string and
00:05:32.919
returns a big array of numbers global warming Ruby programming language
00:05:38.280
whatever you want why is this interesting because then given an llm
00:05:43.520
that embeds this into a big chunk of numbers you can say okay now select articles take the near and neighbors
00:05:50.039
based on this big number which is my query Now find the sixth closest article
00:05:55.440
to it and bam that is a uh it's a select on my ra application for this silly app
00:06:02.360
that I did with with the news article and it gives you the idea of the article
00:06:07.479
the title of the article and this magic number this is if this was implemented in any other language probably would be
00:06:12.599
separated but the creator of the gem of the neighbor gem decided to inject this property into the object so this is the
00:06:20.639
distance between the article how climate change is changing heat waves with the global warming embedding so it's a Delta
00:06:27.360
between the vector of my search and the Factor uh uh of the the embedding of the
00:06:32.599
title of course you can decide do I embed the title do I embed the content of the article do I embed the author so
00:06:37.919
you get all the article by Ricardo like you decide what you want to embed I played with it the title is the best if
00:06:43.840
I put everything there's a lot of content and usually sucks but you can see this is not a keyword search because
00:06:50.960
global warming doesn't exist in after the hurricane still we get a hit so
00:06:56.120
pretty powerful and this is really easy to to implement zero cost if you do it with a Lama so might be interesting to
00:07:03.400
do so what are the challenges here you need a vector database why because this is not the usual select asterisk from
00:07:10.599
articles where title equal blah blah blah so it's not the typical thing that you do with an equal or a hash or a like
00:07:17.840
uh qu SQL query but you need to do similarity between big chubby numbers it's a bit like you remember when gpus
00:07:24.960
were introduced to do graphical computation not like today they're used for something else
00:07:30.160
so um we have a number of vector databases is anybody can you raise your hand if you use any of these databases
00:07:36.639
in here zero okay but okay 1 2 3 four okay a few of you do
00:07:44.759
perfect there are a lot of great products in the market these people created a database which is efficient
00:07:51.240
into searching vectors and I chose the easiest for me which is PG Vector is
00:07:56.720
just a library on top of pogress I use pogress I love posw with all my heart
00:08:01.879
and then this is just a library and if you install the neighbor the neighbor um gem you just say raas migrate boom
00:08:08.599
enable extension which calls this code easy peasy I don't know what's behind the scenes but it looks easy peasy so
00:08:16.639
that's the first part you have your your database now my database supports vectors so I can have a field on Rails
00:08:22.039
to say this is a the the embedding of the title and it supports like a big chubby number to be saved in the
00:08:28.199
database then you the API with your favorite uh uh with your favorite um AI
00:08:34.640
tool that you have in my case is Gemini and I use an embedding model Google has two models one multilingual one single
00:08:41.440
lingual English I tried them both I like multilingual because I have article in Italian and in English in my tests but
00:08:47.519
the the English one works a bit better so I'm yeah I sacrifice it and this is how it looks you can see I'm clearly a
00:08:54.160
front end developer right my you can see the quality of the CSS is that I that I
00:09:00.440
create and as you can see this is a a random article these are the closest article and this number here is the
00:09:07.399
distance that I was telling you about you can use various algorithm for this ukian uh cosinus but I don't think we
00:09:14.360
need to get into there so what's the problem that Ricard is trying to solve if I still have your attention because maybe like boring numbers I don't like
00:09:21.279
them llms that you probably use every day for work or to just play around uh
00:09:26.880
are not perfect they have a number of issues I say my two favorite issues are hallucinations because again it's an
00:09:32.440
autoc completion tool he not intelligent so he's making up stuff and they still do it and they have outdated data so if
00:09:39.240
the model was trained a year ago maybe when you ask the president of the Republic of a country that just changed
00:09:45.720
two months ago he will tell you the old one right humbly you say for what I know I think is this person uh is it still
00:09:52.519
syia bonei probably not okay so we want to fix two things hallucination and up
00:09:58.600
to-date so what I thought is let's create a News application just steals
00:10:04.000
news from newspaper online I just fed it 30 RSS that I manually found on a
00:10:10.040
Saturday morning and finally I say okay feed it into my database and of course
00:10:15.120
they become old after one day they're old my my information is from a month ago so they are old but good enough but
00:10:21.720
still old how do we solve the problem of LMS the most famous way to solve it is
00:10:26.839
Rag and rag in my opinion is very 2023 so this is how you would solve the problem a year ago it's very well
00:10:34.040
established in where I work with the customers I work with this is very 2023 they're still implementing it but it's
00:10:39.800
still it's a beautiful solution but it's quite known it's it's been used for for like a year time which in gen it
00:10:46.279
corresponds to more than 10 years it's like 25 years so um I would say two and a half more than uh in ratio than just
00:10:53.279
languages how do you do rag well philosophically you start from the embedding of the user question I don't
00:10:59.079
know climate change uh yeah climate change for example then you do a similarity search on your database
00:11:05.000
actually I say database but less expanded it could be retrieve them out in the wild retrieve news from the word
00:11:11.440
or search my database depends from your application whatever you want it's just find some information that is fitting
00:11:18.120
and that probably the llm doesn't know because the LM the llm is stopped in time from let's say one year ago just to
00:11:24.440
visualize it right then construct a prompt where you inject into the LM prompt
00:11:30.000
the information that you just retrieved here so you're kind of cheating you're asking a question but you're providing
00:11:36.079
the response in the middle of the question so you're providing fresh information okay so is a typical question answer
00:11:45.040
where you are cheating and retrieving based on the question you're retrieving from a knowledge base can be in the
00:11:50.680
internet can be on your DB whatever you want you add it here you paste it into
00:11:55.760
the context and you know where I'm going then the autoc completion of answer will ask will try to answer your question but
00:12:01.880
he will also first read you say oh by the way did you know that this person just died this morning or the the war or
00:12:08.720
political information from yesterday you just pasted it so he she already knows
00:12:15.240
in in Italian we have to uh put a gender to everything we don't say it so I don't know if it's a female or a man something
00:12:21.519
or something in between solution number two function calling so this is something a bit more esoterical I would
00:12:28.040
say this is something that has been in is available in a number of platform I don't know open AI Google and I was
00:12:34.639
reading an article this morning just uh uh Co the the French ones what's it called um anthropic um has just launched
00:12:41.959
it this week so it's it's a new thing function calling is difficult to explain
00:12:47.160
because it feels like oh LM can call a function it's subtly different than that the
00:12:53.000
LM re you give it a question and you provide as a payload a bunch of um
00:12:59.440
function uh um input and outputs like location string description string movies date date Etc forgot the word but
00:13:07.160
you know what I'm talking about like the arguments that they want in input and then he tries to make up what is the
00:13:12.240
best function and the best argument that I need to populate for the tools that you gave me and in this case is the
00:13:19.199
probably the find theaters for Barbie and Mont view the only effort that it
00:13:24.519
did is understanding from my question that mon M view was actually mon view in
00:13:30.959
California it was a simple Google Map thing that probably you're an llm you know shitload of stuff right so you can
00:13:38.240
say the mon view I know it's in California rather than in the province of Verona right so that's what it does
00:13:43.720
it seems simple but actually this empowers you to then call in the middle of a an interaction with your llm to
00:13:50.639
call functionality I don't know uh transform Centra to Fahrenheit which you say probably already knows how to do it
00:13:56.959
but maybe something more complex which is based on your I don't know your us your model your business uh logic that
00:14:03.160
is only yours and you only know okay if you if I still have your attention let's talk about my solution my solution is to
00:14:10.399
uh Ruby directory uh in my name is paladius gin news crawler so you can find the the code in there the crawler
00:14:17.759
is really not important today the crawler is just something that I call in February and March leaving my my Mac by
00:14:24.120
night my wife is like it's very noisy yes I know machinating I don't know Milling
00:14:29.560
and getting all of the all the article I have 10,500 article I think there is C
00:14:34.839
to 5 to 10,000 so I have like 10,000 article okay now I fed my database with random stuff from three months ago which
00:14:41.399
is important and then I have a web app which is a rubian ra app Ruby 3 ra 7 uh
00:14:47.079
it's dockerized it builds in 5 minutes plenty of environment variables oh there are like pages and pages of bars too
00:14:53.759
many probably this is the RSS of the first of the crawler is me just randomly search search the RSS playing with the
00:15:01.600
gem that fetches the RSS if he gives an error I remove it if it doesn't give an error so it's a lot of trial and error
00:15:07.079
very boring you don't care about this maybe you care about the libraries that I used I don't know so fit jira is there
00:15:14.199
are two gems for for new fing article I use figa use very well function very
00:15:19.759
well I never tried the second one neighbor is the Magic Gem to do um
00:15:24.920
similarity that that pumps up your vector search uh Matrix as well is good with numbers CH and group date for
00:15:31.880
graphs I mean I love it uh delay job for delayed jobs active record because I'm
00:15:37.000
lazy and I don't want to install in production uh G Google stuff red
00:15:42.360
carpet for markdown and now L chain RB which is the protagonist of my um of the
00:15:48.279
title of my presentation right and this is my joke I don't know if does anybody have experience with the lung chain in
00:15:54.720
um in python or stuff and you say I'm a ruby developer I want to use L chain I'm a bit jealous it doesn't exist then few
00:16:01.759
months ago I realized I I Googled lung chain Ruby and I found out this gam I said I need to meet this guy so I met
00:16:08.680
with this guy and I said hey I want to do a demo let's build a demo together so he help me a little bit and this is the
00:16:14.279
gem that uh kind of changed my Ruby life in the last six months um made by Andre
00:16:19.360
Bond based in Miami independent consultant and uh it supports multiple
00:16:24.600
llm so you know you say oh this guy comes from Google he's showing me the Google way blah blah blah blah I don't like it I don't want vendor Lo lock Lo
00:16:32.759
lock but the fact is that you can do JM L chain llm instead of Google gmany you
00:16:38.079
call I don't know openi or anthropic or Mistral or AMA I actually did it with
00:16:43.880
AMA because I was on a flight to the Philippines a few week a few weeks ago and it works fine perfectly in Local
00:16:49.959
Host because it's a Lama right um it supports function calling chatting embeddings and um a thing called tools
00:16:58.600
that need to explain what it is and if you guys are like me that you really sympathize for Team Ruby the blue one is
00:17:05.559
Ruby and the red one is L chain for Java perro supported by a colleague of mine
00:17:10.919
who loves Java Gom la Forge so please please um up I put the QR code so you
00:17:16.559
can up vote it and maybe give it a few Stars Team Ruby okay um just saying uh
00:17:23.959
the deployment happens with the with the Google Cloud so this is cloud build I deploy Dev and prod I wanted to show you
00:17:30.799
prod but as the new B the database in Dev is a lot better so everything you will see today is in Dev so slow as hell
00:17:37.799
but not too slow so sorry about that I never backported the database to prod because 10,000 too much stuff few stats
00:17:44.880
boring okay this is the architecture so Ricardo does a g commit it's just me it's a demo trigger to Cloud build
00:17:52.679
builds artifact registry Docker image Docker image gets pushed to Cloud run which is a k native on steroid and then
00:17:59.000
he runs in the cloud it calls all of these apis and the CER who cares because it's not the protagonist of the day okay
00:18:05.559
this is kind of like I hope I still yes how much time do I have more another 20 minutes fantastic so I have all the time
00:18:12.320
to show you all the demos um I live frankinstein Jr of course so these are
00:18:17.679
the four demos one I kind of snacked it in into the into the embedding part so you already saw this but I'm going to
00:18:23.400
show you again because we have time then I'm going to do this with a UI this with r console this with UI because it looks
00:18:29.640
cuter there are images and then uh the the number four is the one that I really think is going to be I find it
00:18:36.120
impressive you will tell me if you like it that the three are like like kind of like Preparatory to to the fourth
00:18:41.760
particularly the three I just put it there so you understand the four a bit better but you will see with time so um
00:18:48.720
every demo that I have I want to show you the
00:18:54.600
um uh every demo that I have is uh I need to call a couple to close a couple
00:19:02.320
of okay it's uh on GitHub under web app which is the raise up under docs and
00:19:08.159
demo and as you can see there is a read me and there is every demo is something you can paste in the console and you can
00:19:13.799
adapt it so there is a query you can change the query and see how it works okay um so demo number one is as simple
00:19:21.320
as clicking this button and I will show you on the web it's this and you can click deput if you think I'm cheating
00:19:28.039
you can just click click and find something else you can see that every article is these are actually related
00:19:35.440
articles to the top article so this is the article as you can see I'm a front end developer so interface is slick as
00:19:42.240
hell you cannot find anything better today like state-of-the-art uh
00:19:47.559
UI and um I built the buttons the buttons I
00:19:53.360
asked gy say hey give me buttons that looks like Google Google colors it I pasted the CSS like yes I'm a frontend
00:20:00.039
developer now that's that's the quality of my of my coding um so this is the
00:20:05.080
demo number one for the demo number two the Bella raaga the r demo I want to show you with the uh with the with the
00:20:12.720
console so I'm going to open my vs code so you see don't say that I am vendor logged in oh sorry you shouldn't have
00:20:20.000
seen this um so race console and let's pray the network work don't download a lot of
00:20:27.000
stuff now please uh so demo number two I will use the global warming why because
00:20:33.360
then what I show you in the console is exactly what you see in
00:20:38.600
here and since probably if you see in the slide it probably comes a bit better yes probably here you see the text
00:20:45.480
better so just for this the font size I will show you here but then I show you the code so you don't see oh this guy cannot code probably you still think
00:20:52.480
that but at least I will type something on the keyboard right so it looks like I'm smart uh so global warming say that
00:20:58.720
query so far it's exactly the embedding part that I showed you already but the part the different part about so this
00:21:04.400
you saw it already in the in the kind of the previous demo right but the part that is missing is when we assemble the
00:21:10.960
prompt to inject that information so first I create this header which is blah blah blah blah blah blah tell me
00:21:16.520
something about global warming oh by the way today is the 24th of May you will see 31 on the console because I took the
00:21:23.480
screenshot some days ago and here are the six article and then I take an excerpt of the article I created an
00:21:29.120
except function which puts the title and some re I I played with it a lot I put a lot of info it it sucked and then I put
00:21:36.559
very little info and it got a lot better so I put okay so little info and then I asked the llm to summarize that let's
00:21:43.159
see it in practice so global warming I put two at the time
00:21:49.159
so you can see the embedding has been calculated the network is my friend yes
00:21:55.279
this is the big chubby number for Global Warming okay you saw it now we clo we take the closest
00:22:02.320
article if you're curious select sensible columns I needed to do it because without it would select all the
00:22:07.720
article and it would it would be very bloated by the embeddings and so it would take six seconds and once I
00:22:14.720
realized this with a lot of stock overflow checking I realized it was just
00:22:19.960
as simple as that and now a few milliseconds and you can see
00:22:25.240
uh these are my article this is my um active record which gets stuck at this
00:22:30.919
big number so you can only see the first that's why they're beautiful but you need to you need to say don't print them
00:22:37.320
out otherwise you know somebody maybe can teach me how to not print out um a
00:22:42.440
field when I do the the the print of it so this is the this is against this is
00:22:49.120
still demo number one nothing nothing new from the from the embedding demo now we do the interesting stuff which I
00:22:55.080
wrote the code in the helpers crappy developer so I need to include it for the race console to work and now I'm
00:23:02.240
creating the short part that you saw in the slides this is just a a here document with a couple of variables for
00:23:08.480
the date of today 31 of May I could do it with another query if you want me to I I I can do it this is it's just
00:23:15.080
because I already know the output so I know it kind of makes sense but I could put something else so now I take the
00:23:20.559
excerpts and I put test them or puts them you see quering again because some
00:23:26.480
some fields are missing these are the separated six articles and now I just need to put everything together with
00:23:32.840
another little function that I built and finally call the autoc completion because remember n llm is an autoc
00:23:38.799
completion engine most of the time bingo this is the string that the
00:23:43.840
autocompletion gave me and let's color it of green and this is the can can you read this or it's
00:23:49.200
unreadable because if you cannot read it I do Control Plus but then it's like yeah you get can anybody not read this
00:23:56.039
so I will plus it so okay fantastic okay so this is the demo number two let's go
00:24:02.320
back to the UI okay for the demo number three this demo is very very simple I
00:24:07.799
think it's beautiful but simple it doesn't do anything important I need to do it from a narrative perspective
00:24:13.080
because you without this you don't understand the demo number four the demo number three is me calling a l chain
00:24:18.320
tool what is a l chain tool a l chain tool is a thingy composed of a Json and
00:24:24.440
a ruby file do I have it here yes and uh in this case this is something that
00:24:29.880
Andre wrote for me in his gem so this is a public Fe that anybody can use you just need to get the API code from news
00:24:36.000
api. comom I want to do the org but you can do it with either uh you get the API
00:24:41.080
key and then you can start asking tell me everything about Verona amaron uh Roma or you know whatever whatever you
00:24:47.279
like and the interesting part is that you have a Json and a ruby and as I anticipated some time ago Ruby has the
00:24:54.080
code of the function which Germany doesn't care your llm which it is doesn't care about and then let me make
00:25:02.440
it a bit bigger the rubby code is the part that you write or somebody else writes for
00:25:08.399
you and that gets executed when you interact with the llm as you will see we'll see in the next demo the the part
00:25:14.600
that is really relevant to an llm is actually the Json part which is the part where you tell it hey this is a title
00:25:21.039
hey this is a nation the nation can be Italy or France or UK so you can
00:25:26.200
actually instruct it the description of the metadata is the part that the llm picks up so that's the part that I
00:25:32.760
whenever my demo doesn't work I go change the Jon I got I don't go J change the Ruby if that makes sense which was
00:25:39.279
very surprising to me so I made some you know usually I do some smart stuff and
00:25:44.520
some very silly stuff and with the silly stuff that's what breaks my demo say oh make up the country and make me the
00:25:50.760
Emoji of the country where the article is from and when he knows or she knows was the right thing but when it doesn't
00:25:57.399
know it fails with an error which is unrecoverable come on I just want to do something silly so I changed the the
00:26:03.520
description to if you don't know put Vatican City I'm a very religious man as you can
00:26:09.279
see right so put Vatican City all of a sudden it doesn't fail anymore I change the description not the code it's
00:26:15.120
incredible because the code is very very simple so um let's come back to us so
00:26:20.960
you understood like the tool is a collection of methods and functions where you you say oh I'm able which are
00:26:27.600
usually connected like in a class like all method that have to do with a topic
00:26:32.640
and uh if you want to see what L chain supports as a calculator database file
00:26:38.440
system Google search news retriever Vector search weather Wikipedia you can I could actually use the added the
00:26:44.760
Wikipedia tool to say if you search for Wikipedia on what is a treasure shark for example which maybe it's easy to
00:26:51.640
find a Wikipedia than on uh on news right so depending on what you're trying to do you can use all of these tool now
00:26:57.320
that I showed you now that I showed you the theory I'm going to show you the boring
00:27:03.679
practice so this is nothing magical at all let's look for venal this is the
00:27:09.799
query this is the payload in response I played with the response so you can see the tokenization of every single
00:27:16.240
response and bang these are the Articles constructed it looks better on the UI
00:27:21.440
because there are images right without images I would have showed you on the console so I would have looked smarter this is even too simple right because I
00:27:27.760
don't do anything now let's come to the final demo that is the difficult one the
00:27:32.960
one that fails 30% of the time so pray for me now in the fourth demo I'm going
00:27:39.039
to do this I'm going to do similar to the three I'm going to call a tool but actually I'm instantiating an assistant
00:27:44.720
again another L chain uh uh L chain Ruby objects that has this property you
00:27:50.640
instantiate it you will see it in the code but I wanted to have a slide for it you in say the LM which is the brain the
00:27:56.640
thread which is the list the array the history of what has happened starts empty and then it gets loaded with all
00:28:02.720
the conversation instruction you can start with this you can play with it you can say well if the person also always
00:28:09.600
ask you to save to the database ask for a password 4242 or you know you can do
00:28:15.080
something like that and finally most importantly you give it an array of tools a tool is an array of methods so
00:28:21.480
it's an array of an array of methods you know what it means plenty of methods
00:28:26.519
okay in my case there is the news retriever which I showed you in the demo number three and the article tool which
00:28:33.320
instead is uh in my inside my code so crappy code and it gives you the create
00:28:38.919
function to to write something on the artive recor of course the code is in my ra application because it belongs to it
00:28:44.679
right it knows how to create an article how to delete an article and do a suspiciously looking carsian URL the
00:28:52.919
hell is this I know you're struggling with anticipation so let's move to the
00:28:58.240
let's move to the demo to see what happens here so now I will click on demo
00:29:03.519
four and I will cut and paste some code so I will look half smart so
00:29:10.880
llm and again as I said this is a Google jam llm with the where I take the credential from the application
00:29:17.240
credential and uh you could distate from any other uh llm vendor so this is completely transparent and it does work
00:29:24.080
it needs to be an LM which supports function calling and as far as I know only a few support it now but it's going
00:29:30.000
to grow oh sorry this I I forgot the comment see bingo so we're using gini
00:29:36.640
1.5 if you are familiar with it is the one with a million token in input so you can read the whole Shakespeare or Divine
00:29:42.360
Comedy and ask in how many different way vigilo slacked uh Dante in Paradise for
00:29:49.039
example here we're instantiating the assistant this is the one that I showed you in the slide because I wanted it to
00:29:54.080
be understandable now we understand it and the assistant and this is me being
00:29:59.840
lazy because I I will talk a lot to this thing here so I would just say say say
00:30:05.159
could be say but it's an S because I'm very lazy and now finally we can start playing with this the history starts
00:30:11.559
empty and say give me the latest five news from Italy can you read this so now he's talking to L chain you
00:30:18.919
remember now I'm having a live conversation storing the assistant object so empty then Ricardo says give
00:30:25.799
me the latest five news from uh from Italy and I will call
00:30:32.080
history and this is this is a if it's colorful it's my code of course so this is me the user asking five new news from
00:30:40.679
Italy the model calling the function calling functionality we say call the news Retriever get top headlines
00:30:46.760
arguments country it page size five I could say I don't like them give me the next five you will call it another
00:30:53.480
function with page equals two I guess at least that's what what it did two hours ago
00:30:58.600
let's say nah I don't like them give me the next
00:31:06.600
five so that will probably and you see I'm having a conversation imagine tweaking this with a microphone you
00:31:12.120
could actually do it uh I actually my next Dem is we going to probably be saying it to the Google home or to some
00:31:17.880
or Alexa you can just say this in word and bang these are the next five uh news right and say Metallica wow I like
00:31:25.360
Metallica so I could say something uh uh save the second one on Metallica just
00:31:32.840
because it could be confused with the second uh on
00:31:39.360
DB and if I am lucky he understands he need to save these information this is
00:31:45.039
just the title and this is active record doing stuff plenty of numbers so it
00:31:50.159
calculated an embedding which is why it takes a few seconds and he says I've saved the article about Metallica playing a cover of Aida the pro and
00:31:57.440
database uh the article ID is D okay sorry my English is bad for five digits
00:32:02.519
so I can do article D okay uh
00:32:08.600
10,413 you see I'm good huh and uh but I want to because I'm super lazy so can
00:32:17.200
you give me the carian URL and I love the fact that I
00:32:22.360
can make a typ of n what does it mean this I
00:32:28.519
what does this mean are we having Grappa yes so the
00:32:34.519
kisan article is this I'm going to open this and this of course is the URL in
00:32:40.000
production but actually it's in Dev uh for the new article this article was created a few seconds ago and it already
00:32:47.200
has an embedding with the closest article to Metallica Aida Prozak which
00:32:55.600
is maybe the the post with paji has something about that I don't know so it
00:33:01.679
already has the similarity search from the demo number one right so I would say the demo does work and you can say
00:33:07.600
something much more complicated because you're talking to an llm so we could do something like I don't know um I'm at
00:33:15.000
conference and my audience is very susceptible um I want to avoid political
00:33:22.000
D and that's what is the article that you would save ah damn
00:33:28.519
it choses the one that I already saved why don't we try to save it okay so say
00:33:35.399
bingo uh save it please what is going to happen what is going to happen in your
00:33:43.919
opinion s again it's already there so it's going
00:33:50.240
to fa to to to fail and if it fails um
00:33:56.200
the failure should provide adjon string of the error messages of the failure so
00:34:01.320
that LM learns why it fails you don't return nil you return the strings of the error because you're talking to
00:34:07.440
a in in to a Smart uh robot so if you provide as much feedback as you can then
00:34:12.639
let me say well the title already exist you idiot say ah okay uh let's try I
00:34:18.240
never tried this article is already saved the database oh
00:34:23.800
wow oh wow I didn't really okay he knows it's ready saved without even been trying wow that's interesting I didn't I
00:34:30.560
didn't see this happening fantastic that's that's outsmarting I thought you would try let
00:34:37.399
me try save it nonetheless he's like follow
00:34:42.960
my orders and that he should explode and get some some mistake no okay it's too
00:34:48.520
smart for me okay I cannot I cannot yeah okay so that's the end of the demo and I
00:34:54.560
could do it if you guys are interested we could search for something else we can does anybody have a query to try out
00:35:00.680
unless you tell me that I need to close it and then we I can declare the demo closed how are you doing on
00:35:06.640
time 3 minutes any anybody has a question to ask the llm or some curiosity let's push it to the to the
00:35:13.320
borders
00:35:18.480
any uh gives give me some news about
00:35:26.480
rail the second word is club race club
00:35:37.599
conference let's let's see what happens notice the history keeps uh uh
00:35:47.599
increasing okay could can I just do raise or
00:36:03.960
this is of course depends on the on the news API let's see if he finds it I noticed that if you ask country
00:36:09.560
information Nah if you ask country gets it but if you ask a generic thing it
00:36:15.119
does let's try
00:36:20.599
this because these I found something so this should work there's a lot of news
00:36:42.280
so this is a internal tool that doesn't allow me to do
00:36:47.520
stuff okay it's called Santa Claus but you hate
00:36:53.359
it okay good luck find it couldn't find specific new article so yeah that's that
00:36:59.240
doesn't work rails Europe uh yeah no this doesn't
00:37:09.920
work let's say Japan yeah with country it works I think
00:37:15.319
this is probably a limitation in the API search uh that um it expects like a
00:37:20.440
geographic area I say Verona it doesn't accept it but I say Italy does accept it so it has pagination but it doesn't have
00:37:26.880
a very smart so oh uh this is so easy to
00:37:35.480
understand uh can you save the second and the
00:37:40.960
fourth hoping they are five because I cannot even see them in my mind I'm cheating of course I could ask him to
00:37:46.720
translate them to English uh which I forgot in this case it will probably be
00:37:52.440
smart enough to call the function once save it call the function twice save it and now it has two ID probably will give
00:37:58.119
me two IDs he could actually be smart enough to say well this guy cares about the kesian URL let me also give you the
00:38:03.960
caresan sometimes it does it based on the history because he remembers the previous interaction if I reset the the
00:38:10.200
rail console he would forget everything so he would say he he wouldn't do it at first right so he's doing the first he's
00:38:16.760
doing the second I think I'm running probably a bit late you see these are the two IDs
00:38:22.040
1045 he gave me the two IDs and say carian SS
00:38:29.440
please and probably will give me a list of two URLs which I just click and show you one of
00:38:37.079
them and I think we can declare the demo kind of done cuz I don't want to
00:38:43.520
abuse your time let's see if it's in Japanese or it
00:38:48.640
translated something Japanese since I'm the best front 10 developer in the world
00:38:55.000
I'm not able to actually transform this beautiful uh character in actually utf8
00:39:00.800
I tried but I failed there is a two uf8 but it didn't work I still don't know if
00:39:05.960
somebody wants to fix the code for me please tell me teach me so that's the end of the demo and uh I'll give you the
00:39:12.280
last slide which is boring as hell which is thank you and um if you're curious to
00:39:18.000
see the links I put all of this here with a QR code so in case this is just the r me the the bottom of the r me of
00:39:25.440
my so there is the the gem the repo what is an embedding the video I took a video of the demo in case this failed so yeah
00:39:32.599
that's everything is there so thanks everyone and up to the next presenter