How to use Microsoft Azure AI Studio and Azure OpenAI models

Adrian Twarog
29 Mar 202416:37

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

00:00

🚀 介绍Azure AI Studio及其功能

本段落介绍了Azure AI Studio,这是一个集成了微软多种AI服务的工具平台,如Azure OpenAI机器学习和语音、视觉服务。视频将分为五部分,包括Azure AI Studio概览、在Azure OpenAI上构建模型、从CSV或数据库导入数据、配置和部署模型以及API的使用。感谢微软赞助,视频将主要基于微软Azure服务构建。Azure AI Studio允许用户部署模型、测试、添加自定义数据以改善提示、定义工作流程似的提示流、集成内容安全过滤器以及结合多种AI能力来生成更高级的AI解决方案。

05:00

📚 如何使用Azure AI Studio添加和管理数据

在这一部分中,讲解了如何在Azure AI Studio中添加和管理数据。首先,用户可以选择添加数据源,如Azure AI搜索、Azure Blob存储或上传文件。上传文件后,文件将被索引并可用于模型。此外,用户可以在数据部分下查看和管理已上传的数据。通过上传的文件,模型可以引用文档内容来更准确地回答查询。还展示了如何通过提示流使用自定义数据源,以及如何在Azure AI Studio中部署AI模型。

10:01

🛠️ 使用Azure AI Studio部署模型和访问API

这部分内容讲解了如何在Azure AI Studio中部署模型以及如何通过API访问模型。首先,用户需要请求Azure OpenAI服务团队的访问权限。一旦获得批准,用户可以选择不同的模型进行部署,并立即使用。视频还展示了如何在playground中切换模型版本,以及如何启用增强功能。接下来,讲解了如何使用API进行项目开发,包括获取目标URL和密钥、在代码中使用预设提示、以及如何在Visual Studio Code中设置和使用环境密钥和端点URL。最后,通过一个简单的JavaScript示例,展示了如何使用Azure AI Studio生成代码提示。

15:02

🔧 编写代码以使用Azure AI Studio API

本段落详细介绍了如何编写代码以使用Azure AI Studio的API。首先,需要在Visual Studio Code中安装Azure OpenAI包,并设置环境密钥和端点URL。然后,创建一个新的JavaScript文件,初始化OpenAI客户端,并定义一个提示。通过调用客户端的getChatCompletion方法,传入模型和提示,即可获取AI生成的回复。最后,通过循环遍历结果并打印输出,展示了如何使用API完成句子。视频还提供了相关项目的链接,供用户进一步学习和探索。

Mindmap

Keywords

💡Azure AI Studio

Azure AI Studio 是微软提供的一个集成工具平台,它结合了Azure OpenAI、机器学习和语音、视觉等AI服务,使用户能够在一个中央位置部署模型、进行测试和定制。在视频中,Azure AI Studio 被用来展示如何构建更复杂的AI解决方案,包括导入数据、配置和部署模型等。

💡模型构建

模型构建是指在AI领域中创建和训练模型的过程,这些模型能够基于输入数据进行预测或生成输出。在视频中,讲解了如何在Azure AI Studio上构建模型,包括使用Azure OpenAI服务和导入数据来训练和优化模型。

💡数据导入

数据导入是指将数据从一个系统或格式转移到另一个系统或模型中,以便模型可以使用这些数据进行训练或提供更准确的输出。在视频中,讲解了如何将CSV文件、数据库或文档等数据导入到Azure AI Studio中的模型,以便模型可以利用这些数据提供更有针对性的回答。

💡配置和部署

配置和部署是指设置和激活AI模型的过程,使其能够在实际应用中运行和使用。在视频中,讲解了如何在Azure AI Studio中配置模型的参数,并将其部署到云端,使其可以通过API被访问和使用。

💡API访问

API访问是指通过应用程序编程接口(API)来请求和接收服务或数据的过程。在视频中,讲解了如何使用Azure AI Studio中的API来访问和使用部署的AI模型,以便在外部项目中集成和利用这些模型的功能。

