You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
3.0 KiB
3.0 KiB
AI Agent 快速开始
30秒上手
1. 配置API Key
# 创建 .env 文件
echo "DASHSCOPE_API_KEY=your_api_key_here" > .env
2. 测试Agent
python test_agent.py
3. 使用API
# 启动服务
python api.py
# 调用Agent
curl -X POST "http://localhost:8001/api/agent" \
-H "Content-Type: application/json" \
-d '{"query": "帮我分析一下游戏类视频的热门趋势"}'
常用查询示例
分析分类趋势
curl -X POST "http://localhost:8001/api/agent" \
-H "Content-Type: application/json" \
-d '{"query": "帮我分析一下游戏类视频的热门趋势"}'
获取创作建议
curl -X POST "http://localhost:8001/api/agent" \
-H "Content-Type: application/json" \
-d '{"query": "我想做美食相关的内容,给我一些建议"}'
分析特定关键词
curl -X POST "http://localhost:8001/api/agent" \
-H "Content-Type: application/json" \
-d '{"query": "王者荣耀的视频现在什么内容最火?"}'
多分类对比
curl -X POST "http://localhost:8001/api/agent" \
-H "Content-Type: application/json" \
-d '{"query": "对比一下游戏和美食两个分类的热门趋势"}'
自定义Agent行为
修改提示词
编辑 prompts/agent_prompt.md:
## 工作流程
### 2. 制定执行计划
**场景A:用户提到明确的分类**
- 使用 `get_creative_guidance` 获取数据
- 使用 `analyze_video_data` 分析
- 总结并给出建议
**场景B:你的自定义场景**
- 你的自定义逻辑
- ...
添加新工具
在 ai_agent.py 中:
# 1. 定义工具函数
async def your_tool(param: str) -> Dict:
# 实现
return {"success": True, "data": ...}
# 2. 在 create_agent() 中注册
agent.register_tool(
name="your_tool",
func=your_tool,
description="工具描述",
parameters={...}
)
工作原理
用户: "帮我分析游戏类视频"
↓
Agent: 理解意图 → 需要游戏分类数据
↓
Agent: 调用 get_creative_guidance(category="游戏")
↓
Agent: 获得50个视频数据
↓
Agent: 调用 analyze_video_data(videos=...)
↓
Agent: 获得统计分析结果
↓
Agent: 生成最终答案(包含趋势、建议等)
↓
返回给用户
支持的查询类型
✅ 分类分析
- "分析游戏类视频"
- "美食分类的热门趋势"
✅ 创作建议
- "我想做XX内容,给我建议"
- "如何做好XX类视频"
✅ 关键词分析
- "XX的视频什么最火"
- "XX领域的热门话题"
✅ 对比分析
- "对比XX和YY两个分类"
- "XX和YY哪个更火"
❌ 不支持的查询
- 创作具体内容(如"写一个视频脚本")
- 非抖音相关的问题
- 需要实时数据的问题
下一步
- 查看 README_AGENT.md 了解详细功能
- 修改 prompts/agent_prompt.md 自定义行为
- 在 ai_agent.py 中添加新工具
- 访问 http://localhost:8001/docs 查看API文档