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.
2.4 KiB
2.4 KiB
快速开始指南
1. 安装依赖
pip install -r requirements.txt
2. 配置API Key
方式一:使用 .env 文件(推荐)
# 复制示例文件
cp .env.example .env
# 编辑 .env 文件
# DASHSCOPE_API_KEY=sk-xxxxxxxxxxxxxxxx
方式二:设置环境变量
Windows (CMD):
set DASHSCOPE_API_KEY=sk-xxxxxxxxxxxxxxxx
Windows (PowerShell):
$env:DASHSCOPE_API_KEY="sk-xxxxxxxxxxxxxxxx"
Linux/Mac:
export DASHSCOPE_API_KEY=sk-xxxxxxxxxxxxxxxx
3. 测试AI分析功能
python test_ai_analysis.py
4. 启动API服务
python api.py
访问 http://localhost:8001/docs 查看API文档
5. 使用示例
示例1:抓取游戏类创作指导数据
curl -X POST "http://localhost:8001/api/creative-guidance" \
-H "Content-Type: application/json" \
-d '{"category": "游戏"}'
示例2:分析抓取的数据
curl -X POST "http://localhost:8001/api/analyze-file" \
-H "Content-Type: application/json" \
-d '{
"json_file": "douyin_data_soupce/douyin_data/douyin_creative_guidance_游戏_20260107_112545.json",
"custom_instruction": "重点分析爆款特征"
}'
示例3:直接分析视频数据
curl -X POST "http://localhost:8001/api/analyze" \
-H "Content-Type: application/json" \
-d '{
"videos": [
{
"author": "游戏主播",
"description": "王者荣耀上分攻略 #王者荣耀",
"plays": "100万",
"likes": "5万"
}
]
}'
6. 自定义提示词
编辑 prompts/analyze_prompt.md 文件来自定义分析逻辑:
# 你的自定义提示词
你是一个专业的数据分析师...
## 分析重点
1. ...
2. ...
常见问题
Q: API Key在哪里获取?
A: 访问 https://dashscope.console.aliyun.com/ 注册并创建API Key
Q: 支持哪些模型?
A: qwen-turbo, qwen-plus(推荐), qwen-max, qwen-long
Q: 如何控制成本?
A:
- 使用 qwen-turbo 模型(更便宜)
- 减少分析的视频数量
- 精简提示词内容
Q: 分析结果保存在哪里?
A:
- API返回JSON格式结果
- 命令行工具可使用 --output 参数保存到文件
下一步
- 查看 README_AI.md 了解详细功能
- 访问 http://localhost:8001/docs 查看完整API文档
- 自定义
prompts/analyze_prompt.md提示词