💡Prompt Flow

Prompt Flow 是Azure AI Studio中的一个功能,它允许用户通过可视化的方式创建和管理复杂的提示流程。这个功能可以帮助用户定义模型如何处理输入、生成输出,并在过程中执行特定的步骤或操作。

💡内容安全过滤器

内容安全过滤器是指用于检测和过滤潜在有害内容的机制。在Azure AI Studio中,用户可以集成这样的过滤器来减轻模型可能生成的不当内容,确保生成的文本或响应符合特定的安全标准。

💡自定义提示

自定义提示是指用户根据特定需求和场景为AI模型设定的输入文本。通过自定义提示,用户可以引导AI模型按照特定的方式回答问题或执行任务。在视频中,讲解了如何在Azure AI Studio中定义和使用自定义提示来改善模型的输出。

💡变量

变量在编程和AI模型中是一种存储信息的容器,可以在不同的上下文中被引用和使用。在Azure AI Studio中,用户可以创建变量并在系统提示或聊天提示中调用它们,以便构建更复杂和动态的AI对话。

💡响应温度

响应温度是指在AI模型中调整输出的随机性或创造性的一种参数。较高的温度可能导致更多样化和创造性的输出,而较低的温度可能导致更保守和确定性的回答。在Azure AI Studio中,用户可以根据需要调整这个参数来定制模型的响应。

💡代码提示

代码提示是指AI模型根据用户的输入提供编程代码建议或解决方案的功能。在Azure AI Studio中,用户可以利用模型的代码提示能力来解决编程问题或生成代码片段。

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

play00:00

in this video I'm going to cover Azure

play00:02

AI Studio which is useful if you're

play00:04

looking to build something a bit more

play00:05

complex as either a beginner or a

play00:08

professional developer at a company

play00:10

there'll be five parts to this video

play00:12

first I want to take a look at Azure AI

play00:14

Studio second we'll take a look at how

play00:16

to build models on top of azure open AI

play00:20

Third how to import data to a model from

play00:22

like a CSV or a database fourth how to

play00:25

configure and then deploy that model and

play00:27

then fifth how the API works and how to

play00:30

use and access that model for a project

play00:33

now I'd also like to thank Microsoft for

play00:35

sponsoring this video a lot of what we

play00:37

do today will be built on top of

play00:38

Microsoft Azure service so if you want

play00:40

to learn a little bit more about that

play00:42

I'll add links in the description below

play00:44

Azure AI studio is a combination of

play00:46

tools from Microsoft such as Azure open

play00:49

AI machine learning and other AI

play00:51

services such as speech and vision all

play00:54

in a central place with it I'm able to

play00:56

do things like deploy models and test

play00:59

them on the aure openai service I can

play01:02

add custom data for better prompting

play01:04

such as using a database or a file or a

play01:06

document or even a web address I can

play01:09

Define prompts to work almost like a

play01:11

flowchart this means that the prompt

play01:13

flow feature allows you to create and

play01:15

customize the models and how they

play01:17

function I can also integrate content

play01:20

safety filters this helps me mitigate

play01:22

problems like harm depending on the type

play01:24

of solution I'm building I can also

play01:27

combine multiple AI capabilities to

play01:29

produce a much more advanced generative

play01:31

AI solution here is the Azure AI Studio

play01:34

website I'm going to link it in the

play01:36

description below what's pretty

play01:38

interesting is that there are quite a

play01:39

few different models here ones from meta

play01:42

as well as ones from Microsoft

play01:44

themselves and the ones here from Azure

play01:46

open AI which we'll be looking at today

play01:49

if you want to take a look at all the

play01:50

models and the catalog then you can

play01:52

select here to preview all of them

play01:55

there's quite a few including Nvidia the

play01:57

Microsoft research program and Desi AI

play02:00

and many more for this example I'm going

play02:02

to select Azure open Ai and I'm going to

play02:04

select to use the GPT 4 model but I'm

play02:07

going to need to sign in first so I'm

play02:10

going to sign in with my user account

play02:12

