azure-ai-projects-py
使用 Foundry SDK 构建 Azure AI 应用
使用 Azure AI Projects Python SDK 在 Microsoft Foundry 上构建 AI 应用程序。此技能提供创建智能体、管理会话线程、配置工具和运行评估的综合文档。
下载技能 ZIP
在 Claude 中上传
前往 设置 → 功能 → 技能 → 上传技能
开启并开始使用
测试它
正在使用“azure-ai-projects-py”。 创建一个带有 CodeInterpreterTool 的基本智能体
预期结果:
智能体创建成功,ID 为 'agent-123abc'。已启用的工具:CodeInterpreterTool。您现在可以使用此智能体创建会话线程和运行。
正在使用“azure-ai-projects-py”。 展示如何列出部署
预期结果:
可用部署:['gpt-4o-mini', 'gpt-4o', 'o1-mini']。您可以在创建智能体时使用这些模型名称。
安全审计
安全All 74 static findings are false positives. The file is a markdown documentation file (SKILL.md) containing code examples for the Azure AI Projects Python SDK. The 'external_commands' detections are markdown code fences, not shell execution. The 'network' detection is a placeholder URL template in documentation. The 'env_access' detections are documentation examples showing SDK configuration. No actual executable code or malicious patterns exist. This is a legitimate documentation skill for Microsoft's Azure Foundry SDK.
质量评分
你能构建什么
在 Microsoft Foundry 中构建 AI 智能体
使用 Azure AI Projects SDK 创建可执行 Python 代码、搜索文件和调用外部 API 的智能智能体。
配置智能体工具和功能
为您的智能体添加代码解释、文件搜索、Bing 接地和自定义函数调用等功能。
对智能体输出运行评估
使用内置评估器或创建自定义评估器来测试和衡量智能体质量及其对要求的遵循程度。
试试这些提示
使用 DefaultAzureCredential 通过 AIProjectClient 创建一个名为 'my-agent' 的 Azure AI Projects 智能体,使用 gpt-4o-mini 模型,指令为 'You are a helpful assistant.'。
创建一个启用了 CodeInterpreterTool 和 FileSearchTool 的智能体。该智能体应能够执行 Python 代码并搜索上传的文档。
展示如何使用 Azure AI Projects SDK 创建会话线程、添加用户消息、创建和处理运行,以及检索助手响应。
使用 PromptAgentDefinition 创建一个版本标签为 'v1.0' 的版本化智能体。包含客户服务专家的指令,并展示如何部署它。
最佳实践
- 对异步 AIProjectClient 使用上下文管理器 (async with) 以确保正确的资源清理
- 在生产部署中使用 PromptAgentDefinition 创建版本化智能体以维护稳定的 API
- 不再需要时使用 client.agents.delete_agent(agent.id) 清理智能体以避免资源泄漏
避免
- 不要在代码中硬编码凭据 - 始终使用 DefaultAzureCredential 或环境变量
- 当需要 connections 和 deployments 等 Foundry 特定功能时,不要使用低级别的 AgentsClient
- 避免创建大量智能体而不清理 - 完成后始终删除智能体