CrewAI 快速上手:10 分鐘建立第一個研究 Crew
3 min read
這篇目標很單純:你跟著做完,就能跑出第一份 AI 研究報告。
我們走最短路徑,不玩花招。
步驟 1:建立專案
crewai create crew latest-ai-notes
cd latest-ai-notes這會建立基本結構,包含:
src/latest_ai_notes/config/agents.yamlsrc/latest_ai_notes/config/tasks.yamlsrc/latest_ai_notes/crew.pysrc/latest_ai_notes/main.py
步驟 2:安裝依賴
crewai install這個指令會自動讀專案設定、建立虛擬環境並安裝套件。
你不用自己手動拼一堆 pip install。
步驟 3:設定 Agent
編輯 agents.yaml:
researcher:
role: >
{topic} Researcher
goal: >
Find useful and current information about {topic}
backstory: >
You are good at collecting reliable information and summarizing key points.
reporter:
role: >
{topic} Reporter
goal: >
Convert research notes into a readable markdown report
backstory: >
You explain technical topics with simple language and clear structure.步驟 4:設定 Task
編輯 tasks.yaml:
research_task:
description: >
Research {topic}. Focus on trends, tools, and practical examples in 2026.
expected_output: >
10 bullet points with short explanations.
agent: researcher
report_task:
description: >
Expand the research notes into a complete markdown article for beginners.
expected_output: >
A beginner-friendly markdown report with sections and conclusion.
agent: reporter
context:
- research_task
output_file: output/report.md💡
context很重要:它告訴第二個任務要吃第一個任務的結果。
步驟 5:執行 Crew
crewai run成功時你會在 output/report.md 看到內容。
第一次跑若有延遲很正常,模型呼叫就像貓主子起床:要等一下才會理你。
常見問題
| 問題 | 可能原因 | 解法 |
|---|---|---|
API key missing |
環境變數未設定 | 在 .env 加入你的 API Key |
Module not found |
依賴沒裝完整 | 重新執行 crewai install |
| 輸出很飄 | 任務描述太模糊 | 強化 expected_output 的格式要求 |
下一步
你已經跑完第一個流程了。
下一篇來講最關鍵的拆分技巧:
👉 Agent 與 Task 入門