once done I'm taking back to the studio

play02:14

dashboard and here I'm going to have the

play02:16

option to create a new project as well

play02:18

as select a model to use I'm going to

play02:21

create a project called Azure AI Studio

play02:23

demo example then I'm going to scroll

play02:26

down and select to use the GPT model

play02:28

over here so that I can get this

play02:30

deployed and start using the studio

play02:33

properly to deploy it I just give it a

play02:35

deployment name and connect it to one of

play02:37

my projects this takes me into the main

play02:40

dashboard for Azure AI Studio the main

play02:42

part here is the playground if you've

play02:44

used AI playgrounds in the past this is

play02:46

very similar you have your AI settings

play02:48

for the system on the left hand side the

play02:50

chat dialogue in the middle and

play02:52

additional parameter configurations on

play02:54

the right what makes Azure AI Studio

play02:56

unique is a few other things such as the

play02:58

prompt flow which which will'll create

play03:00

later as well as being able to manage

play03:02

your data here in this data section

play03:04

heading back to the playground let me

play03:06

set up a basic environment that we can

play03:08

utilize so I can show you how some of

play03:10

these things work the system message is

play03:12

what initializes the context for the AI

play03:15

and its chat session you can write

play03:17

whatever you want here and there is no

play03:19

limit but be aware that it does count

play03:22

towards your token limit for this

play03:23

example I'll say that this is a coding

play03:26

assistant AI helping me solve problems

play03:29

now there's also Al something called

play03:30

variables I'm going to add one right now

play03:32

called languages and in programming

play03:34

there's lots of different programming

play03:36

languages so I'm going to create a

play03:38

language that we're currently using

play03:39

which will be JavaScript this variable

play03:41

can now be called inside of system

play03:43

prompts as well as chat prompts and this

play03:46

can be useful if you're building out an

play03:47

application I can reference this

play03:49

variable inside of my system prompt

play03:51

using the double squiggly bracket I'll

play03:53

select apply changes and continue to

play03:56

make sure that this model is now updated

play03:58

I'm going to test all of this out by

play04:00

adding a simple prompt here hello what

play04:02

are you and the response back here from

play04:05

the AI is that they're a coding

play04:06

assistant helping me explain problems in

play04:09

JavaScript on the top menu here we have

play04:11

playground settings if you select it you

play04:13

can select which language the AI uses

play04:16

what subscription you're utilizing and

play04:18

if you want speech you can add a speech

play04:19

resource too I'm going to select a save

play04:21

for this and on the right hand side we

play04:23

have parameters you've probably seen

play04:25

this before where you can set the

play04:27

response the temperature top PE but most

play04:29

of these things is useful to keep on

play04:31

default unless you're specifically

play04:33

customizing it for an application I'll

play04:35

have chat history and most of my chats

play04:37

will continue on in the form that the

play04:40

system message presents which is in

play04:41

JavaScript with an explanation of what's

play04:43

happening on the top right here I can

play04:45

change the mode from chat to completions

play04:48

or images and this is useful if you're

play04:50

using other models right now since I'm

play04:52

using GPT 3.5 turbo it doesn't have

play04:55

images or completions but I can swap the

play04:58

models around by selecting a different

play05:00

deployment one toggle I like is so Json

play05:03

which allows you to see the raw inputs

play05:05

and outputs that are being sent to and

play05:07

from the API these include the system

play05:10

message as well as messages from the

play05:12

user and the AI assistant and it's

play05:14

perfect if you want to copy and paste

play05:15

these into just some programming code

play05:17

prompt flows is another feature from

play05:19

Azure AI Studio which has the ability to

play05:23

visually showcase exactly what's

play05:24

happening in a more complex prompt I'll

play05:27

create one here using the custom prompt

play05:29

flow option and it's going to generate

play05:32

this in the prompt flow area it's a

play05:34

visual on the right hand side of an

play05:36

input a chat and an output on the left

play05:39

hand side I see some of the raw code of

play05:41

what's actually happening in the

play05:42

background and this is where I can

