mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-07-05 06:59:23 +00:00
* feat: adopt directory-based docs versioning with Edge channel Switch docs.crewai.com from navigation-only versioning (every version selector entry rendered the same docs/<lang>/* source files) to Mintlify's directory-based versioning so each version selector entry renders its own snapshot. Add an "Edge" channel under docs/edge/<lang>/* that always reflects main HEAD for unreleased work, eliminating pre-release leakage onto frozen release labels. External links to canonical /<lang>/* URLs are preserved via wildcard redirects that always land on the current default version. Layout: - docs/edge/<lang>/* rolling source (you edit here) - docs/edge/enterprise-api.*.yaml - docs/v<X.Y.Z>/<lang>/* frozen, immutable snapshots - docs/v<X.Y.Z>/enterprise-api.*.yaml - docs/images/ shared, append-only - docs/docs.json nav + redirects URLs follow the Mintlify-idiomatic shape: /edge/<lang>/<page> for Edge, /v<X.Y.Z>/<lang>/<page> for every frozen snapshot. The wildcard redirects /<lang>/:slug* -> /<default>/<lang>/:slug* keep stale links working, and every freeze rewrites them (plus all per-section/per-page redirects) so destinations always resolve to the current default without depending on a second redirect hop. Release flow integration (devtools release): - New module crewai_devtools.docs_versioning.freeze() materialises docs/v<X.Y.Z>/ from docs/edge/, rewrites openapi: refs inside the snapshot, inserts the version into every language block in docs.json, and refreshes all redirect destinations. - _update_docs_and_create_pr() in cli.py now calls that freeze during Phase 2 of devtools release. Edge changelogs are updated first (so the snapshot freeze picks them up), then the snapshot is staged alongside docs.json, branched as docs/freeze-v<X.Y.Z>, and the PR is titled [docs-freeze] docs: snapshot and changelog for v<X.Y.Z> — the title prefix the new CI guard reads. - The PR still gates tag, GitHub release, PyPI publish, and the enterprise release as before; no new PRs are added. - Pre-releases (1.X.YaN, 1.X.YbN, ...) skip the snapshot — they ride Edge — and the docs PR title omits the [docs-freeze] prefix. - docs_check (AI-generated docs scaffolding) writes to docs/edge/<lang>/* so newly-generated unreleased docs land in Edge and never accidentally touch a frozen snapshot. Migration scripts (one-shot): - scripts/docs/freeze_historical_versions.py reconstructs all 16 historical snapshots (v1.10.0 .. v1.14.7) from git tags via git archive | tar, rewriting openapi: MDX refs so each snapshot reads its own enterprise-api YAML rather than the live one. - scripts/docs/prefix_version_paths.py one-shot-migrates docs.json: rewrites every page path in 16 versioned blocks to point under docs/v<X.Y.Z>/, inserts a new Edge entry per language, tags v1.14.7 as Latest (default), prunes pages whose target file doesn't exist in the snapshot (e.g. docs/ar/ didn't exist before v1.12.0), and writes the wildcard + per-section redirects. - scripts/docs/freeze_current_edge.py is now a thin CLI wrapper around docs_versioning.freeze for manual one-off freezes (e.g. retroactively snapshotting a forgotten release). CI guards (.github/workflows/docs-snapshots.yml): - Frozen snapshots under docs/v[0-9]*/ are immutable; only PRs whose title contains [docs-freeze] (i.e. release-cut PRs generated by devtools release or the manual wrapper) may modify them. - Images under docs/images/ are append-only since snapshots share a single image directory. Deleting or renaming an image breaks every historical snapshot that still references it. Restored docs/images/crewai-otel-export.png from PR #3673; it was deleted in PR #4908 but v1.10.0 / v1.10.1 snapshots still reference it. Restoring instead of editing the snapshots preserves historical rendering fidelity and validates the new append-only rule retroactively. Tests: - lib/devtools/tests/test_docs_versioning.py covers the freeze: file copy, openapi rewrite, version insertion, default demotion, redirect upserts, per-section redirect rewriting, idempotency, and invalid inputs. Verified locally with mintlify broken-links: 0 broken links across the full site (Edge + 16 frozen versions, 4 locales). AGENTS.md (repo root) is the contributor guide for the new model; RELEASING.md is the release-cut runbook; README's Contribution section links to both. Co-authored-by: Cursor <cursoragent@cursor.com> * style: resolve linter issues --------- Co-authored-by: Cursor <cursoragent@cursor.com>
322 lines
12 KiB
Plaintext
322 lines
12 KiB
Plaintext
---
|
|
title: ابنِ أول Crew لك
|
|
description: دليل تفصيلي لإنشاء فريق AI تعاوني يعمل معًا لحل المشكلات المعقدة.
|
|
icon: users-gear
|
|
mode: "wide"
|
|
---
|
|
|
|
## إطلاق قوة الذكاء الاصطناعي التعاوني
|
|
|
|
تخيل أن لديك فريقًا من Agents الذكاء الاصطناعي المتخصصة تعمل معًا بسلاسة لحل مشكلات معقدة، كل منها يساهم بمهاراته الفريدة لتحقيق هدف مشترك. هذه هي قوة CrewAI - إطار عمل يمكّنك من إنشاء أنظمة ذكاء اصطناعي تعاونية يمكنها إنجاز مهام تفوق بكثير ما يمكن لـ AI واحد تحقيقه بمفرده.
|
|
|
|
في هذا الدليل، سنمشي عبر إنشاء Crew بحث يساعدنا في البحث والتحليل حول موضوع ما، ثم إنشاء تقرير شامل. يوضح هذا المثال العملي كيف يمكن لـ Agents الذكاء الاصطناعي التعاون لإنجاز مهام معقدة، لكنه مجرد البداية لما هو ممكن مع CrewAI.
|
|
|
|
### ما ستبنيه وتتعلمه
|
|
|
|
بنهاية هذا الدليل، ستكون قد:
|
|
|
|
1. **أنشأت فريق بحث AI متخصص** بأدوار ومسؤوليات مميزة
|
|
2. **نسّقت التعاون** بين عدة Agents ذكاء اصطناعي
|
|
3. **أتممت سير عمل معقد** يتضمن جمع المعلومات والتحليل وإنشاء التقارير
|
|
4. **بنيت مهارات أساسية** يمكنك تطبيقها على مشاريع أكثر طموحًا
|
|
|
|
### المتطلبات المسبقة
|
|
|
|
قبل البدء، تأكد من:
|
|
|
|
1. تثبيت CrewAI باتباع [دليل التثبيت](/ar/installation)
|
|
2. إعداد مفتاح API لنموذج LLM في بيئتك، باتباع [دليل إعداد LLM](/ar/concepts/llms#setting-up-your-llm)
|
|
3. فهم أساسي لـ Python
|
|
|
|
## الخطوة 1: إنشاء مشروع CrewAI جديد
|
|
|
|
أولاً، لننشئ مشروع CrewAI جديد باستخدام CLI. سينشئ هذا الأمر هيكل مشروع كامل بجميع الملفات الضرورية.
|
|
|
|
```bash
|
|
crewai create crew research_crew
|
|
cd research_crew
|
|
```
|
|
|
|
سينتج هيكل مشروع بالبنية الأساسية المطلوبة لـ Crew. ينشئ CLI تلقائيًا:
|
|
|
|
- مجلد مشروع بالملفات اللازمة
|
|
- ملفات تهيئة للـ Agents والمهام
|
|
- تطبيق Crew أساسي
|
|
- سكريبت رئيسي لتشغيل الـ Crew
|
|
|
|
<Frame caption="نظرة عامة على إطار عمل CrewAI">
|
|
<img src="/images/crews.png" alt="نظرة عامة على إطار عمل CrewAI" />
|
|
</Frame>
|
|
|
|
## الخطوة 2: استكشاف هيكل المشروع
|
|
|
|
لنخصص لحظة لفهم هيكل المشروع الذي أنشأه CLI.
|
|
|
|
```
|
|
research_crew/
|
|
├── .gitignore
|
|
├── pyproject.toml
|
|
├── README.md
|
|
├── .env
|
|
└── src/
|
|
└── research_crew/
|
|
├── __init__.py
|
|
├── main.py
|
|
├── crew.py
|
|
├── tools/
|
|
│ ├── custom_tool.py
|
|
│ └── __init__.py
|
|
└── config/
|
|
├── agents.yaml
|
|
└── tasks.yaml
|
|
```
|
|
|
|
يتبع هذا الهيكل أفضل الممارسات لمشاريع Python ويسهّل تنظيم الكود. فصل ملفات التهيئة (YAML) عن كود التنفيذ (Python) يسهّل تعديل سلوك Crew دون تغيير الكود الأساسي.
|
|
|
|
## الخطوة 3: تهيئة الـ Agents
|
|
|
|
الآن يأتي الجزء الممتع - تعريف Agents الذكاء الاصطناعي! في CrewAI، الـ Agents هي كيانات متخصصة بأدوار وأهداف وخلفيات محددة تشكّل سلوكها.
|
|
|
|
لـ Crew البحث لدينا، سننشئ Agent اثنين:
|
|
1. **باحث** يتفوق في إيجاد وتنظيم المعلومات
|
|
2. **محلل** يمكنه تفسير نتائج البحث وإنشاء تقارير ثاقبة
|
|
|
|
لنعدّل ملف `agents.yaml`. تأكد من تعيين `llm` للمزود الذي تستخدمه.
|
|
|
|
```yaml
|
|
# src/research_crew/config/agents.yaml
|
|
researcher:
|
|
role: >
|
|
Senior Research Specialist for {topic}
|
|
goal: >
|
|
Find comprehensive and accurate information about {topic}
|
|
with a focus on recent developments and key insights
|
|
backstory: >
|
|
You are an experienced research specialist with a talent for
|
|
finding relevant information from various sources. You excel at
|
|
organizing information in a clear and structured manner, making
|
|
complex topics accessible to others.
|
|
llm: provider/model-id # e.g. openai/gpt-4o, google/gemini-2.0-flash, anthropic/claude...
|
|
|
|
analyst:
|
|
role: >
|
|
Data Analyst and Report Writer for {topic}
|
|
goal: >
|
|
Analyze research findings and create a comprehensive, well-structured
|
|
report that presents insights in a clear and engaging way
|
|
backstory: >
|
|
You are a skilled analyst with a background in data interpretation
|
|
and technical writing. You have a talent for identifying patterns
|
|
and extracting meaningful insights from research data, then
|
|
communicating those insights effectively through well-crafted reports.
|
|
llm: provider/model-id # e.g. openai/gpt-4o, google/gemini-2.0-flash, anthropic/claude...
|
|
```
|
|
|
|
لاحظ كيف أن لكل Agent دور وهدف وخلفية مميزة. هذه العناصر ليست وصفية فحسب - بل تشكّل بنشاط كيف يتعامل الـ Agent مع مهامه.
|
|
|
|
## الخطوة 4: تعريف المهام
|
|
|
|
مع تعريف الـ Agents، نحتاج الآن لمنحهم مهام محددة. لنعدّل ملف `tasks.yaml`:
|
|
|
|
```yaml
|
|
# src/research_crew/config/tasks.yaml
|
|
research_task:
|
|
description: >
|
|
Conduct thorough research on {topic}. Focus on:
|
|
1. Key concepts and definitions
|
|
2. Historical development and recent trends
|
|
3. Major challenges and opportunities
|
|
4. Notable applications or case studies
|
|
5. Future outlook and potential developments
|
|
|
|
Make sure to organize your findings in a structured format with clear sections.
|
|
expected_output: >
|
|
A comprehensive research document with well-organized sections covering
|
|
all the requested aspects of {topic}. Include specific facts, figures,
|
|
and examples where relevant.
|
|
agent: researcher
|
|
|
|
analysis_task:
|
|
description: >
|
|
Analyze the research findings and create a comprehensive report on {topic}.
|
|
Your report should:
|
|
1. Begin with an executive summary
|
|
2. Include all key information from the research
|
|
3. Provide insightful analysis of trends and patterns
|
|
4. Offer recommendations or future considerations
|
|
5. Be formatted in a professional, easy-to-read style with clear headings
|
|
expected_output: >
|
|
A polished, professional report on {topic} that presents the research
|
|
findings with added analysis and insights. The report should be well-structured
|
|
with an executive summary, main sections, and conclusion.
|
|
agent: analyst
|
|
context:
|
|
- research_task
|
|
output_file: output/report.md
|
|
```
|
|
|
|
لاحظ حقل `context` في مهمة التحليل - هذه ميزة قوية تتيح للمحلل الوصول إلى مخرجات مهمة البحث.
|
|
|
|
## الخطوة 5: تهيئة الـ Crew
|
|
|
|
الآن حان الوقت لجمع كل شيء معًا. لنعدّل ملف `crew.py`:
|
|
|
|
```python
|
|
# src/research_crew/crew.py
|
|
from crewai import Agent, Crew, Process, Task
|
|
from crewai.project import CrewBase, agent, crew, task
|
|
from crewai_tools import SerperDevTool
|
|
from crewai.agents.agent_builder.base_agent import BaseAgent
|
|
from typing import List
|
|
|
|
@CrewBase
|
|
class ResearchCrew():
|
|
"""Research crew for comprehensive topic analysis and reporting"""
|
|
|
|
agents: List[BaseAgent]
|
|
tasks: List[Task]
|
|
|
|
@agent
|
|
def researcher(self) -> Agent:
|
|
return Agent(
|
|
config=self.agents_config['researcher'], # type: ignore[index]
|
|
verbose=True,
|
|
tools=[SerperDevTool()]
|
|
)
|
|
|
|
@agent
|
|
def analyst(self) -> Agent:
|
|
return Agent(
|
|
config=self.agents_config['analyst'], # type: ignore[index]
|
|
verbose=True
|
|
)
|
|
|
|
@task
|
|
def research_task(self) -> Task:
|
|
return Task(
|
|
config=self.tasks_config['research_task'] # type: ignore[index]
|
|
)
|
|
|
|
@task
|
|
def analysis_task(self) -> Task:
|
|
return Task(
|
|
config=self.tasks_config['analysis_task'], # type: ignore[index]
|
|
output_file='output/report.md'
|
|
)
|
|
|
|
@crew
|
|
def crew(self) -> Crew:
|
|
"""Creates the research crew"""
|
|
return Crew(
|
|
agents=self.agents,
|
|
tasks=self.tasks,
|
|
process=Process.sequential,
|
|
verbose=True,
|
|
)
|
|
```
|
|
|
|
## الخطوة 6: إعداد السكريبت الرئيسي
|
|
|
|
```python
|
|
#!/usr/bin/env python
|
|
# src/research_crew/main.py
|
|
import os
|
|
from research_crew.crew import ResearchCrew
|
|
|
|
# Create output directory if it doesn't exist
|
|
os.makedirs('output', exist_ok=True)
|
|
|
|
def run():
|
|
"""
|
|
Run the research crew.
|
|
"""
|
|
inputs = {
|
|
'topic': 'Artificial Intelligence in Healthcare'
|
|
}
|
|
|
|
# Create and run the crew
|
|
result = ResearchCrew().crew().kickoff(inputs=inputs)
|
|
|
|
# Print the result
|
|
print("\n\n=== FINAL REPORT ===\n\n")
|
|
print(result.raw)
|
|
|
|
print("\n\nReport has been saved to output/report.md")
|
|
|
|
if __name__ == "__main__":
|
|
run()
|
|
```
|
|
|
|
## الخطوة 7: إعداد متغيرات البيئة
|
|
|
|
أنشئ ملف `.env` في جذر مشروعك بمفاتيح API:
|
|
|
|
```sh
|
|
SERPER_API_KEY=your_serper_api_key
|
|
# Add your provider's API key here too.
|
|
```
|
|
|
|
راجع [دليل إعداد LLM](/ar/concepts/llms#setting-up-your-llm) لتفاصيل تهيئة المزود المفضل لديك. يمكنك الحصول على مفتاح Serper API من [Serper.dev](https://serper.dev/).
|
|
|
|
## الخطوة 8: تثبيت التبعيات
|
|
|
|
```bash
|
|
crewai install
|
|
```
|
|
|
|
## الخطوة 9: تشغيل الـ Crew
|
|
|
|
الآن اللحظة المثيرة - حان وقت تشغيل Crew ومشاهدة التعاون بين الـ AI!
|
|
|
|
```bash
|
|
crewai run
|
|
```
|
|
|
|
عند تشغيل هذا الأمر، سترى Crew يعمل. سيجمع الباحث معلومات حول الموضوع المحدد، ثم سينشئ المحلل تقريرًا شاملاً بناءً على ذلك البحث.
|
|
|
|
## الخطوة 10: مراجعة المخرجات
|
|
|
|
بمجرد إتمام Crew عمله، ستجد التقرير النهائي في ملف `output/report.md`. سيتضمن التقرير:
|
|
|
|
1. ملخص تنفيذي
|
|
2. معلومات مفصلة عن الموضوع
|
|
3. تحليل ورؤى
|
|
4. توصيات أو اعتبارات مستقبلية
|
|
|
|
## استكشاف أوامر CLI الأخرى
|
|
|
|
يوفر CrewAI عدة أوامر CLI مفيدة للعمل مع Crews:
|
|
|
|
```bash
|
|
# View all available commands
|
|
crewai --help
|
|
|
|
# Run the crew
|
|
crewai run
|
|
|
|
# Test the crew
|
|
crewai test
|
|
|
|
# Reset crew memories
|
|
crewai reset-memories
|
|
|
|
# Replay from a specific task
|
|
crewai replay -t <task_id>
|
|
```
|
|
|
|
## ما بعد أول Crew: فن الممكن
|
|
|
|
ما بنيته في هذا الدليل مجرد البداية. يمكنك توسيع Crew البحث الأساسي بإضافة Agents متخصصة أخرى وأدوات وقدرات إضافية وسير عمل أكثر تعقيدًا. يمكن تطبيق نفس الأنماط لإنشاء Crews لإنشاء المحتوى وخدمة العملاء وتطوير المنتجات وتحليل البيانات.
|
|
|
|
## الخطوات التالية
|
|
|
|
1. جرّب تهيئات وشخصيات Agent مختلفة
|
|
2. جرب هياكل مهام وسير عمل أكثر تعقيدًا
|
|
3. طبّق أدوات مخصصة لمنح الـ Agents قدرات جديدة
|
|
4. طبّق Crew على مواضيع أو مجالات مشكلات مختلفة
|
|
5. استكشف [CrewAI Flows](/ar/guides/flows/first-flow) لسير عمل أكثر تقدمًا مع البرمجة الإجرائية
|
|
|
|
<Check>
|
|
تهانينا! لقد بنيت بنجاح أول CrewAI Crew يمكنه البحث والتحليل في أي موضوع تقدمه. هذه التجربة الأساسية أهّلتك بالمهارات لإنشاء أنظمة AI متطورة بشكل متزايد يمكنها معالجة مشكلات معقدة متعددة المراحل من خلال الذكاء التعاوني.
|
|
</Check>
|