ai-agents-for-beginners

Course Setup

Introduction

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

Join Other Learners and Get Help

Before you begin cloning your repo, join the AI Agents For Beginners Discord channel to get any help with setup, any questions about the course, or to connect with other learners.

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.

Setup VSCode

Make sure that you are using the right version of Python in VSCode.

image

Set Up for Samples using GitHub Models

Step 1: Retrieve Your GitHub Personal Access Token (PAT)

This course leverages the GitHub Models Marketplace, providing free access to Large Language Models (LLMs) that you will use to build AI Agents.

To use the GitHub Models, 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.

Please follow the Principle of Least Privilege when creating your token. This means you should only give the token the permissions it needs to run the code samples in this course.

  1. Select the Fine-grained tokens option on the left side of your screen by traversing to the Developer settings

    Then select Generate new token.

    Generate Token

  2. Enter a descriptive name for your token that reflects its purpose, making it easy to identify later.

    🔐 Token Duration Recommendation

    Recommended duration: 30 days For a more secure posture, you can opt for a shorter period—such as 7 days 🛡️ It’s a great way to set a personal target and complete the course while your learning momentum is high 🚀.

    Token Name and Expiration

  3. Limit the token’s scope to your fork of this repository.

    Limit scope to fork repository

  4. Restrict the token’s permissions: Under Permissions, click Account tab, and click the “+ Add permissions” button. A dropdown will appear. Please search for Models and check the box for it. Add Models Permission

  5. Verify the permissions required before generating the token. Verify Permissions

  6. Before generating the token, ensure you are ready to store the token in a secure place like a password manager vault, as it will not be shown again after you create it. Store Token Securely

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

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