play05:44

customize it whether I want to add more

play05:47

steps in this process before or after an

play05:49

input gets generated heading back to the

play05:52

prompt flow dashboard let me create one

play05:54

from scratch there's a few different

play05:55

types you can select from standard to

play05:58

chat flow to eval and there's 's also

play06:00

some pre-existing ones you can use as a

play06:01

demo to get a better idea of how they

play06:03

function let me show you this one with

play06:06

chat with Wikipedia since it's doing a

play06:08

few interesting things like using python

play06:10

adding a few steps and accessing the

play06:12

internet once it's loaded here on the

play06:14

right hand side I can see exactly what's

play06:16

happening which is it's extracting the

play06:18

query from a question grabbing the URL

play06:21

from Wikipedia then searching through

play06:24

the results of that URL and then then

play06:26

processing those search results to send

play06:28

back to the AI while this might seem a

play06:30

bit complex and you'll need to know a

play06:32

little bit of python and other things to

play06:34

be able to code this this is more or

play06:36

less just an example of the scalability

play06:38

that you can build out if you want to

play06:40

learn how to utilize this properly now

play06:42

I'm going to show how to add data to

play06:44

your model here on the left select add

play06:47

your data then select to add a data

play06:49

source this is probably one of the more

play06:52

useful features here in add data you can

play06:54

select from the data sources being Azure

play06:56

AI search Azure blob storage and upload

play06:59

a file which I'll be showing in this

play07:01

example to complete this step you'll

play07:02

need to select your Azure subscription

play07:04

you may need to also select your Azure

play07:07

blob and search resource but once you're

play07:10

done select the name of the index select

play07:13

acknowledge and select next this will

play07:16

bring you to the upload file section you

play07:18

can drag and drop any kind of file that

play07:21

is readable such as text or documents or

play07:24

PDFs I've got this nice handbook from

play07:27

Flavio CZ which I'm going to be using

play07:29

which is kind of like a handbook on

play07:31

nextjs if you have internal company

play07:33

documentation PDFs or resources you want

play07:36

to query the model this is the perfect

play07:38

place to upload it I'll drag and drop it

play07:40

and upload it just here selecting next I

play07:42

can select the search type to be keyword

play07:45

or semantic be aware that using semantic

play07:47

search will incur a cost using Azure you

play07:50

can always fall back to keyword

play07:52

processing here in the background it

play07:54

will upload the file and once it's done

play07:56

it'll index it and it'll be available to

play07:58

use mine's just finished so let me try

play08:01

out a prompt since the file was about

play08:03

nextjs I'm going to ask it what's the

play08:05

best way to run a server side action on

play08:07

a file the response I get back is an

play08:10

example of a bit of code with some

play08:11

information about what this piece of

play08:13

code is doing and if you have a look

play08:16

closely here at the bottom you'll notice

play08:18

that it is referencing the document that

play08:20

I've actually uploaded earlier I can see

play08:22

the citations it's using as context to

play08:25

be able to answer this query properly

play08:27

this can be customized further in the

play08:28

advanc section

play08:29

with how similar or strict content is

play08:32

when you do upload files or data you can

play08:35

head over to the data section under

play08:37

components to see it I've got one here

play08:40

for index.js and another one here I

play08:42

created for search index I can select

play08:44

these and I can see the current version

play08:46

on one which is version one I can add

play08:48

tags to them or I can even upload a new

play08:50

version if I head back to the playground

play08:53

and go to add your data I can also

play08:55

remove the data source if I'm no longer

play08:58

using that specific one or even if I

play09:00

wanted to change it what's pretty

play09:02

interesting is that if you load up the

play09:04

prompt flow with a custom data source

play09:06

you get to see a little bit of what's

play09:07

Happening behind the scenes here you'll

play09:10

see that inputs have a determined intent

play09:13

which extracts the intent and retrieves

play09:15

the document then it formulates a reply

play09:19

and sends that reply to the user under

play09:21

the hood there is actually quite a few

play09:23

complex prompts happening here which is

play09:26

