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 基礎和自訂函式呼叫等機能。
對代理輸出執行評估
使用內建評估器或建立自訂評估器來測試和衡量代理品質及對需求的遵循程度。
試試這些提示
使用 AIProjectClient 與 DefaultAzureCredential 建立一個名稱為 '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 或環境變數
- 當您需要 Foundry 特定功能(如連線和部署)時,不要使用低階 AgentsClient
- 避免建立許多未清理的代理 - 完成後始終刪除代理