一个结构化输出代理,展示了基于 Pydantic 模式的响应,用于创建客户支持工单。
安装 OpenAI Agents SDK:
pip install openai-agents
设置环境:
cp ../env.example .env # Edit .env and add your OpenAI API key
运行代理:
from agents import Runner from agent import root_agent result = Runner.run_sync(root_agent, "I can't log into my account and it's urgent!") print(result.final_output) # Returns SupportTicket object
# The agent will return a SupportTicket object like: { "title": "Account Login Issue", "description": "User unable to access account", "priority": "high", "category": "account_access", "steps_to_reproduce": ["Go to login page", "Enter credentials", "Error occurs"], "estimated_resolution_time": "2-4 hours" }
免责声明:
本文档采用基于机器的 AI 翻译服务进行翻译。尽管我们力求准确,但请注意,自动翻译可能存在错误或不准确之处。应以原文语言版本的文档作为权威依据。如需获取关键信息,建议使用专业的人工翻译。对于因使用本翻译而产生的任何误解或误读,我们概不负责。