Skip to content

Latest commit

 

History

History
137 lines (75 loc) · 5.89 KB

File metadata and controls

137 lines (75 loc) · 5.89 KB

在你的 GitHub 账户中。

选择 Fine-grained tokens option on the left side of your screen.

Then select Generate new token.

Generate Token

You will be prompted to enter a name for your token, select the expiration date (Recommended: 30 Days), and select the scopes for your token (Public Repositories).

It's also necessary to edit the permissions of this token: Permissions -> Models -> Allows access to GitHub Models

Copy your new token that you have just created. You will now add this to your .env file included in this course.

Step 2: Create Your .env File

To create your .env 文件,在终端中运行以下命令。

cp .env.example .env

这将复制示例文件并创建一个 .env in your directory and where you fill in the values for the environment variables.

With your token copied, open the .env file in your favorite text editor and paste your token into the GITHUB_TOKEN field.

You should now be able to run the code samples of this course.

Set Up for Samples using Azure AI Foundry and Azure AI Agent Service

Step 1: Retrieve Your Azure Project Endpoint

Follow the steps to creating a hub and project in Azure AI Foundry found here: Hub resources overview

Once you have created your project, you will need to retrieve the connection string for your project.

This can be done by going to the Overview page of your project in the Azure AI Foundry portal.

Project Connection String

Step 2: Create Your .env File

To create your .env 文件,在终端中运行以下命令。

cp .env.example .env

这将复制示例文件并创建一个 .env in your directory and where you fill in the values for the environment variables.

With your token copied, open the .env file in your favorite text editor and paste your token into the PROJECT_ENDPOINT field.

Step 3: Sign in to Azure

As a security best practice, we'll use keyless authentication to authenticate to Azure OpenAI with Microsoft Entra ID. Before you can do so, you'll first need to install the Azure CLI per the installation instructions for your operating system.

Next, open a terminal and run az login --use-device-code to sign in to your Azure account.

Once you've logged in, select your subscription in the terminal.

Additional Environment Variables - Azure Search and Azure OpenAI

For the Agentic RAG Lesson - Lesson 5 - there are samples that use Azure Search and Azure OpenAI.

If you want to run these samples, you will need to add the following environment variables to your .env file:

Overview Page (Project)

  • AZURE_SUBSCRIPTION_ID - Check Project details on the Overview page of your project.

  • AZURE_AI_PROJECT_NAME - Look at the top of the Overview page for your project.

  • AZURE_OPENAI_SERVICE - Find this in the Included capabilities tab for Azure OpenAI Service on the Overview page.

Management Center

  • AZURE_OPENAI_RESOURCE_GROUP - Go to Project properties on the Overview page of the Management Center.

  • GLOBAL_LLM_SERVICE - Under Connected resources, find the Azure AI Services connection name. If not listed, check the Azure portal under your resource group for the AI Services resource name.

Models + Endpoints Page

  • AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME - Select your embedding model (e.g., text-embedding-ada-002) and note the Deployment name from the model details.

  • AZURE_OPENAI_CHAT_DEPLOYMENT_NAME - Select your chat model (e.g., gpt-4o-mini) and note the Deployment name from the model details.

Azure Portal

  • AZURE_OPENAI_ENDPOINT - Look for Azure AI services, click on it, then go to Resource Management, Keys and Endpoint, scroll down to the "Azure OpenAI endpoints", and copy the one that says "Language APIs".

  • AZURE_OPENAI_API_KEY - From the same screen, copy KEY 1 or KEY 2.

  • AZURE_SEARCH_SERVICE_ENDPOINT - Find your Azure AI Search resource, click it, and see Overview.

  • AZURE_SEARCH_API_KEY - Then go to Settings and then Keys to copy the primary or secondary admin key.

External Webpage

Setup keyless authentication

Rather than hardcode your credentials, we'll use a keyless connection with Azure OpenAI. To do so, we'll import DefaultAzureCredential and later call the DefaultAzureCredential 函数来获取凭据。

from azure.identity import DefaultAzureCredential, InteractiveBrowserCredential

遇到问题?

如果在运行此设置时遇到任何问题,请加入我们的

下一课

你现在已经准备好运行本课程的代码了。祝你在 AI 代理的世界中学习愉快!

AI 代理介绍及代理用例

免责声明
本文件使用 AI 翻译服务 Co-op Translator 进行翻译。虽然我们力求准确,但请注意自动翻译可能存在错误或不准确之处。原始文件的原文应被视为权威来源。对于重要信息,建议采用专业人工翻译。我们不对因使用本翻译而产生的任何误解或误释承担责任。