共用方式為


範例

本頁提供為 DevUI 設計的範例代理與工作流程連結。

即將推出

C# 的 DevUI 範例即將推出。 請稍後回來查看,或參考 Python 範例以獲得指導。

入門範例

Agent Framework 儲存庫在目錄中包含範例代理與工作流程 python/samples/02-agents/devui/

範例 Description
weather_agent_azure A weather agent using Azure OpenAI
foundry_agent 使用 Azure AI Foundry 的代理
azure_responses_agent Agent using Azure Responses API
fanout_workflow 工作流程示範扇出模式
spam_workflow 垃圾郵件偵測工作流程
workflow_agents 工作流程中的多位代理

運行樣本

複製與導航

git clone https://github.com/microsoft/agent-framework.git
cd agent-framework/python/samples/02-agents/devui

設置環境

每個樣本可能需要環境變數。 檢查檔案 .env.example

# Copy and edit the example file
cp weather_agent_azure/.env.example weather_agent_azure/.env
# Edit .env with your credentials

啟動 DevUI

# Discover all samples
devui .

# Or run a specific sample
devui ./weather_agent_azure

In-Memory 模式

in_memory_mode.py 腳本示範了在不進行目錄發現的情況下執行代理程式:

python in_memory_mode.py

這會開啟瀏覽器,並預設了代理程式和基本工作流程,展示如何程式化使用 serve()

當 DevUI 一開始沒有發現實體時,會顯示一個包含精選範例的 範例畫廊 。 從畫廊中,你可以:

  1. 瀏覽可用範例
  2. 查看範例描述與需求
  3. 將樣本下載到你本地的機器
  4. 直接執行取樣

創作自己的樣本

請依照 目錄探索 指南,建立與 DevUI 相容的代理程式與工作流程。

最小代理範本

# my_agent/__init__.py
from agent_framework import Agent
from agent_framework.openai import OpenAIChatClient

agent = Agent(
    name="my_agent",
    chat_client=OpenAIChatClient(),
    instructions="You are a helpful assistant."
)

簡易工作流程範本

# my_workflow/__init__.py
from agent_framework.workflows import WorkflowBuilder

# Define your workflow
workflow = (
    WorkflowBuilder(start_executor="my_executor")
    # Add executors and edges
    .build()
)

後續步驟