useful if you want to learn some prompt

play09:27

engineering now I want to show how to do

play09:30

some deployments on Azure AI studio and

play09:32

while you can deploy a web app we might

play09:35

take a look at that a little bit later

play09:37

when I select the deployments tab I've

play09:39

got a few examples of instances of the

play09:42

AI model that I've already deployed and

play09:44

I can also create new ones if I want

play09:46

these are currently on Chad GPT 3.5

play09:49

turbo I might want to deploy a model on

play09:52

Chad GPT version 4 by selecting create

play09:55

and selecting realtime endpoint I've got

play09:57

a number of options for models here

play09:59

these actually are all the models

play10:00

available and I can select GPT 4 right

play10:03

here selecting confirm I'm taking to one

play10:06

more step to deploy the model but I do

play10:08

have an error here to get access to this

play10:10

model I do need to put in a request to

play10:13

the Azure openi service team here in the

play10:15

documentation I can select apply now and

play10:18

this takes me to the form to request

play10:20

access I filled this out earlier passing

play10:22

in my subscription ID and it was quite

play10:24

quickly approved heading back to

play10:26

deployments I can select GPT 4 now and

play10:28

I'm going to select the model that comes

play10:30

with vision I'm going to ignore this

play10:32

message because I do know that I have

play10:34

requested and confirmed my approval

play10:37

selecting create has deployed the model

play10:39

and now it's available for me to use

play10:40

immediately in the playground or with

play10:42

the API which I think we'll take a look

play10:44

at next inside of the playground on the

play10:47

right hand side under deployments I can

play10:49

select to swap it from GPT 3.5 to GPT 4

play10:53

I can also enable enhancements which for

play10:56

example allows me to add Vision to the

play10:59

this model but you will need to enable

play11:01

this aure service now the final part I

play11:03

want to take a look at using the API for

play11:05

an actual project that I might be coding

play11:07

under deployments I've got my ader and

play11:10

twarog chat GPT 3.5 turbo example and in

play11:13

this example I have the target URL this

play11:16

is kind of of like the endpoint as well

play11:18

as the key that I can pass in as an

play11:20

environmental key the other thing here

play11:22

is the playground itself under

play11:24

playground there's a useful Little Thing

play11:26

Called view code if I select the this

play11:29

button I actually get a preview of a

play11:31

pre-made prompt that I could use inside

play11:34

of some code this one's in Python and

play11:36

it's got the python configuration for a

play11:38

chat completion with the URL endpoint

play11:40

and the key that I need I can also view

play11:42

this in other languages like cop as well

play11:46

as in just a Json format if I'm using a

play11:49

different language like JavaScript or

play11:51

typescript which I think I'll do next by

play11:53

selecting a learn more I can actually go

play11:55

to the documentation website and here

play11:58

I'll have a lot more more info on how to

play12:00

configure using it inside of a project

play12:02

since I want to use JavaScript I'm going

play12:04

to select the JavaScript option and the

play12:06

main thing here that I need is the keys

play12:09

as well as the endpoint URL inside of

play12:11

the Microsoft Azure dashboard I can

play12:13

search up Azure AI Studio these are all

play12:16

the instances that I've created so far

play12:18

what I'm going to do is select the

play12:19

latest one and instead of selecting to

play12:22

launch the AI Studio what I'm going to

play12:24

do instead is scroll down and see the

play12:26

keys as well as the endpoint URL which I

play12:28

can now connect inside of a coding

play12:30

project inside of vs code here's a brand

play12:32

new empty project in vs code I'm going

play12:34

to create a file called index.js in

play12:37

order to query Azure open AI I need to

play12:40

install the package so here I'm going to

play12:41

install at Azure slopen aai next I need

play12:45

to pass the environmental keys so I'm

play12:48

going to create another file here called

play12:50

EnV and the two keys I need is the API

play12:52

key and the endpoint let me select to

play12:55

copy these from the documentation and

play12:57

paste these in let me delete the syntax

play12:59

so it's properly assigned for JavaScript

play13:02

