### Initialize .NET CopilotKit Client Source: https://github.com/microsoft/agent-framework-samples/blob/main/09.Cases/GHModel.AI/README.md Commands to navigate to the project directory, install dependencies, and start the development server. ```bash cd GHModel.dotNET.AI/GHModel.dotNET.AI.Workflow.AGUI/GHModel.dotNET.AI.Workflow.AGUI.CopilotKit npm install npm run dev # Open http://localhost:3000 in browser ``` -------------------------------- ### Run the Next.js development server Source: https://github.com/microsoft/agent-framework-samples/blob/main/09.Cases/GHModel.AI/GHModel.Python.AI/GHModel.Python.AI.Workflow.AGUI/GHModel.Python.AI.Workflow.AGUI.CopilotKit/README.md Use these commands to start the local development environment. Ensure the project dependencies are installed before execution. ```bash npm run dev # or yarn dev # or pnpm dev # or bun dev ``` -------------------------------- ### Install Microsoft Agent Framework from source Source: https://github.com/microsoft/agent-framework-samples/blob/main/09.Cases/AgenticMarketingContentGen/requirements.txt Use this command to install the package locally before it is available on PyPI. ```bash pip install /path/to/agentframework/python/packages/core ``` -------------------------------- ### Install Dependencies Source: https://github.com/microsoft/agent-framework-samples/blob/main/09.Cases/AgenticMarketingContentGen/README.md Install the required packages using pip. ```bash pip install -r requirements.txt pip install agent-framework --pre # or install from source ``` -------------------------------- ### Run Python AG-UI Server Source: https://github.com/microsoft/agent-framework-samples/blob/main/09.Cases/GHModel.AI/README.md Install dependencies and run the Python AG-UI server. The server will start at http://127.0.0.1:8888. ```bash cd GHModel.Python.AI/GHModel.Python.AI.Workflow.AGUI/GHModel.Python.AI.Workflow.AGUI.Server pip install agent-framework agent-framework-ag-ui fastapi uvicorn python-dotenv python main.py ``` -------------------------------- ### Install Agent Framework Source: https://github.com/microsoft/agent-framework-samples/blob/main/03.ExploerAgentFramework/code_samples/python/02-python-agent-framrwork-ghmodel.ipynb Install the Agent Framework with complete dependencies using pip. ```bash pip install agent-framework-core -U ``` -------------------------------- ### Setup .NET Environment and Dependencies Source: https://github.com/microsoft/agent-framework-samples/blob/main/02.CreateYourFirstAgent/README.md Load required NuGet packages and local assemblies for the Microsoft Agent Framework in a C# notebook. ```csharp // Reference the core AI extensions library from NuGet #r "nuget: Microsoft.Extensions.AI, 9.9.0" #r "nuget: Microsoft.Extensions.AI.OpenAI, 9.9.0-preview.1.25458.4" // Reference local Agent Framework libraries #r "C:\\Users\\kinfeylo\\Documents\\Agent\\agent-framework\\dotnet\\src\\Microsoft.Agents.AI.OpenAI\\bin\\Debug\\net9.0\\Microsoft.Agents.AI.OpenAI.dll" #r "C:\\Users\\kinfeylo\\Documents\\Agent\\agent-framework\\dotnet\\src\\Microsoft.Agents.AI\\bin\\Debug\\net9.0\\Microsoft.Agents.AI.dll" // Add a helper for loading environment variables #r "nuget: DotNetEnv, 3.1.1" // Import the necessary namespaces using System; using System.ComponentModel; using System.ClientModel; using Microsoft.Extensions.AI; using Microsoft.Agents.AI; using OpenAI; using DotNetEnv; ``` -------------------------------- ### Install Released Agent Framework Source: https://github.com/microsoft/agent-framework-samples/blob/main/README.md Use these commands to install the stable or pre-release version of the framework. ```bash pip install agent-framework --pre ``` ```bash dotnet add package Microsoft.Agents.AI ``` -------------------------------- ### Install Dependencies Source: https://github.com/microsoft/agent-framework-samples/blob/main/03.ExploerAgentFramework/code_samples/python/04-python-agent-framework-foundrylocal.ipynb Install the required packages from the requirements file. ```python # ! pip install -r Installations/requirements.txt -U ``` -------------------------------- ### Run Development Server Source: https://github.com/microsoft/agent-framework-samples/blob/main/09.Cases/GHModel.AI/GHModel.dotNET.AI/GHModel.dotNET.AI.Workflow.AGUI/GHModel.dotNET.AI.Workflow.AGUI.CopilotKit/README.md Use one of these commands to start the Next.js development server. Open http://localhost:3000 to view the site. ```bash npm run dev ``` ```bash yarn dev ``` ```bash pnpm dev ``` ```bash bun dev ``` -------------------------------- ### Install Agent Framework (Python) Source: https://context7.com/microsoft/agent-framework-samples/llms.txt Install the Microsoft Agent Framework for Python using pip. Use the --pre flag for the latest pre-release version or install from requirements.txt for the latest features from source. ```bash # Python Installation (Released Version) pip install agent-framework --pre # Python Installation (Build from Source - Latest Features) pip install -r ./Installation/requirements.txt -U ``` -------------------------------- ### Install dependencies Source: https://github.com/microsoft/agent-framework-samples/blob/main/03.ExploerAgentFramework/code_samples/python/03-python-agent-framework-msfoundry.ipynb Install the required packages for the agent framework. ```python # ! pip install -r ../../../Installation/requirements.txt -U ``` -------------------------------- ### Install Agent Framework (.NET) Source: https://context7.com/microsoft/agent-framework-samples/llms.txt Install the Microsoft Agent Framework for .NET using the NuGet package manager for the released version. For building from source, clone the repository and build the solution. ```bash # .NET Installation (Released Version) dotnet add package Microsoft.Agents.AI # .NET Installation (Build from Source) git clone https://github.com/microsoft/agent-framework.git cd agent-framework/dotnet dotnet build agent-framework-dotnet.slnx ``` -------------------------------- ### Start DevUI Environment Source: https://github.com/microsoft/agent-framework-samples/blob/main/09.Cases/GHModel.AI/README.md Commands to launch the DevUI interface for Python and .NET projects. ```bash cd GHModel.Python.AI/GHModel.Python.AI.Workflow.DevUI pip install agent-framework agent-framework-devui python-dotenv python main.py # Browser opens automatically at http://localhost:8090 ``` ```bash cd GHModel.dotNET.AI/GHModel.dotNET.AI.Workflow.DevUI dotnet run # DevUI: https://localhost:50516/devui # OpenAI API: https://localhost:50516/v1/responses ``` -------------------------------- ### Install System Dependencies Source: https://github.com/microsoft/agent-framework-samples/blob/main/07.Workflow/code_samples/python/02.python-agent-framework-workflow-ghmodel-sequential.ipynb Commands to install Graphviz on Linux or macOS systems. ```bash # ! sudo apt update # ! sudo apt install graphviz -y ``` ```bash # ! brew install graphviz ``` -------------------------------- ### Install Agent Framework and OTLP Exporter Source: https://github.com/microsoft/agent-framework-samples/blob/main/08.EvaluationAndTracing/python/tracer_aspire/README.md Install the agent-framework-foundry package and the OpenTelemetry gRPC exporter for OTLP. Ensure you have Python 3.10 or higher. ```bash pip install agent-framework-foundry -U pip install opentelemetry-exporter-otlp-proto-grpc ``` -------------------------------- ### Create Basic Agent Source: https://github.com/microsoft/agent-framework-samples/blob/main/00.ForBeginners/02-explore-agentic-frameworks/code_samples/python-agent-framework-basicagent.ipynb Demonstrates the fundamental pattern for creating a basic agent within the framework. This serves as the starting point for agent development. ```python # ๐Ÿค– Create the Basic Agent # This demonstrates the core agent creation pattern in the framework ``` -------------------------------- ### Configure Environment Variables Source: https://github.com/microsoft/agent-framework-samples/blob/main/09.Cases/GHModel.AI/README.md Create a .env file in each example directory to configure API endpoints and tokens. ```env GITHUB_ENDPOINT=https://models.inference.ai.azure.com GITHUB_TOKEN=your_github_token GITHUB_MODEL_ID=gpt-4o ``` -------------------------------- ### Install Python Requirements Source: https://github.com/microsoft/agent-framework-samples/blob/main/07.Workflow/code_samples/python/02.python-agent-framework-workflow-ghmodel-sequential.ipynb Install necessary Python dependencies from the requirements file. ```bash # ! pip install -r ../../../Installation/requirements.txt -U # ``` -------------------------------- ### Configure OpenTelemetry Environment Source: https://github.com/microsoft/agent-framework-samples/blob/main/09.Cases/GHModel.AI/README.md Setup commands and environment variables for OpenTelemetry observability. ```bash cd GHModel.Python.AI/GHModel.Python.AI.Workflow.OpenTelemetry pip install agent-framework opentelemetry-exporter-otlp-proto-grpc python-dotenv python main.py # Interactive chat, type exit to quit ``` ```bash cd GHModel.dotNET.AI/GHModel.dotNET.AI.Workflow.OpenTelemetry # Start Aspire Dashboard (optional) docker run --rm -d -p 18888:18888 -p 4317:18889 --name aspire-dashboard mcr.microsoft.com/dotnet/aspire-dashboard:latest dotnet run # View traces at http://localhost:18888 ``` ```env ENABLE_OTEL=true ENABLE_SENSITIVE_DATA=true # Enable sensitive data logging in dev OTLP_ENDPOINT=http://localhost:4317 # Aspire Dashboard / OTLP Collector APPLICATIONINSIGHTS_CONNECTION_STRING=... # Azure Application Insights (optional) ``` -------------------------------- ### Initialize Workflow and Run Stream Source: https://github.com/microsoft/agent-framework-samples/blob/main/09.Cases/AgenticMarketingContentGen/spec/spec_cn.md Initializes the main workflow class, setting up the chat client and tools. It then creates agents and an executor, orchestrates the workflow using SequentialBuilder, and processes the event stream. Use this to start the marketing campaign generation process. ```python class AgenticMarketingWorkflow: def __init__(self, chat_client, *, config=None): # Initialize tools: TavilySearchTools, FluxImageGenerationTools, SoraVideoGenerationTools # Create Agents: create_marketing_agents() # Optional: Create DeepResearchExecutor async def run(self, topic: str) -> CampaignPackage: # Create and execute the workflow workflow = self._create_workflow(campaign_dir) async for event in workflow.run_stream(topic): # Process events... ``` -------------------------------- ### Install Python Dependencies Source: https://github.com/microsoft/agent-framework-samples/blob/main/07.Workflow/code_samples/python/01.python-agent-framework-workflow-ghmodel-basic.ipynb Installs project dependencies from a requirements file. Ensure you are in the correct directory before running. ```bash #!/bin/bash pip install -r ../../../Installation/requirements.txt -U ``` -------------------------------- ### Run Python AG-UI CopilotKit Client Source: https://github.com/microsoft/agent-framework-samples/blob/main/09.Cases/GHModel.AI/README.md Install Node.js dependencies and run the Python AG-UI CopilotKit client. ```bash cd GHModel.Python.AI/GHModel.Python.AI.Workflow.AGUI/GHModel.Python.AI.Workflow.AGUI.CopilotKit npm install npm run dev ``` -------------------------------- ### Install NuGet Dependencies Source: https://github.com/microsoft/agent-framework-samples/blob/main/06.RAGs/README.md Reference the required Azure AI Agent Framework and supporting libraries in a Polyglot Notebook. ```csharp #r "nuget: Microsoft.Extensions.AI, 9.9.0" #r "nuget: Azure.AI.Agents.Persistent, 1.2.0-beta.5" #r "nuget: Azure.Identity, 1.15.0" #r "nuget: System.Linq.Async, 6.0.3" #r "nuget: DotNetEnv, 3.1.1" ``` -------------------------------- ### Initialize OpenAI Client in Python Source: https://github.com/microsoft/agent-framework-samples/blob/main/03.ExploerAgentFramework/README.md Initialize an OpenAIChatClient using environment variables for the base URL, API key, and model ID. This example demonstrates connecting to an OpenAI-compatible service. ```python import os from dotenv import load_dotenv from agent_framework import ChatMessage, Role from agent_framework.openai import OpenAIChatClient load_dotenv() # Initialize the client with GitHub endpoint and token client = OpenAIChatClient( base_url=os.environ.get("GITHUB_ENDPOINT"), api_key=os.environ.get("GITHUB_TOKEN"), ai_model_id=os.environ.get("GITHUB_MODEL_ID") ) # Prepare the messages and get a response messages = [ ChatMessage(role=Role.SYSTEM, text="You are a helpful assistant."), ChatMessage(role=Role.USER, text="Write a haiku about Agent Framework.") ] response = await client.get_response(messages) print(response.messages[0].text) ``` -------------------------------- ### Initialize Environment Source: https://github.com/microsoft/agent-framework-samples/blob/main/07.Workflow/code_samples/python/02.python-agent-framework-workflow-ghmodel-sequential.ipynb Import system utilities and load environment variables. ```python import os import base64 from typing import cast from dotenv import load_dotenv ``` ```python load_dotenv() ``` -------------------------------- ### Run the Agent Framework Sample Source: https://github.com/microsoft/agent-framework-samples/blob/main/08.EvaluationAndTracing/python/tracer_aspire/README.md Execute the Python script to run the agent sample. This will configure OpenTelemetry, create an agent, process questions, and send telemetry data to the Aspire Dashboard. ```bash python simple.py ``` -------------------------------- ### Initialize and Run Agent Source: https://github.com/microsoft/agent-framework-samples/blob/main/04.Tools/code_samples/python/msfoundry/03.python-agent-framework-msfoundry-web-search.ipynb Configure the agent with the web search tool and execute a query. ```python # Create web search tool web_search_tool = FoundryChatClient.get_web_search_tool() # Create agent with web search capabilities agent = Agent( client=FoundryChatClient(credential=AzureCliCredential()), name=AgentName, instructions=AgentInstructions, tools=[web_search_tool], ) query = "What is today's date and weather in Guangzhou?" print(f"User: {query}") result = await agent.run(query) print(f"Agent: {result.text}") ``` -------------------------------- ### Initialize Client and Agent Source: https://github.com/microsoft/agent-framework-samples/blob/main/02.CreateYourFirstAgent/code_samples/python/python-travelagent-ghmodel.ipynb Set up the GitHub Models client and instantiate the agent with the custom tool. ```python # ๐Ÿ”— Initialize GitHub Models Client # Create the API client that connects our agent to advanced AI capabilities openai_chat_client = OpenAIChatCompletionClient( base_url=os.environ.get("GITHUB_ENDPOINT"), # GitHub Models API endpoint api_key=os.environ.get("GITHUB_TOKEN"), # Your authentication token model=os.environ.get("GITHUB_MODEL_ID") # Model selection (e.g., gpt-4o-mini) ) ``` ```python # ๐Ÿค– Create Your First AI Agent! # This is where the magic happens - creating an intelligent travel planning assistant agent = Agent( client=openai_chat_client, # ๐Ÿ”— AI model connection instructions="You are a helpful AI Agent that can help plan vacations for customers at random destinations.", # ๐ŸŽฏ Agent personality and role tools=[get_random_destination] # ๐Ÿ› ๏ธ Available functions the agent can use ) ``` -------------------------------- ### Configure Environment Variables Source: https://github.com/microsoft/agent-framework-samples/blob/main/09.Cases/AgenticMarketingContentGen/README.md Set up the environment configuration files and required API keys. ```bash cp .env.example .env ``` ```env # Azure OpenAI (Main Model) AZURE_OPENAI_ENDPOINT=https://.openai.azure.com/ AZURE_OPENAI_API_KEY= AZURE_OPENAI_CHAT_DEPLOYMENT_NAME=gpt-5-mini AZURE_OPENAI_API_VERSION=2025-04-01-preview # Tavily Search (Market Research) Tvly_API_KEY= ``` ```env # FLUX Image Generation AZURE_IMAGE_ENDPOINT=https://.openai.azure.com/openai/v1/ AZURE_IMAGE_API_KEY= AZURE_IMAGE_DEPLOYMENT_NAME=FLUX.1-Kontext-pro # Sora-2 Video Generation AZURE_VIDEO_ENDPOINT=https://.openai.azure.com/openai/v1/videos AZURE_VIDEO_API_KEY= AZURE_VIDEO_DEPLOYMENT_NAME=sora-2 ``` -------------------------------- ### Initialize and Execute Agent Source: https://github.com/microsoft/agent-framework-samples/blob/main/06.RAGs/README.md Configures the agent with FileSearchTool and executes a query against the vector store. ```python async with ( AzureCliCredential() as credential, AzureAIAgentClient(async_credential=credential) as chat_client, ): file_id, vector_store = await create_vector_store(chat_client) file_search = FileSearchTool(vector_store_ids=[vector_store.id]) agent = chat_client.create_agent( name="PythonRAGDemo", instructions=""" You are a helpful assistant that helps people find information in a set of files. If you can't find the answer in the files, just say you don't know. Do not make up an answer. """, tools=file_search.definitions, # Tools available to the agent tool_resources=file_search.resources, # Resources for the tool ) print("Agent created. You can now ask questions about the uploaded document.") query = "What is GraphRAG?" # The tool resources must be passed again at runtime response = await AgentRunResponse.from_agent_response_generator(agent.run_stream(query, tool_resources={"file_search": {"vector_store_ids": [vector_store.id]}})) print(f"Assistant: {response}") ``` -------------------------------- ### Clone Repository and Navigate Source: https://github.com/microsoft/agent-framework-samples/blob/main/09.Cases/GHModel.AI/README.md Clone the project repository and navigate to the root directory. ```bash git clone https://github.com/your-username/GHModel.AI.git cd GHModel.AI ``` -------------------------------- ### Install Graphviz Source: https://github.com/microsoft/agent-framework-samples/blob/main/07.Workflow/code_samples/python/01.python-agent-framework-workflow-ghmodel-basic.ipynb Installs the Graphviz package required for workflow visualization on Linux and macOS systems. ```bash #!/bin/bash sudo apt update sudo apt install graphviz -y ``` ```bash #!/bin/bash brew install graphviz ``` -------------------------------- ### Initialize Agents and Workflow Source: https://github.com/microsoft/agent-framework-samples/blob/main/07.Workflow/code_samples/python/04.python-agent-framework-workflow-msfoundry-condition.ipynb Sets up Azure credentials, creates a FoundryChatClient, initializes various agents (Evangelist, Reviewer, Publisher) with specific tools and instructions, and builds a workflow connecting them. ```python try: credential = AzureCliCredential() client = FoundryChatClient(credential=credential) # Create web search tool and code interpreter tool web_search_tool = FoundryChatClient.get_web_search_tool() code_interpreter_tool = FoundryChatClient.get_code_interpreter_tool() # Create evangelist agent with web search tool evangelist_agent_obj = Agent( client=client, name="evangelist-agent", instructions=EvangelistInstructions, tools=[web_search_tool], ) evangelist_agent = AgentExecutor(evangelist_agent_obj, id="evangelist_agent") # Create reviewer agent (no tools needed) reviewer_agent_obj = Agent( client=client, name="reviewer-agent", instructions=ContentReviewerInstructions, ) reviewer_agent = AgentExecutor(reviewer_agent_obj, id="reviewer_agent") # Create publisher agent with code interpreter tool publisher_agent_obj = Agent( client=client, name="publisher-agent", instructions=PublisherInstructions, tools=[code_interpreter_tool], ) publisher_agent = AgentExecutor(publisher_agent_obj, id="publisher_agent") workflow = ( WorkflowBuilder(start_executor=evangelist_agent) .add_edge(evangelist_agent, reviewer_agent) .add_edge(reviewer_agent, to_reviewer_result) .add_multi_selection_edge_group( to_reviewer_result, [handle_review, save_draft], selection_func=select_targets, ) .add_edge(save_draft, publisher_agent) .build() ) print("Generating workflow visualization...") viz = WorkflowViz(workflow) # Print out the mermaid string. print("Mermaid string: \n=======") print(viz.to_mermaid()) print("=======") # Print out the DiGraph string. print("DiGraph string: \n=======") print(viz.to_digraph()) print("=======") svg_file = viz.export(format="svg") print(f"SVG file saved to: {svg_file}") if svg_file and os.path.exists(svg_file): try: display(SVG(filename=svg_file)) except Exception as e: print(f"โš ๏ธ Direct SVG render failed: {e}. Falling back to raw HTML.") try: with open(svg_file, "r", encoding="utf-8") as f: svg_text = f.read() display(HTML(svg_text)) except Exception as inner: print(f"โŒ Fallback HTML render also failed: {inner}") else: print("โŒ SVG file not found. Ensure viz.export(format='svg') ran successfully.") task = """ ``` -------------------------------- ### Create Agent instance Source: https://github.com/microsoft/agent-framework-samples/blob/main/03.ExploerAgentFramework/code_samples/python/03-python-agent-framework-msfoundry.ipynb Instantiate an agent with the client and specific instructions. ```python agent = Agent( client=client, name = "FoundryAgent", instructions="Write a haiku about Agent Framework", ) ``` -------------------------------- ### Example Output of Agent Code Source: https://github.com/microsoft/agent-framework-samples/blob/main/04.Tools/code_samples/python/msfoundry/02.python-agent-framework-msfoundry-code-interpreter.ipynb This is an example of the output produced when the agent's generated Python code is executed. ```python 42 ``` -------------------------------- ### Build Agent Framework from Source Source: https://github.com/microsoft/agent-framework-samples/blob/main/README.md Build the framework from the repository source to access the latest features. ```bash pip install -r ./Installation/requirement.txt -U ``` ```bash git clone https://github.com/microsoft/agent-framework.git cd agent-framework/dotnet dotnet build agent-framework-dotnet.slnx ``` -------------------------------- ### Initialize Client and Agent Source: https://github.com/microsoft/agent-framework-samples/blob/main/03.ExploerAgentFramework/code_samples/python/04-python-agent-framework-foundrylocal.ipynb Configure the FoundryLocalClient, list available models, and instantiate an agent with tools. ```python client = FoundryLocalClient(model="qwen2.5-1.5b-instruct-generic-cpu:4") print(f"Client Model ID: {client.model}\n") print("Other available models (tool calling supported only):") for model in client.manager.list_catalog_models(): if model.supports_tool_calling: print( f"- {model.alias} for {model.task} - id={model.id} - {(model.file_size_mb / 1000):.2f} GB - {model.license}" ) agent = client.as_agent( name="LocalAgent", instructions="You are a helpful agent.", tools=get_weather, ) ``` -------------------------------- ### Install OTLP Exporter (Troubleshooting) Source: https://github.com/microsoft/agent-framework-samples/blob/main/08.EvaluationAndTracing/python/tracer_aspire/README.md If you encounter import errors related to OpenTelemetry, install the OTLP exporter package. This is a common fix for missing telemetry components. ```bash pip install opentelemetry-exporter-otlp-proto-grpc ``` -------------------------------- ### Agent Generated Code Example Source: https://github.com/microsoft/agent-framework-samples/blob/main/04.Tools/code_samples/python/msfoundry/02.python-agent-framework-msfoundry-code-interpreter.ipynb This is an example of Python code generated by the agent in response to a query. It defines a function to return a random even number and then calls it. ```python import random def random_even_1_to_100(): return random.randrange(2, 101, 2) print(random_even_1_to_100()) ``` -------------------------------- ### Initialize Agents in Python Source: https://github.com/microsoft/agent-framework-samples/blob/main/07.Workflow/README.md Create agent instances by providing instructions and names to the chat client. ```python reviewer_agent = chat_client.create_agent( instructions=(REVIEWER_INSTRUCTIONS), name=REVIEWER_NAME, ) front_desk_agent = chat_client.create_agent( instructions=(FRONTDESK_INSTRUCTIONS), name=FRONTDESK_NAME, ) ``` -------------------------------- ### RAG Agent Output Example Source: https://github.com/microsoft/agent-framework-samples/blob/main/06.RAGs/code_samples/python/python-agent-framework-msfoundry-file-search.ipynb This is an example output from the RAG agent when queried about 'What's GraphRAG?'. It shows the agent's response based on the uploaded document, including an explanation of GraphRAG and its benefits, followed by cleanup messages. ```text Output: Uploading file from: ../files/demo.md Uploaded file, file ID: assistant-NngmEZ6fUPdtnr8pKyvz9X Created vector store, vector store ID: vs_eqlGLmi8xDsN93OuCU15YRPm File successfully added to vector store # User: 'What's GraphRAG?' # Agent: GraphRAG is an AI-based content interpretation and search capability that uses LLMs to parse data, build a knowledge graph, and answer questions about a user-provided private dataset. In the uploaded document, itโ€™s described as especially useful when answers span many documents or when the questions are more thematic or abstract than simple keyword or vector search can handleโ€”for example, finding connections across a large corpus or identifying top themes in a dataset. A few key points from the doc: - It connects information across large volumes of text using a knowledge graph. - Itโ€™s intended for analysis and information discovery in complex, noisy, domain-specific corpora. - Human review is still important: the document says domain experts should verify and augment GraphRAGโ€™s responses. If you want, I can also explain how GraphRAG differs from standard RAG in simple terms. Deleted vector store: vs_eqlGLmi8xDsN93OuCU15YRPm Deleted file: assistant-NngmEZ6fUPdtnr8pKyvz9X ``` -------------------------------- ### Planning Agent Result Output Source: https://github.com/microsoft/agent-framework-samples/blob/main/00.ForBeginners/07-planning-design/code_samples/python-agent-framrwork-ghmodel-planningdesign.ipynb Example of the JSON-formatted travel plan generated by the agent. ```json Result: '{"main_task":"Create a travel plan for a family of 4, with 2 kids, traveling from Singapore to Melbourne.","subtasks":[{"assigned_agent":"FlightBooking","task_details":"Book flights for 4 family members, including 2 kids, from Singapore to Melbourne."},{"assigned_agent":"HotelBooking","task_details":"Find and book family-friendly accommodation in Melbourne suitable for 4 people including 2 kids."},{"assigned_agent":"CarRental","task_details":"Arrange for a suitable car rental in Melbourne for a family of 4, including 2 kids."},{"assigned_agent":"ActivitiesBooking","task_details":"Plan and book family-friendly activities and attractions in Melbourne suitable for 2 adults and 2 kids."}]}' ``` -------------------------------- ### Build Workflow Source: https://github.com/microsoft/agent-framework-samples/blob/main/07.Workflow/code_samples/python/01.python-agent-framework-workflow-ghmodel-basic.ipynb Constructs a workflow by defining the starting agent and the sequence of agent interactions. ```python workflow = WorkflowBuilder(start_executor=front_desk_agent).add_edge(front_desk_agent, reviewer_agent).build() ``` -------------------------------- ### Publisher Instructions Prompt Source: https://github.com/microsoft/agent-framework-samples/blob/main/07.Workflow/code_samples/python/04.python-agent-framework-workflow-msfoundry-condition.ipynb Instructions for an AI agent acting as a content publisher, detailing how to save tutorial draft content as a Markdown file with a timestamped name. ```python PublisherInstructions = """ You are the content publisher ,run code to save the tutorial's draft content as a Markdown file. Saved file's name is marked with current date and time, such as yearmonthdayhourminsec. Note that if it is 1-9, you need to add 0, such as 20240101123045.md. """ ``` -------------------------------- ### Run .NET AG-UI Client Source: https://github.com/microsoft/agent-framework-samples/blob/main/09.Cases/GHModel.AI/README.md Navigate to the .NET AG-UI client directory and run the client using the .NET CLI. ```bash cd GHModel.dotNET.AI/GHModel.dotNET.AI.Workflow.AGUI/GHModel.dotNET.AI.Workflow.AGUI.Client dotnet run ``` -------------------------------- ### Setup Python Environment for AI Agent Source: https://github.com/microsoft/agent-framework-samples/blob/main/02.CreateYourFirstAgent/README.md Imports necessary libraries and loads environment variables for the agent framework. ```python import os from random import randint from dotenv import load_dotenv # Import the core agent components from agent_framework import ChatAgent from agent_framework.openai import OpenAIChatClient # Load environment variables from the .env file load_dotenv() ``` -------------------------------- ### Initialize Agent Source: https://github.com/microsoft/agent-framework-samples/blob/main/00.ForBeginners/02-explore-agentic-frameworks/code_samples/python-agent-framework-basicagent.ipynb Configures an agent with a chat client, system instructions, and a list of available tools. ```python agent = Agent( client=openai_chat_client, # The AI model client for generating responses instructions="You are a helpful AI Agent that can help plan vacations for customers at random destinations.", # System prompt defining agent behavior tools=[get_random_destination] # List of available tools the agent can use ) ``` -------------------------------- ### Run .NET AG-UI Server Source: https://github.com/microsoft/agent-framework-samples/blob/main/09.Cases/GHModel.AI/README.md Navigate to the .NET AG-UI server directory and run the server using the .NET CLI. ```bash cd GHModel.dotNET.AI/GHModel.dotNET.AI.Workflow.AGUI/GHModel.dotNET.AI.Workflow.AGUI.Server dotnet run ``` -------------------------------- ### Define Agent Configuration Source: https://github.com/microsoft/agent-framework-samples/blob/main/04.Tools/code_samples/python/msfoundry/02.python-agent-framework-msfoundry-code-interpreter.ipynb Set the agent's name and provide instructions for its behavior. The instructions guide the agent's responses and actions. ```python AgentName = "Coding-Agent" AgentInstructions = "You are a helpful assistant that can write and execute Python code to solve problems." ``` -------------------------------- ### Initialize Dependencies and Environment Source: https://github.com/microsoft/agent-framework-samples/blob/main/06.RAGs/README.md Imports required libraries for Azure AI Agent Framework and loads environment variables. ```python import os from azure.ai.agents.models import FilePurpose,VectorStore,FileSearchTool from azure.ai.projects.aio import AIProjectClient from azure.identity.aio import AzureCliCredential from dotenv import load_dotenv from agent_framework import AgentRunResponse,ChatAgent,HostedFileSearchTool,HostedVectorStoreContent from agent_framework.azure import AzureAIAgentClient load_dotenv() ``` -------------------------------- ### Define Sequential Workflow Participants Source: https://github.com/microsoft/agent-framework-samples/blob/main/09.Cases/AgenticMarketingContentGen/spec/spec.md Use SequentialBuilder to define the participants in a workflow. This example shows a pipeline with strategy, copywriting, image, video, and packaging agents. ```python builder = SequentialBuilder().participants([ strategy_participant, # Strategy Agent or DeepResearchExecutor self._agents.copywriting, self._agents.image, self._agents.video, packaging_executor, ]) workflow = builder.with_checkpointing(checkpoint_storage).build() ``` -------------------------------- ### Run Deep Research Workflow (DevUI Mode) Source: https://github.com/microsoft/agent-framework-samples/blob/main/09.Cases/FoundryLocalPipeline/README.md Start the deep research workflow in DevUI mode. Access the interactive interface at the provided local address. ```bash python 02.foundrylocal_maf_workflow_deep_research_devui.py ``` -------------------------------- ### Initialize and Run RAG Agent Source: https://github.com/microsoft/agent-framework-samples/blob/main/04.Tools/code_samples/python/msfoundry/04.python-agent-framework-msfoundry-file-search.ipynb Upload a file, create a vector store, configure the agent with file search, and execute the query. Ensure cleanup of resources in the finally block. ```python file_id = None vector_store_id = None # Initialize the Foundry chat client client = FoundryChatClient(credential=AzureCliCredential()) try: # 1. Upload file and create vector store file_path = '../../files/demo.md' # Path to the file to be uploaded print(f"Uploading file from: {file_path}") # Read file content with open(file_path, 'rb') as f: file_content = f.read() # Upload file to Foundry file = await client.client.files.create( file=("demo.md", file_content), purpose="assistants" ) file_id = file.id print(f"Uploaded file, file ID: {file_id}") # Create vector store with expiry vector_store = await client.client.vector_stores.create( name="rag_knowledge_base", expires_after={"anchor": "last_active_at", "days": 1} ) vector_store_id = vector_store.id print(f"Created vector store, vector store ID: {vector_store_id}") # Add file to vector store result = await client.client.vector_stores.files.create_and_poll( vector_store_id=vector_store_id, file_id=file_id ) if result.last_error is not None: raise Exception(f"Vector store file processing failed: {result.last_error.message}") print("File successfully added to vector store") # 2. Create file search tool using the client's method file_search_tool = client.get_file_search_tool(vector_store_ids=[vector_store_id]) # 3. Create an agent with file search capabilities agent = Agent( client=client, name ="PythonRAGAgent", instructions=( "You are an AI assistant that helps people find information in a set of documents. Use the File Search tool to look up relevant information from the files when needed to answer user questions. If you don't know the answer, just say you don't know. Do not make up answers." ), tools=[file_search_tool], ) # 4. Query the agent print(f"\n# User: '{query}'") response = await agent.run(query) print(f"# Agent: {response}\n") finally: # 5. Cleanup: Delete the vector store and file to prevent orphaned resources if vector_store_id: with contextlib.suppress(Exception): await client.client.vector_stores.delete(vector_store_id) print(f"Deleted vector store: {vector_store_id}") if file_id: with contextlib.suppress(Exception): await client.client.files.delete(file_id) print(f"Deleted file: {file_id}") ``` -------------------------------- ### Connect to Azure OpenAI Service in .NET Source: https://github.com/microsoft/agent-framework-samples/blob/main/03.ExploerAgentFramework/README.md Initializes an AzureOpenAIClient using environment variables and Azure CLI credentials, then creates and runs an AI agent to get a response. ```csharp // Load endpoint and model ID from environment variables var aoai_endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT"); var aoai_model_id = Environment.GetEnvironmentVariable("AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME"); // Create the agent AIAgent agent = new AzureOpenAIClient( new Uri(aoai_endpoint), new AzureCliCredential()) .GetChatClient(aoai_model_id) .CreateAIAgent("You are a helpful assistant."); // Run the agent and get a response Console.WriteLine(await agent.RunAsync("Write a haiku about Agent Framework.")); ``` -------------------------------- ### Initialize Chat Client Source: https://github.com/microsoft/agent-framework-samples/blob/main/00.ForBeginners/04-tool-use/code_samples/python-agent-framework-ghmodel-tools.ipynb Create the OpenAI-compatible chat client for agent communication. ```python # ๐Ÿ”— Initialize GitHub Models chat client for agent communication # Creates the primary interface between the agent and the language model openai_chat_client = OpenAIChatCompletionClient(base_url=os.environ.get("GITHUB_ENDPOINT"), api_key=os.environ.get("GITHUB_TOKEN"), model=os.environ.get("GITHUB_MODEL_ID")) ``` -------------------------------- ### Configure Environment Variables for Instrumentation Source: https://github.com/microsoft/agent-framework-samples/blob/main/08.EvaluationAndTracing/python/tracer_aspire/README.md Copy the example environment file and update it with your Azure AI Foundry project details and OpenTelemetry endpoint. Ensure ENABLE_INSTRUMENTATION is set to true. ```env FOUNDRY_PROJECT_ENDPOINT="https://your-project.services.ai.azure.com" FOUNDRY_MODEL="gpt-4o-mini" ENABLE_INSTRUMENTATION=true OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317 ``` -------------------------------- ### Python Agent Framework Travel Agent Example Source: https://github.com/microsoft/agent-framework-samples/blob/main/00.ForBeginners/README.md Demonstrates a basic travel agent implementation using the Microsoft Agent Framework in Python. This notebook is part of the introduction to AI agents. ```python # This is a placeholder for the actual code from the notebook file. # The content of the notebook is not provided in the input text. ``` -------------------------------- ### Load Environment Configuration Source: https://github.com/microsoft/agent-framework-samples/blob/main/00.ForBeginners/01-intro-to-ai-agents/code_samples/python-agent-framework-travelagent.ipynb Initialize environment variables from a .env file. ```python # ๐Ÿ”ง Load Environment Variables # This loads configuration from a .env file in the project root # Required variables: GITHUB_ENDPOINT, GITHUB_TOKEN, GITHUB_MODEL_ID load_dotenv() ``` -------------------------------- ### Environment Setup Configuration Source: https://github.com/microsoft/agent-framework-samples/blob/main/README.md Configure your environment variables in a .env file for various services including GitHub Models, Azure OpenAI, Foundry Local, Azure AI, Bing, and OpenTelemetry. ```env GITHUB_TOKEN="Your GitHub Models Token" GITHUB_ENDPOINT="Your GitHub Models Endpoint" GITHUB_MODEL_ID="Your GitHub Model ID" AZURE_OPENAI_ENDPOINT="Your Azure OpenAI Endpoint" AZURE_OPENAI_CHAT_DEPLOYMENT_NAME ="Your Azure OpenAI Model Deployment Name" FOUNDRYLOCAL_ENDPOINT="Your Foundry Local Endpoint http://localhost:5272/v1" FOUNDRYLOCAL_MODEL_DEPLOYMENT_NAME="Your Foundry Local Model Deployment Name" AZURE_AI_PROJECT_ENDPOINT ="Your Azure AI Foundry Project Endpoint" AZURE_AI_MODEL_DEPLOYMENT_NAME ="Your Azure AI Foundry Project Deployment Name" BING_CONNECTION_ID="Your Bing Connection ID" BING_CONNECTION_NAME="Your Bing Connection Name" OTEL_EXPORTER_OTLP_ENDPOINT="Your OpenTelemetry Collector Endpoint e.g. http://localhost:4317" ``` -------------------------------- ### Initialize and Run Vision Agent Source: https://github.com/microsoft/agent-framework-samples/blob/main/04.Tools/code_samples/python/msfoundry/01.python-agent-framework-msfoundry-vision.ipynb Create a Foundry-backed agent, encode an image to base64, and send a multi-modal request. ```python # Create a Foundry-backed agent with vision capabilities agent = Agent( client=FoundryChatClient(credential=AzureCliCredential()), name=AgentName, instructions=AgentInstructions, ) # Prepare image image_path = "../../files/home.png" with open(image_path, "rb") as image_file: image_b64 = base64.b64encode(image_file.read()).decode() image_uri = f"data:image/png;base64,{image_b64}" # Send text and image as separate content items print("User: Please find the relevant furniture according to the image and give the corresponding price for each piece of furniture [Image provided]") first_result = await agent.run( [ Content.from_text(text="Please find the relevant furniture according to the image and give the corresponding price for each piece of furniture"), Content.from_uri(uri=image_uri, media_type="image/png") ] ) print(f"Agent: {first_result.text}") ``` -------------------------------- ### Run Aspire Dashboard Locally Source: https://github.com/microsoft/agent-framework-samples/blob/main/08.EvaluationAndTracing/python/tracer_aspire/README.md Start the Aspire Dashboard using Docker. This command maps the necessary ports for the web UI and the OTLP endpoint. The dashboard will be accessible at http://localhost:18888. ```bash docker run --rm -it -d \ -p 18888:18888 \ -p 4317:18889 \ --name aspire-dashboard \ mcr.microsoft.com/dotnet/aspire-dashboard:latest ``` -------------------------------- ### Initialize FoundryChatClient Source: https://github.com/microsoft/agent-framework-samples/blob/main/03.ExploerAgentFramework/code_samples/python/03-python-agent-framework-msfoundry.ipynb Create a client instance using Azure CLI credentials. ```python client = FoundryChatClient(credential=AzureCliCredential()) ``` -------------------------------- ### Configure OpenAI Client Source: https://github.com/microsoft/agent-framework-samples/blob/main/07.Workflow/code_samples/python/02.python-agent-framework-workflow-ghmodel-sequential.ipynb Initialize the chat completion client using environment variables. ```python chat_client = OpenAIChatCompletionClient(base_url=os.environ.get("GITHUB_ENDPOINT"), api_key=os.environ.get("GITHUB_TOKEN"), model=os.environ.get("GITHUB_MODEL_ID") ) ``` -------------------------------- ### Initialize and Configure Agent with File Search Source: https://github.com/microsoft/agent-framework-samples/blob/main/00.ForBeginners/05-agentic-rag/code_samples/python-agent-framework-msfoundry-file-search.ipynb This snippet initializes the FoundryChatClient, uploads a document, creates a vector store, adds the file to the vector store, and configures an Agent with a file search tool. It includes error handling for vector store processing and cleanup logic to delete the vector store and file after use. ```python file_id = None vector_store_id = None # Initialize the Foundry chat client client = FoundryChatClient(credential=AzureCliCredential()) try: # 1. Upload file and create vector store file_path = './document.md' print(f"Uploading file from: {file_path}") # Read file content with open(file_path, 'rb') as f: file_content = f.read() # Upload file to Foundry file = await client.client.files.create( file=("document.md", file_content), purpose="assistants" ) file_id = file.id print(f"Uploaded file, file ID: {file_id}") # Create vector store with expiry vector_store = await client.client.vector_stores.create( name="contoso_knowledge_base", expires_after={"anchor": "last_active_at", "days": 1} ) vector_store_id = vector_store.id print(f"Created vector store, vector store ID: {vector_store_id}") # Add file to vector store result = await client.client.vector_stores.files.create_and_poll( vector_store_id=vector_store_id, file_id=file_id ) if result.last_error is not None: raise Exception(f"Vector store file processing failed: {result.last_error.message}") print("File successfully added to vector store") # 2. Create file search tool using the client's method file_search_tool = client.get_file_search_tool(vector_store_ids=[vector_store_id]) # 3. Create an agent with file search capabilities agent = Agent( client=client, instructions=( "You are an AI assistant designed to answer user questions using only the information " "retrieved from the provided document(s). " "If a user's question cannot be answered using the retrieved context, you must clearly respond: " "'I'm sorry, but the uploaded document does not contain the necessary information to answer that question.' " "Do not answer from general knowledge or reasoning. Do not make assumptions or generate hypothetical explanations. " "For questions that do have relevant content in the document, respond accurately and cite the document explicitly." ), tools=[file_search_tool], ) # 4. Query the agent print(f"\n# User: '{query}'") response = await agent.run(query) print(f"# Agent: {response}\n") finally: # 5. Cleanup: Delete the vector store and file to prevent orphaned resources if vector_store_id: with contextlib.suppress(Exception): await client.client.vector_stores.delete(vector_store_id) print(f"Deleted vector store: {vector_store_id}") if file_id: with contextlib.suppress(Exception): await client.client.files.delete(file_id) print(f"Deleted file: {file_id}") ``` -------------------------------- ### Create Agent Instances Source: https://github.com/microsoft/agent-framework-samples/blob/main/00.ForBeginners/08-multi-agent/code_samples/python-agent-framework-ghmodel-workflow-multi-agents.ipynb Instantiate the agents using the shared chat client and defined instructions. ```python writer_agent = chat_client.as_agent( instructions=( REVIEWER_INSTRUCTIONS ), name=REVIEWER_NAME, ) agent_reviewer = chat_client.as_agent( instructions=( FRONTDESK_INSTRUCTIONS ), name=FRONTDESK_NAME, ) ``` -------------------------------- ### Load Configuration in .NET Source: https://github.com/microsoft/agent-framework-samples/blob/main/02.CreateYourFirstAgent/README.md Read environment variables from the .env file to initialize the AI model connection. ```csharp // Load variables from a .env file located in a parent directory Env.Load("../../../.env"); // Fetch the GitHub endpoint, model ID, and API token var github_endpoint = Environment.GetEnvironmentVariable("GITHUB_ENDPOINT") ?? throw new InvalidOperationException("GITHUB_ENDPOINT is not set."); var github_model_id = Environment.GetEnvironmentVariable("GITHUB_MODEL_ID") ?? "gpt-4o-mini"; var github_token = Environment.GetEnvironmentVariable("GITHUB_TOKEN") ?? throw new InvalidOperationException("GITHUB_TOKEN is not set."); ``` -------------------------------- ### Initialize and Execute Python Agent Source: https://github.com/microsoft/agent-framework-samples/blob/main/02.CreateYourFirstAgent/README.md Configures the chat client and runs the agent with the defined tool. ```python # Initialize the chat client pointing to the GitHub Models service openai_chat_client = OpenAIChatClient( base_url=os.environ.get("GITHUB_ENDPOINT"), api_key=os.environ.get("GITHUB_TOKEN"), ai_model_id=os.environ.get("GITHUB_MODEL_ID") ) # Create the agent agent = ChatAgent( chat_client=openai_chat_client, instructions="You are a helpful AI Agent that can help plan vacations for customers at random destinations.", tools=[get_random_destination] ) # Run the agent with a prompt response = await agent.run("Plan me a day trip") ``` -------------------------------- ### Create Bing Web Search Agent (.NET) Source: https://context7.com/microsoft/agent-framework-samples/llms.txt Instantiate an agent with the HostedWebSearchTool for real-time web information retrieval. Ensure FOUNDRY_PROJECT_ENDPOINT and FOUNDRY_MODEL environment variables are set. ```csharp using Azure.AI.Projects; using Azure.Identity; using Microsoft.Agents.AI; using Microsoft.Extensions.AI; using OpenAI.Responses; using DotNetEnv; Env.Load(".env"); const string AgentName = "Bing-Agent-Framework"; const string AgentInstructions = @"You are a helpful assistant that can search the web for current information. Use the Bing search tool to find up-to-date information and provide accurate, well-sourced answers. Always cite your sources when possible."; string endpoint = Environment.GetEnvironmentVariable("FOUNDRY_PROJECT_ENDPOINT") ?? throw new InvalidOperationException("FOUNDRY_PROJECT_ENDPOINT is not set."); string deploymentName = Environment.GetEnvironmentVariable("FOUNDRY_MODEL") ?? "gpt-4o-mini"; AIProjectClient aiProjectClient = new(new Uri(endpoint), new DefaultAzureCredential()); // Create agent with Web Search tool AIAgent agent = aiProjectClient.AsAIAgent( deploymentName, instructions: AgentInstructions, name: AgentName, tools: [new HostedWebSearchTool()]); AgentResponse response = await agent.RunAsync("What is today's date and weather in Guangzhou?"); // Get the text response Console.WriteLine($"Response: {response.Text}"); // Get citations from web search foreach (AIAnnotation annotation in response.Messages.SelectMany(m => m.Contents).SelectMany(c => c.Annotations ?? [])) { if (annotation.RawRepresentation is UriCitationMessageAnnotation urlCitation) { Console.WriteLine($"Title: {urlCitation.Title}"); Console.WriteLine($"URL: {urlCitation.Uri}"); } } ``` -------------------------------- ### Initialize MCP and Azure Components Source: https://github.com/microsoft/agent-framework-samples/blob/main/05.Providers/code_samples/python/01-python-agent-framework-aifoundry-mcp.ipynb Import necessary modules and load environment variables for Azure AI Foundry and MCP integration. ```python # ๐Ÿ”Œ Import MCP and Azure AI Foundry Components # Essential components for Model Context Protocol integration with enterprise services import os import asyncio from typing import TYPE_CHECKING, Any from agent_framework import Agent from agent_framework.foundry import FoundryChatClient from azure.identity import AzureCliCredential from dotenv import load_dotenv ``` ```python load_dotenv() ``` -------------------------------- ### Import Libraries Source: https://github.com/microsoft/agent-framework-samples/blob/main/02.CreateYourFirstAgent/code_samples/python/python-travelagent-ghmodel.ipynb Import necessary system utilities and framework components. ```python # ๐Ÿ“ฆ Import Essential Libraries # Core system and utility libraries for building AI agents import os # Environment variable access for secure configuration from random import randint # Random number generation for destination selection # ๐Ÿ”ง Environment configuration management from dotenv import load_dotenv # Load API keys and settings from .env file ``` ```python # ๐Ÿค– Import Microsoft Agent Framework Components # Core classes for building intelligent conversational agents from agent_framework import Agent # Main agent orchestrator class from agent_framework.openai import OpenAIChatCompletionClient # GitHub Models API client ``` -------------------------------- ### Configure and Run AI Agent in C# Source: https://github.com/microsoft/agent-framework-samples/blob/main/02.CreateYourFirstAgent/README.md Initializes the OpenAI client with GitHub endpoint credentials and executes the agent with a custom tool. ```csharp // Configure the client options to point to the GitHub endpoint var openAIOptions = new OpenAIClientOptions() { Endpoint = new Uri(github_endpoint) }; // Create the client with our API token and options var openAIClient = new OpenAIClient(new ApiKeyCredential(github_token), openAIOptions); // Create the AIAgent AIAgent agent = openAIClient.GetChatClient(github_model_id).CreateAIAgent( instructions: "You are a helpful AI Agent that can help plan vacations for customers at random destinations", tools: [AIFunctionFactory.Create((Func)GetRandomDestination)] ); // Run the agent and print the result Console.WriteLine(await agent.RunAsync("Plan me a day trip")); ``` -------------------------------- ### Connect to Foundry Local with Python Source: https://github.com/microsoft/agent-framework-samples/blob/main/03.ExploerAgentFramework/README.md Initialize OpenAIChatClient with base_url pointing to the Foundry Local endpoint and a dummy API key. Loads environment variables using dotenv. ```python import os from dotenv import load_dotenv from agent_framework import ChatMessage, Role from agent_framework.openai import OpenAIChatClient load_dotenv() # Initialize client for Foundry Local client = OpenAIChatClient( base_url=os.environ.get("FOUNDRYLOCAL_ENDPOINT"), api_key="nokey", ai_model_id=os.environ.get("FOUNDRYLOCAL_MODEL_DEPLOYMENT_NAME") ) # Prepare messages and execute messages = [ ChatMessage(role=Role.SYSTEM, text="You are a helpful assistant."), ChatMessage(role=Role.USER, text="Can you introduce yourself?") ] response = await client.get_response(messages) print(response.messages[0].text) ``` -------------------------------- ### Create a Custom Agent with OpenAIChatClient Source: https://github.com/microsoft/agent-framework-samples/blob/main/09.Cases/GHModel.AI/README.md Initializes an agent using environment variables for configuration. Ensure GITHUB_ENDPOINT, GITHUB_TOKEN, and GITHUB_MODEL_ID are set in the environment. ```python from agent_framework.openai import OpenAIChatClient chat_client = OpenAIChatClient( base_url=os.environ.get("GITHUB_ENDPOINT"), api_key=os.environ.get("GITHUB_TOKEN"), model_id=os.environ.get("GITHUB_MODEL_ID") ) my_agent = chat_client.create_agent( name="MyAgent", instructions="Your custom instructions here..." ) ```