>> [MUSIC]
> Hopefully you've all been watching
the news and you're seeing there is a little bit of
a topic called OpenAI that's
been sweeping our industry and honestly,
every industry for the last few months.
Today, we've got special guest,
Julia Kasper here to show you and us
how to do OpenAI meets local. Over to you.
>> Awesome. Thank you, Donna. Yes, you saw right.
Over the last couple of weeks,
social media feeds have been flooded
with conversations about ChatGPT and OpenAI.
Today, we want to look and see how we
can integrate OpenAIs technology and
the Microsoft Power Platform and
empower our Power platform developers and
how they can use this technology and
build super cool use cases for themselves.
Let's start. What is OpenAI?
OpenAI first of all,
it's a research company and deployment company.
They provide a bunch of public available APIs and grant
access to their super powerful and
AI trained models using these APIs.
For today's session, we want to focus on
one OpenAI API and built
a next-gen application using Microsoft Power Apps with it.
Let's have a look at those public APIs first.
For this, we can just simply scroll through the documentation
here and we can see an API reference documentation here.
For today's use case,
we want to focus on the Create image endpoint.
First of all, the Create image endpoint is
an API that uses the underlying model called DALL.
E 2, which is basically just another version of GPT-3.
Now is the question,
how do we get from here to
the Microsoft Power Platform and how can
we use this endpoint
within the Microsoft Power Platform, as well?
Most importantly, we want to think
about it in a secure and governant way.
This is why we are introducing or using
Azure API Management as our API gateway service to
provide a consistent and secure access to
our backend services and in our use case, an OpenAI API.
First of all, we have to import or add
the API to our Azure API Management instance.
As you can see, Azure API Management
supports a bunch of different types of API.
There are bunch of different ways how to import
this API to your instance, for example,
you can also just input it
using one of your existing Azure resources, as well.
For our use case,
we just simply manually added
the OpenAI endpoint to our Azure API Management instance.
All of this documentation can be found here,
and we simply just edited and filled out
the manually HTTP API form here.
Went ahead and added this API to
my Azure API Management instance and
I added the operation Create image here.
Using Azure API Management,
I'm able to modify
the request before it goes out to our backend service,
I'm using a bunch of different policies.
Policy help us modify the behavior of the API and
it even lets us add extra security layers on top of it.
In my use case,
I added a policy called set-header
here because I don't want to worry about authentication.
By modifying the APIs header,
I'm able to pass along an API key,
so authentication just works,
and I also don't have to think about it or worry about it
from a Microsoft Power Platform perspective, as well.
Now that we configured and set everything up here,
we want to test it in the Azure Portal, as well.
For this, I can quickly head the test and tab right here,
and before I'm hitting the Send button,
you can see for me being able to successfully call the API,
I need to first define a request body because
my API endpoint needs a bunch of parameter for me to work.
All of this can be also configured in Azure API Management,
and you can see I added a bunch of
different properties that my endpoint needs.
Now that I configured this,
I will quickly just hit the Send button here.
Let's wait.
It's always the beauty about a live demo, but perfect,
200 and everything worked and I can see the response here,
my body as well.
Now that we tested it in the Azure API Management portal,
we want to expose it to the Microsoft Power Platform.
For this, I can easily use the Power Platform tab
right here and create a so-called custom connector.
I can choose whatever API I
want to expose to the Microsoft Power Platform,
and I can choose which environment I
want the exposure or the integration to work with.
As soon as I hit the Create button,
a so-called custom connector will
be available on the Power Platform side.
So custom connector, as we learned before during Daniel's session,
is basically just a wrapper around a rest API,
and in our use case,
it's a wrapper around the OpenAI API.
As you can see,
as soon as this has been successfully created,
I can find my custom connector via
the Custom connector tab in the Microsoft Power Platform.
I also want to test it within the portal here.
I can quickly jump to the testing tip here,
and as you can see,
all the configurations I did on
the Azure API Management side are
now reflected in the Microsoft Power Platform,
as well, and the request body gives me indication what
the API endpoint needs for my call to be successful.
I can also switch to the raw body here,
which I will do.
I will copy the parameters for
my documentation page and hit the Test operation button.
You can see it's loading,
fingers crossed and I'm getting a 200,
perfect and my body response is here, as well.
Now that we tested it on the Power Platform side as well,
we want to see what this looks like in an actual Power App.
For this reason, I build a very simple application in
Power App to showcase what this OpenAI can do.
First of all, I need to add
my custom connector to the Power App itself, as well.
Just make sure via the Data tab,
you have added the custom connector here as well,
and now, you are able as
the Power Platform developer to
use this functionality here, as well.
In my use case, every
time I'm hitting the Generate Picture button,
I want to make an API call.
For this, I just simply reference a custom connectors name.
I reference the operations name,
and then in the brackets,
adding my request body depending on
the variables I want to pass along with my call.
Let's see what this will look like in action.
Because I know yesterday was Valentine's Day,
let's see what OpenAI comes up with for
a gift for Valentine's Day.
Let's hit the Generate Picture button.
You can see it's loading all the way up here, and perfect.
I can see flowers,
I can see jewelry.
Maybe I should send my partner this app in the future so he
can get some inspiration what to
send me next year for Valentine's Day.
But let's recap what we learned today.
Today, we saw how we can integrate
an open endpoint API with our Microsoft Power Platform here.
We use this by using Azure API Management to add
some extra security and to do this in a governant way.
Now, our citizen developers or even Power Platform developers,
all of them can use the beauty of
OpenAI and build their own pretty cool applications with it,
as well. Now, back to you, Donna.
>> I'm freaking out, people,
because that is cool.
This is really cool.
Actually, it's so cool.
I would like to implement this in the top-secret project I'm
working on that my boss now knows about because I told all of you.
But I want to move
your solution to my environment, my Team's environment.
I actually think our next presenters
Karthik and Casey are going to show
us how to do exactly that with
ALM, Application Lifecycle Management.