here I'll add one more environmental key

play13:04

the model itself which I'll set a little

play13:06

bit later on for this example I'm going

play13:08

to deploy out a new model I'm going to

play13:09

select deploy a real-time model and this

play13:12

model will be the GPT 3.5 turbo instruct

play13:16

model once deployed I'll need to grab

play13:18

the key as well as the URL that I'm

play13:21

going to use for the endpoint so for the

play13:23

URL I'm going to select to the

play13:24

playground I'm going to go to the view

play13:27

code section and I'm just going to pull

play13:29

the open AI base URL from here I'm also

play13:32

going to grab the model itself or the

play13:35

engine as they put it here and this

play13:37

engine will have the following name

play13:40

gpt-3 dturbo d instruct finally I'll

play13:43

head back to deployments and select the

play13:46

deployment model once more and here I'm

play13:48

going to copy out the key and paste this

play13:51

in here now make sure you keep this

play13:53

private and Anonymous and don't share

play13:55

this out publicly because it is what

play13:57

authorizes all of your requests

play13:59

now back to the index.js file here I'm

play14:02

going to require the constant values of

play14:04

open AI client and the Azure key

play14:06

credentials from at aure slopen aai now

play14:11

I want some environmental keys to be

play14:12

used our require. EnV which we installed

play14:15

earlier calling config what I can do now

play14:18

is call const endpoint is equal to

play14:21

process. env. aure open AI endpoint and

play14:24

this can save it to the value endpoint

play14:26

I'll do the same for the API key

play14:29

as well as for the model itself I also

play14:33

want to define a prompt so I'm going to

play14:35

do cons prompt is equal to and in an

play14:37

array I'm going to add the string the

play14:39

best way to do Hello World in JavaScript

play14:41

is buy I've done it this way because

play14:43

it's not a chat but a chat completion

play14:45

I'll be doing next I want to run a

play14:47

function but I just want it to

play14:49

automatically run so inside brackets

play14:51

I'll do Asing function as an arrow

play14:52

function and I'll call it straight after

play14:54

inside of this asnc function I'm going

play14:56

to do console log and begin this chat

play14:59

completion I'll initialize the client by

play15:02

calling cons client is equal to new open

play15:05

AI client here I'll pass in the endpoint

play15:08

as well as the Azure key for the API I

play15:11

also need to add the deployment ID so

play15:13

I'll pass it in here calling the

play15:15

environmental key that I had earlier set

play15:17

to model finally I'm going to call this

play15:19

chat completion I'll const out the

play15:21

results here and call await client.

play15:25

getet chat completion and then I'll pass

play15:27

in the model through deployment ID as

play15:30

well as the prompt I said earlier to

play15:32

view the results I'll have to Loop

play15:34

through them so I'll call for cons

play15:37

choice of results. choices and here I'll

play15:40

just console log out the choice. text

play15:44

and that's basically it I can now open

play15:47

up the terminal and run this function

play15:49

and hopefully I'll get the result back

play15:51

to run it I'll call

play15:53

node. index.js and here I've got a

play15:57

response back open your code editor of

play16:00

choice and then and as you can see it

play16:01

hasn't finished the final line because

play16:03

this is a chat completion there's

play16:05

probably a default token limit but it

play16:08

gives you an example of how this API

play16:10

completes the sentence of what you're

play16:12

writing if you want to learn a little

play16:13

bit more I've added a link in the

play16:15

description which gives you access to

play16:17

this repo of this project I've worked on

play16:19

as well as the ability to sign up to

play16:22

Azure AI studio and its documentation to

play16:25

learn more I'll be covering a few more

play16:26

videos on Microsoft Azure open a AI so

play16:29

if you're interested in any specific

play16:31

topics or projects then let me know in

play16:33

the description below otherwise I hope

play16:35

you guys enjoyed this video

Rate This

5.0 / 5 (0 votes)

Related Tags
Azure AIAI工作室模型构建数据导入API使用微软赞助编程助手GPT-4模型数据源部署模型
Do you need a summary in English?