10. 实战案例
10.1 市场调研任务
typescript
// 用户请求: "帮我调研 AI 编程助手市场的主要竞争对手"
const taskPlan = {
goal: "调研 AI 编程助手市场竞争对手",
steps: [
{
id: 1,
description: "搜索 AI 编程助手相关信息",
tool: "browser_navigate",
params: { url: "https://www.google.com/search?q=AI+coding+assistant+tools+2024" }
},
{
id: 2,
description: "访问 GitHub Copilot 官网获取信息",
tool: "browser_navigate",
params: { url: "https://github.com/features/copilot" }
},
{
id: 3,
description: "提取 Copilot 产品信息",
tool: "browser_extract",
params: {
schema: {
name: "string",
pricing: "array",
features: "array",
targetUsers: "string"
}
}
},
// ... 更多步骤访问其他竞品
{
id: 10,
description: "生成竞品分析报告",
tool: "shell_python",
params: {
code: `
import json
import pandas as pd
# 加载收集的数据
with open('competitors.json') as f:
data = json.load(f)
# 创建对比表格
df = pd.DataFrame(data)
df.to_csv('competitor_comparison.csv')
df.to_html('competitor_comparison.html')
# 生成 Markdown 报告
report = generate_markdown_report(data)
with open('competitor_analysis.md', 'w') as f:
f.write(report)
`
}
},
{
id: 11,
description: "发送结果给用户",
tool: "message_user",
params: {
content: "市场调研完成!已生成竞品分析报告。",
attachments: [
"competitor_analysis.md",
"competitor_comparison.csv"
]
}
}
],
deliverables: [
"competitor_analysis.md",
"competitor_comparison.csv",
"competitor_comparison.html"
]
};10.2 数据处理任务
typescript
// 用户请求: "帮我分析这个销售数据 Excel 并生成可视化报告"
async function analyzeSalesData(filePath: string) {
const agent = new ManusAgent();
return await agent.run(`
分析销售数据文件 ${filePath}:
1. 读取 Excel 文件,理解数据结构
2. 清洗数据(处理缺失值、异常值)
3. 计算关键指标:
- 总销售额
- 月度趋势
- 产品类别分布
- 地区销售对比
4. 生成可视化图表:
- 销售趋势折线图
- 产品分类饼图
- 地区热力图
5. 生成 HTML 报告,包含图表和关键发现
6. 导出处理后的数据为 CSV
`);
}