How to use Microsoft Azure AI Studio and Azure OpenAI models
Summary
TLDR本视频介绍了微软Azure AI Studio,一个集成了多种AI服务和工具的平台。视频分为五部分,包括Azure AI Studio概览、在Azure Open AI上构建模型、从CSV或数据库导入数据、配置和部署模型以及API的使用和访问。通过实际演示,展示了如何使用GPT-4模型创建项目、设置系统消息、添加变量、测试提示、使用提示流、添加数据源、部署模型以及如何通过API在项目中使用模型。视频内容丰富,适合初学者和专业开发者。
Takeaways
- 🌐 视频介绍了Azure AI Studio,这是一个集成了微软多种AI服务的工具平台。
- 🔧 视频中讲解了如何在Azure AI Studio上构建模型,并使用Azure Open AI服务。
- 📊 演示了如何从CSV或数据库导入数据到模型中。
- 🚀 展示了如何配置和部署AI模型。
- 🔗 讨论了API的工作原理以及如何使用和访问模型以用于项目。
- 🤖 强调了Azure AI Studio支持自定义数据以改善提示功能。
- 🎨 介绍了如何使用prompt flow功能来创建和定制模型的工作流程。
- 🔍 说明了如何整合内容安全过滤器以减少潜在的问题。
- 📚 展示了如何将多个AI能力结合起来,以产生更先进的生成性AI解决方案。
- 📈 提供了Azure AI Studio网站上不同模型的预览,并演示了如何选择合适的模型。
- 🔑 演示了如何在Azure AI Studio中添加数据源,并展示了如何上传文件以供模型查询。
- 🛠️ 讨论了如何在Azure AI Studio中进行模型部署,并如何通过API在项目中使用模型。
Q & A
Azure AI Studio 是用来做什么的?
-Azure AI Studio 是一个集成了微软多种人工智能服务的工具平台,包括Azure OpenAI、机器学习和语音、视觉服务等。它可以帮助开发者构建更复杂的AI应用,无论是初学者还是专业开发者都可以使用。
视频中提到了哪些Azure AI Studio的主要功能?
-Azure AI Studio的主要功能包括:部署模型、测试模型、导入数据(如CSV文件或数据库)、配置和部署模型以及使用API访问模型。此外,还可以定义提示流程、集成内容安全过滤器以及结合多种AI能力来创建高级的生成性AI解决方案。
如何在Azure AI Studio中创建新项目?
-在Azure AI Studio中,用户可以登录后返回到工作室仪表板,选择创建新项目,并为项目命名,例如命名为'Azure AI Studio demo example'。然后,用户可以选择一个模型来使用,如GPT模型,并进行部署。
Azure AI Studio支持哪些类型的AI模型?
-Azure AI Studio支持多种类型的AI模型,包括来自Meta和微软自家的模型,以及Azure OpenAI的模型。用户可以在Azure AI Studio网站上预览所有可用的模型。
如何在Azure AI Studio中添加数据源?
-用户可以在Azure AI Studio的'添加数据'部分选择添加数据源,可以选择Azure AI搜索、Azure Blob存储或上传文件。完成这一步需要选择Azure订阅、Azure Blob和搜索资源,然后上传文件,文件上传并索引后即可用于模型。
Azure AI Studio中的提示流程是什么?
-提示流程是Azure AI Studio的一个特色功能,它允许用户通过可视化的方式展示复杂的提示操作。用户可以创建自定义的提示流程,并在流程中添加步骤,以便在输入生成前或后进行定制化处理。
如何在Azure AI Studio中部署AI模型?
-用户可以在Azure AI Studio的部署选项卡中查看已部署的AI模型实例,并创建新的部署。选择创建实时端点,选择所需的模型,确认后即可部署模型。如果需要访问特定模型,可能需要向Azure OpenAI服务团队申请访问权限。
如何使用Azure AI Studio的API?
-用户可以在Azure AI Studio的部署部分获取模型的端点URL和密钥,然后在编程项目中使用这些信息来调用API。例如,可以使用Python、JavaScript或其他语言的代码模板来实现与API的交互。
视频中提到了哪些编程语言和工具?
-视频中提到了JavaScript作为编程语言,并使用了Visual Studio Code作为代码编辑器。此外,还提到了Azure OpenAI服务、Azure AI Studio和Azure Blob存储等微软的AI服务和工具。
如何在JavaScript项目中使用Azure AI Studio的API?
-在JavaScript项目中,首先需要安装`openai`包,然后通过环境变量传递API密钥和端点URL。接着,可以编写一个异步函数来初始化OpenAI客户端,并通过客户端调用`getChatCompletion`方法来获取AI生成的文本。
视频中提到的'变量'在Azure AI Studio中的作用是什么?
-在Azure AI Studio中,'变量'可以在系统提示和聊天提示中被调用,用于构建和定制化AI模型的功能。例如,可以创建一个名为'languages'的变量,并在系统提示中使用双波浪括号引用该变量,以便在AI会话中根据变量值进行相应的操作。
Azure AI Studio中的'内容安全过滤器'有什么作用?
-Azure AI Studio中的'内容安全过滤器'可以帮助开发者减少生成的AI内容中可能存在的问题,如不当内容。通过集成这一功能,可以根据构建解决方案的类型来减轻潜在的有害问题。
Outlines
🚀 介绍Azure AI Studio及其功能
本段落介绍了Azure AI Studio,这是一个集成了微软多种AI服务的工具平台,如Azure OpenAI机器学习和语音、视觉服务。视频将分为五部分,包括Azure AI Studio概览、在Azure OpenAI上构建模型、从CSV或数据库导入数据、配置和部署模型以及API的使用。感谢微软赞助,视频将主要基于微软Azure服务构建。Azure AI Studio允许用户部署模型、测试、添加自定义数据以改善提示、定义工作流程似的提示流、集成内容安全过滤器以及结合多种AI能力来生成更高级的AI解决方案。
📚 如何使用Azure AI Studio添加和管理数据
在这一部分中,讲解了如何在Azure AI Studio中添加和管理数据。首先,用户可以选择添加数据源,如Azure AI搜索、Azure Blob存储或上传文件。上传文件后,文件将被索引并可用于模型。此外,用户可以在数据部分下查看和管理已上传的数据。通过上传的文件,模型可以引用文档内容来更准确地回答查询。还展示了如何通过提示流使用自定义数据源,以及如何在Azure AI Studio中部署AI模型。
🛠️ 使用Azure AI Studio部署模型和访问API
这部分内容讲解了如何在Azure AI Studio中部署模型以及如何通过API访问模型。首先,用户需要请求Azure OpenAI服务团队的访问权限。一旦获得批准,用户可以选择不同的模型进行部署,并立即使用。视频还展示了如何在playground中切换模型版本,以及如何启用增强功能。接下来,讲解了如何使用API进行项目开发,包括获取目标URL和密钥、在代码中使用预设提示、以及如何在Visual Studio Code中设置和使用环境密钥和端点URL。最后,通过一个简单的JavaScript示例,展示了如何使用Azure AI Studio生成代码提示。
🔧 编写代码以使用Azure AI Studio API
本段落详细介绍了如何编写代码以使用Azure AI Studio的API。首先,需要在Visual Studio Code中安装Azure OpenAI包,并设置环境密钥和端点URL。然后,创建一个新的JavaScript文件,初始化OpenAI客户端,并定义一个提示。通过调用客户端的getChatCompletion方法,传入模型和提示,即可获取AI生成的回复。最后,通过循环遍历结果并打印输出,展示了如何使用API完成句子。视频还提供了相关项目的链接,供用户进一步学习和探索。
Mindmap
Keywords
💡Azure AI Studio
💡模型构建
💡数据导入
💡配置和部署
💡API访问
💡Prompt Flow
💡内容安全过滤器
💡自定义提示
💡变量
💡响应温度
💡代码提示
Highlights
视频将介绍Azure AI Studio,这是一个对于初学者或专业开发者构建复杂项目都非常有用的工具。
视频分为五个部分,涵盖Azure AI Studio的介绍、在Azure Open AI上构建模型、导入数据、配置和部署模型以及API的使用。
感谢Microsoft对视频的赞助,我们将主要基于Microsoft Azure服务进行操作。
Azure AI Studio集成了Microsoft的多种工具,如Azure Open AI、机器学习和语音视觉服务等。
用户可以在Azure Open AI服务上部署模型,添加自定义数据以优化提示,如使用数据库或文件。
Azure AI Studio支持定义提示流程,类似于流程图,允许用户创建和定制模型及其功能。
可以集成内容安全过滤器,帮助减轻解决方案构建过程中的潜在问题。
Azure AI Studio支持结合多种AI能力,以产生更先进的生成性AI解决方案。
Azure AI Studio网站提供了多种不同的模型,包括来自Meta和Microsoft的模型。
用户可以选择使用GPT-4模型,但需要先登录账户。
在Azure AI Studio的主控制面板中,用户可以创建新项目并选择模型进行使用。
Azure AI Studio的独特之处在于其提示流程功能,允许用户可视化地展示复杂的提示过程。
用户可以通过添加数据源来向模型中添加数据,支持Azure AI搜索、Azure Blob存储和文件上传。
上传文件后,用户可以在数据部分中管理这些数据,并对其进行标签化或上传新版本。
Azure AI Studio支持在Azure上进行模型部署,用户可以创建新的实时端点进行模型部署。
用户可以通过API将Azure AI Studio集成到实际项目中,支持多种编程语言和格式。
视频提供了如何使用Azure AI Studio进行项目开发的详细步骤和示例。
Transcripts
in this video I'm going to cover Azure
AI Studio which is useful if you're
looking to build something a bit more
complex as either a beginner or a
professional developer at a company
there'll be five parts to this video
first I want to take a look at Azure AI
Studio second we'll take a look at how
to build models on top of azure open AI
Third how to import data to a model from
like a CSV or a database fourth how to
configure and then deploy that model and
then fifth how the API works and how to
use and access that model for a project
now I'd also like to thank Microsoft for
sponsoring this video a lot of what we
do today will be built on top of
Microsoft Azure service so if you want
to learn a little bit more about that
I'll add links in the description below
Azure AI studio is a combination of
tools from Microsoft such as Azure open
AI machine learning and other AI
services such as speech and vision all
in a central place with it I'm able to
do things like deploy models and test
them on the aure openai service I can
add custom data for better prompting
such as using a database or a file or a
document or even a web address I can
Define prompts to work almost like a
flowchart this means that the prompt
flow feature allows you to create and
customize the models and how they
function I can also integrate content
safety filters this helps me mitigate
problems like harm depending on the type
of solution I'm building I can also
combine multiple AI capabilities to
produce a much more advanced generative
AI solution here is the Azure AI Studio
website I'm going to link it in the
description below what's pretty
interesting is that there are quite a
few different models here ones from meta
as well as ones from Microsoft
themselves and the ones here from Azure
open AI which we'll be looking at today
if you want to take a look at all the
models and the catalog then you can
select here to preview all of them
there's quite a few including Nvidia the
Microsoft research program and Desi AI
and many more for this example I'm going
to select Azure open Ai and I'm going to
select to use the GPT 4 model but I'm
going to need to sign in first so I'm
going to sign in with my user account
once done I'm taking back to the studio
dashboard and here I'm going to have the
option to create a new project as well
as select a model to use I'm going to
create a project called Azure AI Studio
demo example then I'm going to scroll
down and select to use the GPT model
over here so that I can get this
deployed and start using the studio
properly to deploy it I just give it a
deployment name and connect it to one of
my projects this takes me into the main
dashboard for Azure AI Studio the main
part here is the playground if you've
used AI playgrounds in the past this is
very similar you have your AI settings
for the system on the left hand side the
chat dialogue in the middle and
additional parameter configurations on
the right what makes Azure AI Studio
unique is a few other things such as the
prompt flow which which will'll create
later as well as being able to manage
your data here in this data section
heading back to the playground let me
set up a basic environment that we can
utilize so I can show you how some of
these things work the system message is
what initializes the context for the AI
and its chat session you can write
whatever you want here and there is no
limit but be aware that it does count
towards your token limit for this
example I'll say that this is a coding
assistant AI helping me solve problems
now there's also Al something called
variables I'm going to add one right now
called languages and in programming
there's lots of different programming
languages so I'm going to create a
language that we're currently using
which will be JavaScript this variable
can now be called inside of system
prompts as well as chat prompts and this
can be useful if you're building out an
application I can reference this
variable inside of my system prompt
using the double squiggly bracket I'll
select apply changes and continue to
make sure that this model is now updated
I'm going to test all of this out by
adding a simple prompt here hello what
are you and the response back here from
the AI is that they're a coding
assistant helping me explain problems in
JavaScript on the top menu here we have
playground settings if you select it you
can select which language the AI uses
what subscription you're utilizing and
if you want speech you can add a speech
resource too I'm going to select a save
for this and on the right hand side we
have parameters you've probably seen
this before where you can set the
response the temperature top PE but most
of these things is useful to keep on
default unless you're specifically
customizing it for an application I'll
have chat history and most of my chats
will continue on in the form that the
system message presents which is in
JavaScript with an explanation of what's
happening on the top right here I can
change the mode from chat to completions
or images and this is useful if you're
using other models right now since I'm
using GPT 3.5 turbo it doesn't have
images or completions but I can swap the
models around by selecting a different
deployment one toggle I like is so Json
which allows you to see the raw inputs
and outputs that are being sent to and
from the API these include the system
message as well as messages from the
user and the AI assistant and it's
perfect if you want to copy and paste
these into just some programming code
prompt flows is another feature from
Azure AI Studio which has the ability to
visually showcase exactly what's
happening in a more complex prompt I'll
create one here using the custom prompt
flow option and it's going to generate
this in the prompt flow area it's a
visual on the right hand side of an
input a chat and an output on the left
hand side I see some of the raw code of
what's actually happening in the
background and this is where I can
customize it whether I want to add more
steps in this process before or after an
input gets generated heading back to the
prompt flow dashboard let me create one
from scratch there's a few different
types you can select from standard to
chat flow to eval and there's 's also
some pre-existing ones you can use as a
demo to get a better idea of how they
function let me show you this one with
chat with Wikipedia since it's doing a
few interesting things like using python
adding a few steps and accessing the
internet once it's loaded here on the
right hand side I can see exactly what's
happening which is it's extracting the
query from a question grabbing the URL
from Wikipedia then searching through
the results of that URL and then then
processing those search results to send
back to the AI while this might seem a
bit complex and you'll need to know a
little bit of python and other things to
be able to code this this is more or
less just an example of the scalability
that you can build out if you want to
learn how to utilize this properly now
I'm going to show how to add data to
your model here on the left select add
your data then select to add a data
source this is probably one of the more
useful features here in add data you can
select from the data sources being Azure
AI search Azure blob storage and upload
a file which I'll be showing in this
example to complete this step you'll
need to select your Azure subscription
you may need to also select your Azure
blob and search resource but once you're
done select the name of the index select
acknowledge and select next this will
bring you to the upload file section you
can drag and drop any kind of file that
is readable such as text or documents or
PDFs I've got this nice handbook from
Flavio CZ which I'm going to be using
which is kind of like a handbook on
nextjs if you have internal company
documentation PDFs or resources you want
to query the model this is the perfect
place to upload it I'll drag and drop it
and upload it just here selecting next I
can select the search type to be keyword
or semantic be aware that using semantic
search will incur a cost using Azure you
can always fall back to keyword
processing here in the background it
will upload the file and once it's done
it'll index it and it'll be available to
use mine's just finished so let me try
out a prompt since the file was about
nextjs I'm going to ask it what's the
best way to run a server side action on
a file the response I get back is an
example of a bit of code with some
information about what this piece of
code is doing and if you have a look
closely here at the bottom you'll notice
that it is referencing the document that
I've actually uploaded earlier I can see
the citations it's using as context to
be able to answer this query properly
this can be customized further in the
advanc section
with how similar or strict content is
when you do upload files or data you can
head over to the data section under
components to see it I've got one here
for index.js and another one here I
created for search index I can select
these and I can see the current version
on one which is version one I can add
tags to them or I can even upload a new
version if I head back to the playground
and go to add your data I can also
remove the data source if I'm no longer
using that specific one or even if I
wanted to change it what's pretty
interesting is that if you load up the
prompt flow with a custom data source
you get to see a little bit of what's
Happening behind the scenes here you'll
see that inputs have a determined intent
which extracts the intent and retrieves
the document then it formulates a reply
and sends that reply to the user under
the hood there is actually quite a few
complex prompts happening here which is
useful if you want to learn some prompt
engineering now I want to show how to do
some deployments on Azure AI studio and
while you can deploy a web app we might
take a look at that a little bit later
when I select the deployments tab I've
got a few examples of instances of the
AI model that I've already deployed and
I can also create new ones if I want
these are currently on Chad GPT 3.5
turbo I might want to deploy a model on
Chad GPT version 4 by selecting create
and selecting realtime endpoint I've got
a number of options for models here
these actually are all the models
available and I can select GPT 4 right
here selecting confirm I'm taking to one
more step to deploy the model but I do
have an error here to get access to this
model I do need to put in a request to
the Azure openi service team here in the
documentation I can select apply now and
this takes me to the form to request
access I filled this out earlier passing
in my subscription ID and it was quite
quickly approved heading back to
deployments I can select GPT 4 now and
I'm going to select the model that comes
with vision I'm going to ignore this
message because I do know that I have
requested and confirmed my approval
selecting create has deployed the model
and now it's available for me to use
immediately in the playground or with
the API which I think we'll take a look
at next inside of the playground on the
right hand side under deployments I can
select to swap it from GPT 3.5 to GPT 4
I can also enable enhancements which for
example allows me to add Vision to the
this model but you will need to enable
this aure service now the final part I
want to take a look at using the API for
an actual project that I might be coding
under deployments I've got my ader and
twarog chat GPT 3.5 turbo example and in
this example I have the target URL this
is kind of of like the endpoint as well
as the key that I can pass in as an
environmental key the other thing here
is the playground itself under
playground there's a useful Little Thing
Called view code if I select the this
button I actually get a preview of a
pre-made prompt that I could use inside
of some code this one's in Python and
it's got the python configuration for a
chat completion with the URL endpoint
and the key that I need I can also view
this in other languages like cop as well
as in just a Json format if I'm using a
different language like JavaScript or
typescript which I think I'll do next by
selecting a learn more I can actually go
to the documentation website and here
I'll have a lot more more info on how to
configure using it inside of a project
since I want to use JavaScript I'm going
to select the JavaScript option and the
main thing here that I need is the keys
as well as the endpoint URL inside of
the Microsoft Azure dashboard I can
search up Azure AI Studio these are all
the instances that I've created so far
what I'm going to do is select the
latest one and instead of selecting to
launch the AI Studio what I'm going to
do instead is scroll down and see the
keys as well as the endpoint URL which I
can now connect inside of a coding
project inside of vs code here's a brand
new empty project in vs code I'm going
to create a file called index.js in
order to query Azure open AI I need to
install the package so here I'm going to
install at Azure slopen aai next I need
to pass the environmental keys so I'm
going to create another file here called
EnV and the two keys I need is the API
key and the endpoint let me select to
copy these from the documentation and
paste these in let me delete the syntax
so it's properly assigned for JavaScript
here I'll add one more environmental key
the model itself which I'll set a little
bit later on for this example I'm going
to deploy out a new model I'm going to
select deploy a real-time model and this
model will be the GPT 3.5 turbo instruct
model once deployed I'll need to grab
the key as well as the URL that I'm
going to use for the endpoint so for the
URL I'm going to select to the
playground I'm going to go to the view
code section and I'm just going to pull
the open AI base URL from here I'm also
going to grab the model itself or the
engine as they put it here and this
engine will have the following name
gpt-3 dturbo d instruct finally I'll
head back to deployments and select the
deployment model once more and here I'm
going to copy out the key and paste this
in here now make sure you keep this
private and Anonymous and don't share
this out publicly because it is what
authorizes all of your requests
now back to the index.js file here I'm
going to require the constant values of
open AI client and the Azure key
credentials from at aure slopen aai now
I want some environmental keys to be
used our require. EnV which we installed
earlier calling config what I can do now
is call const endpoint is equal to
process. env. aure open AI endpoint and
this can save it to the value endpoint
I'll do the same for the API key
as well as for the model itself I also
want to define a prompt so I'm going to
do cons prompt is equal to and in an
array I'm going to add the string the
best way to do Hello World in JavaScript
is buy I've done it this way because
it's not a chat but a chat completion
I'll be doing next I want to run a
function but I just want it to
automatically run so inside brackets
I'll do Asing function as an arrow
function and I'll call it straight after
inside of this asnc function I'm going
to do console log and begin this chat
completion I'll initialize the client by
calling cons client is equal to new open
AI client here I'll pass in the endpoint
as well as the Azure key for the API I
also need to add the deployment ID so
I'll pass it in here calling the
environmental key that I had earlier set
to model finally I'm going to call this
chat completion I'll const out the
results here and call await client.
getet chat completion and then I'll pass
in the model through deployment ID as
well as the prompt I said earlier to
view the results I'll have to Loop
through them so I'll call for cons
choice of results. choices and here I'll
just console log out the choice. text
and that's basically it I can now open
up the terminal and run this function
and hopefully I'll get the result back
to run it I'll call
node. index.js and here I've got a
response back open your code editor of
choice and then and as you can see it
hasn't finished the final line because
this is a chat completion there's
probably a default token limit but it
gives you an example of how this API
completes the sentence of what you're
writing if you want to learn a little
bit more I've added a link in the
description which gives you access to
this repo of this project I've worked on
as well as the ability to sign up to
Azure AI studio and its documentation to
learn more I'll be covering a few more
videos on Microsoft Azure open a AI so
if you're interested in any specific
topics or projects then let me know in
the description below otherwise I hope
you guys enjoyed this video
5.0 / 5 (0 votes)