This lesson will cover how to run the code samples of this course.
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 the link to fork the repo
You should now have your own forked version of this course in the following link:
This course offers a series of Jupyter Notebooks that you can run with to get hands-on experience building AI Agents.
The code samples use either:
Requires GitHub Account - Free:
1) Semantic Kernel Agent Framework + GitHub Models Marketplace. Labelled as (semantic-kernel.ipynb) 2) AutoGen Framework + GitHub Models Marketplace. Labeled as (autogen.ipynb)
Requires Azure Subscription: 3) Azure AI Foundry + Azure AI Agent Service. Labelled as (azureaiagent.ipynb)
We encourage you to try out all three types of examples to see which one works best for you.
Whichever option you choose, it will determine which setup steps you need to follow below:
We have included a requirements.txt
file in the root of this repository that contains all the required Python packages to run the code samples.
You can install them by running the following command in your terminal at the root of the repository:
pip install -r requirements.txt
We recommend creating a Python virtual environment to avoid any conflicts and issues.
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
option on the left side of your screen.
Then select Generate new 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.
.env
FileTo 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 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.
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.
.env
FileTo 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 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_CONNECTION_STRING
field.
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.
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:
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.
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.
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_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.
AZURE_OPENAI_API_VERSION
- Visit the API version lifecycle page under Latest GA API release.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
If you have any issues running this setup, hop into our Azure AI Community Discord or create an issue.
You are now ready to run the code for this course. Happy learning more about the world of AI Agents!