0:32
hey friends this is your host Rodrigo and today we're going to see the
0:38
conversation building block and this is the last session of the
0:44
series it's been a wild ride since December
0:50
and you have to take into account that all the different sessions are recorded
0:55
and you can find those in the cp.com
1:01
website and say that you want to I don't know you
1:08
want to continue your journey with Dapper there's of course a lot of different videos and training courses
1:15
that you can find online and okay that's it let me share my
1:24
screen which is number two okay cool
1:33
awesome let me start the
1:39
presentation so the conversation building block allows you to interact with llm
1:46
providers right such as open AI cloud or
1:52
all the different models that you can use in hugging phase and so on okay so
1:58
this is a a way for you to call those llms basically that's it take into
2:04
account that this is an it's an in an alpha state so all the things that I can
2:11
showed you today maybe they'll be changed in the future
2:17
okay um so let's go ahead and see the diagram which is this one you can see
2:23
that as any other building block you have your side car the side car
2:30
is the one responsible for calling the component of course and the component is
2:37
the one that is configured for a specific uh large language model and
2:43
provider okay today I'm going to show you open
2:48
Ai and of course you can use the same uh the
2:55
same uh techniques and skills for any other model
3:00
okay so this is nice I like the conversation building block the way that
3:07
the DI grade and the dopper community are thinking about it since you
3:12
can have some features that are not available in other Frameworks for
3:19
instance prom caching that's available in other Frameworks as
3:24
well but with promt caching it allows you to reduce costs and lat
3:30
by caching the prompts that are regularly sent to the
3:35
llms this is when you have a specific prompt that is recurrently being sent to
3:43
the LM that prompt is going to be cashed okay so of course that's going to reduce
3:51
cost in latency that's nice so in the other hand we have the pii ofation this
3:58
is personable identifiable information in other words
4:04
sensible or private information that you want to office gate you want to hide
4:11
when you're sending that data to the LM and the other way around as well when
4:17
you're receiving information that has pii this particular building block is
4:24
going to alus skate that data which is very nice I think that
4:30
approach is um interesting and of course just like any
4:37
other building block in Dapper this uh integration with large language
4:44
models are being observed and everything is going to be uh traced by using the
4:51
observability features that Dapper has which is quite fantastic
5:00
right so let's go ahead and see what we can
5:06
do with this okay let me go to the Dapper in action
5:14
folder and then this is the 13 folder since we are today in this
5:22
13th uh session and of course I don't have anything I just created the folder
5:29
uh some minutes ago so let's go ahead and create a new web API by using
5:36
asp.net and let's name it conversation so net new web API
5:43
conversation and let's use controllers you know
5:48
me I don't like uh minimal web apis so regular controllers and the name
5:57
is going to be conversation and basically that's it okay so for this
6:06
building block there's a nugget package that you can reference for calling the API remember the side
6:15
car your side card that is running alongside your application is exposing
6:20
an API that you can call by using HTTP or
6:27
grpc and you're free to uh you know call that end
6:32
points uh in any way you like right you can for
6:39
instance if you as you are a CP and net developer you can create your HTTP
6:44
client and then client do you know post async or get or put or those kind of
6:53
things however Dapper has fantastic s case that we can use and
7:01
net is one of the platforms that are supported in the upper and for this
7:08
particular conversation building block there's a specific nuget package this is not your regular Dapper asp.net core
7:16
nuget package so the name let's change the folder to here the name
7:25
is uh doer. a unsurprisingly I
7:32
think okay so I'm using net ad package of course you can use uh visual Studios
7:39
uh nuget ad package reference but since I'm here in the
7:44
terminal I just want to show you how to add this nuget package doer. a version
7:52
1.15.2 at the time of this recording and we can go ahead and verify
7:58
conversation cspr and the package reference is there
8:03
there's there's nothing new right okay so now let's create a new
8:11
solution and Net Solution add the current
8:16
project and we're ready to rumble conversation
8:22
sln and I'm going to open my visual studio 2022 instance
8:29
since you know me I'm a visual studio
8:35
Fanboy of course I use Visual Studio code from time to time but I think I
8:40
truly believe Visual Studio is better and is
8:45
superior uh to visual studio code but of course we can disagree right
8:52
you can disagree with me uh you can even be using other languages or Frameworks
8:57
that's fine so just like you're expecting here you
9:04
have to add the Dapper client but that's not the regular daer
9:10
client actually the same is the name is different Builder Services uh doer
9:16
conversation client okay this is the one so with this line of code you can
9:24
inject the dopper conversation client in your controllers and and you can even add
9:30
some configuration here you can pass this uh you know this expression an
9:38
action in this daer conversation client builder for setting up some things and
9:44
I'm going to use the defaults I don't want to focus on those details right now
9:49
I just I just want to show you that this is the way for injecting the D conversation client and let's get rid of
9:56
this nonsense whether forecast controller and let's rename this
10:04
to um say chat controller or conversation
10:10
controller okay this is good now using the primary
10:16
Constructor syntax I'm going to inject daer client daer conversation client
10:24
okay this is the one Dapper conversation client and of course it has some methods
10:31
and members that we can use for invoking those
10:38
LMS which llms you may ask well of course we need
10:44
the component we need to create the JAMA file for
10:50
sure so let me go ahead and open the browser and then developing applications
10:58
building blocks and then um
11:04
conversation and conversation overview of course you can read more about this
11:10
about the features what kind of information is considered uh private or sensitive
11:18
information such as phone numbers email addresses and so on it makes sense right
11:25
and let's navigate to those components you can see that AWS Bedrock is there
11:33
anthropic for calling CLA or those fantastic LMS are is there anthropic
11:40
deep siek is there deep siek such a fantastic
11:46
and uh glorious llm very interesting hogging phase
11:53
Mistral and of course open Ai and that's actually the one that I want to use used
11:59
today open Ai and you can see those required
12:07
values you know those fields that you you can specify the required one is key
12:14
that's the only one that is actually truly required API key for open
12:20
a okay take into account that this is again this is an alpha uh version okay
12:28
because it doesn't say anything about an endpoint so there's no Asher open AI
12:36
option right now of course Dapper is open source you
12:41
can contribute and create a component even if you don't contribute you can
12:47
create your own components uh anyway today I'm going to use the regular openi API the one from
12:55
open.com not Asher openi that is located in the Asher AI
13:02
Foundry uh umbrella in Asher so the key I have my key I created
13:10
the key beforehand because I don't want to spend so much time in that so I have
13:16
the key and the model the default is going to be GPT for
13:23
Turbo um but there are other um I think better models that we can use such as 40
13:31
40 mini right it depends on your requirements but today I'm going to use
13:37
GPT for old Mini I think it has the perfect balance between cost and
13:43
performance and logic and reasoning so GPT 40 mini and cash TTL this is the
13:52
time to live value remember that I told you that those proms um that you sent to the Ln
13:59
are going to be cashed by the building block so this is the Cash Time To Live
14:06
um duration okay the default is 10
14:13
minutes okay okay okay cool so good uh I think I'm just going to copy
14:21
this and return here this is my
14:26
application and this is uh my phone let's create components
14:33
components and let me go ahead and open a visual
14:40
studio instance here let's name it conversation.
14:47
jaml let me close those um panels those um
14:53
popups yeah I know I know okay cool so I'm gonna paste this
15:00
um so API version kind metadata and spec those are expected right Dapper doio B1
15:09
alpha1 is the API version the kind has to be
15:15
component and this is the name remember I told you like 1,000 times this is the
15:21
technical name that you want to use that you have to use in your
15:27
application so let's name it conversation can be called I don't know
15:33
open AI or so on this is just the name that I'm going to use today and the type the technical
15:41
type is conversation. openai okay this is the type for calling
15:48
those models and the key I happen to have my
15:55
key um right here please allow me to copy this and I'm
16:02
going to copy the entire string okay this is my
16:08
key let me show you where you can get that open.com I'm in this other monitor so
16:17
bear with me this is going to be fantastic um so open ai.com and then uh
16:33
and I'm here yes I'm
16:38
here so I just logged in and you can go ahead and see your API
16:46
keys right here and of course you have to have enough uh
16:52
balance okay I have $10 and API keys this is the one drer in
17:00
action that I created beforehand and this is the one I'm going
17:05
to use this is it okay so model it's going to be gp40
17:13
mini you can always will go ahead and search for
17:21
open.com models and in this
17:26
page you can read more about those different models that open AI has
17:35
okay so many at the time of this recording those
17:41
are the ones and finally Cash Time to live this is fine um so this is
17:48
it okay let's go back to the application since I want to use doer conversation
17:56
client of course I need to create an point so public casing task let's say I
18:02
action res I action result let's name it
18:08
Chad okay this going to be HTTP [Music]
18:14
post and what about creating a record chat
18:20
request similar to this um um suggestion from
18:27
co-pilot but instead let's name it message so I have my record this is the
18:33
chat request chat request request right it comes from the
18:38
body this is this is just a regular asp.net core endpoint nothing new here
18:44
so doer conversation client dot you can see that we have Converse asnc Converse
18:52
async okay so convers acing takes the component name or some
19:00
unsurprisingly right this is conversation and then you have to pass
19:06
this I read only list of dopper conversation input and
19:13
then so this is this is an I read only list because you want to send the entire
19:20
conversation history to the large language model if you want to do that right if you want to keep those messages
19:28
or if you have to you know specify the system prompt and then maybe you want to
19:35
use uh few shot learning technique by using the assistant role
19:42
and then your prompt itself make sense so that's why that's an I read
19:49
only list and not only a string and so let's
19:56
pass a new topper conver ation input I'm going to pass request message I'm going
20:04
to pass uh the human you can see that this is an
20:09
inum system tool human function interesting I think the the
20:16
team is thinking about function calling and of course
20:24
agents um so maybe next in the next version we're going to see
20:29
those uh features in the Dapper Dapper composition building
20:36
block so okay human and I think that's
20:42
it what else oh if you want to scrub the private
20:49
information as you can see this is false you can pass through
20:54
and uh that information will be alus skated
21:00
so let's return something and now wait for
21:05
this and remember this is my I read only I'm
21:11
I'm using this um syntax from C 13 and I think that's
21:18
it we have outputs which is an I read only list of topper conversation
21:26
result and this is doer conversation input I don't like the
21:33
name uh conversation input drer
21:39
conversation output so maybe that's one of the things that I could say to the
21:45
team um daer conversation input and then result for me doesn't make sense it
21:52
should be named Dapper conversation output anyway so res do outputs I think that is
22:00
the one that I want and we also have this conversation
22:06
ID which is quite interesting since you want to
22:11
sometimes uh store all the different messages in a single thread right like the assistance
22:19
API that open AI created uh but in this case I'm just going to return let's say
22:27
the outputs just just like this and I think we're ready to
22:32
go Okay Okay cool so I think we're ready to test this
22:42
I'm ready to go ahead and return to the terminal
22:50
and let's go here and let's use toop run just like any
22:58
other application that we created in this series tap around and then the application ID it's going to be
23:05
conversation app or something conation app and then
23:10
dopper HTTP Port I want to use 55,000 and then a port I want to
23:18
be uh using this um 550 Z you know me I
23:25
always use that port and components path or resources path you you need to pass
23:32
that okay remember that the component is
23:37
located in this um folder and you know what let me
23:42
change the folder to this um conversation uh
23:47
project because otherwise I have to tell Don wrw to use that folder but I don't remember
23:54
the syntax right now and so components
24:00
PAAD it's going to be components so netron and then URLs
24:09
HTTP and it's going to be
24:16
55 so let's go ahead and execute this
24:22
remember I'm using components Pad but that
24:35
okay so this is running right so let's I don't know
24:43
let's use Curl or you can use posan or I want to use this conversation. HTTP file
24:51
that most of the time we're ignoring but this is so helpful since you can send those
24:58
requests to the endpoints right here and you have that in Source
25:04
control uh so 5500 and conversation is the
25:12
endo and I want to use content type application Json
25:17
and uh message right
25:24
message message is going to be hi
25:30
or something right for instance let's send a helpful prompt such as what are
25:37
the largest countries in the
25:43
world okay so you can see that you don't need to be executing this project you don't
25:51
need to be debugging the application you can send the request right
25:56
away so method not allow of course because this is not a a get is
26:02
supposed sorry about that send request and
26:11
then the largest countries in the world by total area are Russia and Canada
26:18
China the United States Brazil and so on so this is very
26:24
helpful and you can see that opening ey is the one that is responding specifically um g u GPT 40
26:32
mini is the one that is responding okay very very
26:41
helpful and I wonder about thatp uh
26:48
II so let's do the following let's see what we can do
26:55
here so comerse Asing
27:00
it has dopper conversation component name inputs and then
27:08
options okay options new what we have here let's see
27:15
conversation options there's nothing in the static
27:21
world so new conversation options and I can pass okay I can pass a
27:29
conversation ID very useful if you want to do something like you know
27:35
threads um or I don't know chat and
27:41
then threads right and then thread ID and use that thread ID right here and
27:48
pass that thread ID to this conversation options object um so that's the idea
27:58
what else we have here conversation options I think that's the only thing that we have today remember this is an
28:06
alpha version of the component
28:13
and uh so conversating inputs so here in inputs
28:21
you can specify that scrub pii let's turn it
28:27
into to True represents an input for the doer conversational
28:33
API uh if true scrubs the data okay okay so I think we're ready to test this
28:41
let's see what happens doer on again and let's go back and create another
28:52
prompt and I don't know uh let's see uh
29:01
I don't know let's um return what's the distance between one
29:09
Microsoft way that's an address in Redmond Washington
29:16
and uh I don't know uh let's
29:21
see and the safe C Is that the name of the stadium
29:35
Seattle so let's see the distance between one micr
29:40
away uh so it's not it's not obus skating maybe I'm
29:46
doing something wrong right so I don't know let's try another
29:54
thing uh change this personal information to
30:00
uppercase uh my name just like this I want everything in
30:05
uppercase let's see what's going on and send a request and it's not off
30:14
skating yeah I think something is missing in my code I'm setting this
30:19
personal identifi information uh property as
30:26
true and if true SC the data that goes into the LM yeah maybe I'm doing and this is not
30:33
the the correct demo for scrub pii uh anyway we have that there and
30:41
it's uh very useful we can refer to the
30:47
documentation anyway I want to go back
30:52
and um keep this um prompt that I was sending beforehand
31:00
okay and I think that's it I think that's it
31:05
and you can see that the conversation building block is quite useful uh but of course it's an an in an
31:14
alpha State uh if you want to build something more robust
31:21
or I don't know production ready maybe you can use this don't don't
31:28
get me wrong I think it's it's it's fantastic but maybe there are other
31:34
Frameworks more capable with more options if that's your uh
31:40
goal uh and of course we need to keep on
31:45
looking for those changes in the dopper conversation building block and let's
31:50
wait for the team and the community to uh evolve and continue uh polishing
31:57
this component which is fantastic I'm very excited to have this in Dapper for
32:05
um some um some things uh some practical
32:10
things um and but of course for from a
32:16
Enterprise point of view maybe I would use something else such as semantic kernel or other framework anyway this is
32:25
great this is fantastic great work in the Doer conversation building blog
32:30
and you know what this is the last session of the
32:40
series I'm so so happy that we made it through the end and if you made it to
32:46
the end as well congrats um I'm sure you know more about
32:53
Dapper than when you started back in December and some Shameless plug I have some
33:03
courses about Dapper in LinkedIn learning uh that you can
33:09
use and I'll be continue creating Dapper
33:15
content um and yeah yeah yeah um just uh
33:22
T take that into account and I think that's it I think that's it
33:29
and this is it friends this is it and thank you very much for the
33:35
c.com team and the entire crew for having me 13 sessions today's
33:43
over and keep on uh creating fantastic applications
33:49
with Dapper and happy coding my friends okay see you next time