Skip to content

Latest commit

 

History

History
107 lines (63 loc) · 4.71 KB

File metadata and controls

107 lines (63 loc) · 4.71 KB

Course Setup

Introduction

This lesson will cover how to run the code samples of this course.

Requirements

  • A GitHub Account
  • Python 3.12+
  • Azure Subscription
  • Azure AI Foundry Account

Clone or Fork this Repo

To begin, please clone or fork the GitHub Repository. This will make your own version of the course material so that you can run, test and tweak the code!

This can be done by clicking link to fork the repo

You should now have your own forked version of this course in the following link:

Forked Repo

Retrieve Your GitHub Personal Access Token (PAT)

Currently this course uses the Github Models Marketplace to offer free access to Large Language Models(LLMs) that will be used to create AI Agents.

To access this service, you will need to create a GitHub Personal Access Token.

This can be done by going to your Personal Access Tokens settings in your GitHub Account.

Select the Fine-grained tokens options on the left side of your screen.

Then select Generate new token.

Generate Token

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

Add this to your Environment Variables

To create your .env file run the following command in your terminal:

cp .env.example .env

This will copy the example file and create a .env in your directory, fill in the values for the environment variables. You can locate the values for each environment variable in the following locations of the Azure AI Foundry portal:

Open that file and paste the token you created into the GITHUB_TOKEN= field of the .env file.

  • AZURE_SUBSCRIPTION_ID - On the Overview page of your project within Project details.
  • AZURE_AI_PROJECT_NAME - At the top of the Overview page for your project.
  • AZURE_OPENAI_RESOURCE_GROUP - On the Overview page of the Management Center within Project properties.
  • AZURE_OPENAI_SERVICE - On the Overview page of your project in the Included capabilities tab for Azure OpenAI Service.
  • AZURE_OPENAI_API_VERSION - On the API version lifecycle webpage within the Latest GA API release section.
  • AZURE_OPENAI_ENDPOINT - On the Details tab of your model deployment within Endpoint (i.e. Target URI)

Install Required Packages

To ensure you have all the required Python packages to run the code, run the following command into your terminal.

We recommend creating a Python virtual environment to avoid any conflicts and issues.

pip install -r requirements.txt

This should install the required Python packages.

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 to sign in to your Azure account.

Sign-in to Azure

Login with your Azure AI account used to provision the Azure resources.

Open a new terminal and enter the following command and follow the instruction in the terminal:

az login --use-device-code

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

Access the environment variables.

We'll import os and load_dotenv so that you can access the environment variables.

import os
from dotenv import load_dotenv

load_dotenv()

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 function to get the credential.

from azure.identity import DefaultAzureCredential, InteractiveBrowserCredential

You are now ready to run the code of this code, happy learning more about the world of AI Agents!

If you have any issues running this setup, hop into our Azure AI Community Discord or create an issue.