Cloudflare资源管理
Wrangler C
Azure AI Agents Python SDK(azure-ai-agents)用于在Azure AI Foundry上构建托管智能体,支持代码解释器、文件搜索、Bing联网、Azure AI搜索、函数调用、OpenAPI和MCP等多种工具。
Azure智能体开发让企业无需自建复杂AI基础设施,即可快速搭建能自主执行任务的数字助手。业务人员可通过自然语言指令驱动智能体完成数据分析、文档检索、信息整合等工作,将重复性知识劳动自动化,让团队专注高价值决策。
落地案例:某企业财务团队每月需汇总多部门报表并生成分析。借助Azure智能体开发,财务人员上传历史报表模板后,通过简单对话指令即可让智能体自动提取关键指标、执行计算逻辑并输出标准化分析报告,无需等待IT排期开发脚本。
安装依赖
pip install azure-ai-agents azure-identity
# 或包含额外功能
pip install azure-ai-projects azure-identity
配置环境变量
PROJECT_ENDPOINT="https://<resource>.services.ai.azure.com/api/projects/<project>"
MODEL_DEPLOYMENT_NAME="gpt-4o-mini"
基础使用流程
添加工具示例
from azure.ai.agents import CodeInterpreterTool, FileSearchTool
agent = client.create_agent(
model=os.environ["MODEL_DEPLOYMENT_NAME"],
name="tool-agent",
instructions="You can execute code and search files.",
tools=[CodeInterpreterTool()],
tool_resources={"code_interpreter": {"file_ids": [file.id]}},
)
函数调用与自动执行
from azure.ai.agents import FunctionTool, ToolSet
def get_weather(location: str) -> str:
return f"Weather in {location}: 72F, sunny"
functions = FunctionTool(functions=[get_weather])
toolset = ToolSet()
toolset.add(functions)
run = client.runs.create_and_process(
thread_id=thread.id,
agent_id=agent.id,
toolset=toolset, # 传入toolset实现自动执行
)
流式响应
from azure.ai.agents import AgentEventHandler
class MyHandler(AgentEventHandler):
def on_message_delta(self, delta):
if delta.text:
print(delta.text.value, end="", flush=True)
with client.runs.stream(
thread_id=thread.id,
agent_id=agent.id,
event_handler=MyHandler(),
) as stream:
stream.until_done()
见下方输入与输出表格。
| 项目 | 内容 |
|---|---|
| 输入 | Azure AI Foundry项目端点、模型部署名称、用户查询、可选文件/函数/工具配置 |
| 输出 | 智能体文本回复、代码执行结果、生成文件、流式消息、线程历史、运行状态 |
| 适用人群 | Azure云开发者、需要代码执行/RAG能力的工程师、构建流式交互产品的团队 |
| 不包含 | 本地离线运行、可视化界面、多智能体编排、内置数据库存储 |
原始链接:https://github.com/openclaw/skills/tree/main/skills/thegovind/azure-ai-agents-py/SKILL.md
来源类型:GitHub仓库