ai-agents-for-beginners

Course Setup

Introduction

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

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 the link to fork the repo

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

Forked Repo

Running the Code

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:

Requirements

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.

Set Up for Samples using GitHub Models

Step 1: 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 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 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.

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

Step 1: Retrieve Your Azure Project Connection String

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 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.

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)

Management Center

Models + Endpoints Page

Azure Portal

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

from azure.identity import DefaultAzureCredential, InteractiveBrowserCredential

Stuck Somewhere?

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

Next Lesson

You are now ready to run the code for this course. Happy learning more about the world of AI Agents!

Introduction to AI Agents and Agent Use Cases