mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-07-01 13:18:10 +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>
291 lines
16 KiB
Plaintext
291 lines
16 KiB
Plaintext
---
|
|
title: الأدوات
|
|
description: فهم واستخدام الأدوات ضمن إطار عمل CrewAI لتعاون الوكلاء وتنفيذ المهام.
|
|
icon: screwdriver-wrench
|
|
mode: "wide"
|
|
---
|
|
|
|
## نظرة عامة
|
|
|
|
تُمكّن أدوات CrewAI الوكلاء بقدرات تتراوح من البحث على الويب وتحليل البيانات إلى التعاون وتفويض المهام بين الزملاء.
|
|
توضح هذه الوثائق كيفية إنشاء هذه الأدوات ودمجها والاستفادة منها ضمن إطار عمل CrewAI، بما في ذلك التركيز على أدوات التعاون.
|
|
|
|
<Note type="info" title="الأدوات هي أحد أنواع قدرات الوكيل الخمسة">
|
|
الأدوات تمنح الوكلاء **دوال قابلة للاستدعاء** لاتخاذ إجراءات. تعمل جنبًا إلى جنب مع [MCP](/ar/mcp/overview) (خوادم أدوات عن بُعد) و[التطبيقات](/ar/concepts/agent-capabilities) (تكاملات المنصة) و[المهارات](/ar/concepts/skills) (خبرة المجال) و[المعرفة](/ar/concepts/knowledge) (حقائق مُسترجعة). راجع نظرة عامة على [قدرات الوكيل](/ar/concepts/agent-capabilities) لفهم متى تستخدم كل نوع.
|
|
</Note>
|
|
|
|
## ما هي الأداة؟
|
|
|
|
الأداة في CrewAI هي مهارة أو وظيفة يمكن للوكلاء استخدامها لأداء إجراءات مختلفة.
|
|
يشمل ذلك أدوات من [مجموعة أدوات CrewAI](https://github.com/joaomdmoura/crewai-tools) و[أدوات LangChain](https://python.langchain.com/docs/integrations/tools)،
|
|
مما يُمكّن كل شيء من عمليات البحث البسيطة إلى التفاعلات المعقدة والعمل الجماعي الفعال بين الوكلاء.
|
|
|
|
<Note type="info" title="تحسين المؤسسات: مستودع الأدوات">
|
|
يوفر CrewAI AMP مستودع أدوات شامل مع تكاملات جاهزة لأنظمة الأعمال الشائعة وواجهات API. انشر الوكلاء مع أدوات المؤسسة في دقائق بدلاً من أيام.
|
|
|
|
يتضمن مستودع أدوات المؤسسة:
|
|
|
|
- موصلات جاهزة لأنظمة المؤسسة الشائعة
|
|
- واجهة إنشاء أدوات مخصصة
|
|
- إمكانيات التحكم في الإصدارات والمشاركة
|
|
- ميزات الأمان والامتثال
|
|
</Note>
|
|
|
|
## الخصائص الرئيسية للأدوات
|
|
|
|
- **المنفعة**: مصممة لمهام مثل البحث على الويب وتحليل البيانات وإنشاء المحتوى وتعاون الوكلاء.
|
|
- **التكامل**: تعزز قدرات الوكلاء من خلال دمج الأدوات بسلاسة في سير عملهم.
|
|
- **القابلية للتخصيص**: توفر المرونة لتطوير أدوات مخصصة أو استخدام الأدوات الموجودة، لتلبية الاحتياجات المحددة للوكلاء.
|
|
- **معالجة الأخطاء**: تتضمن آليات معالجة أخطاء قوية لضمان التشغيل السلس.
|
|
- **آلية التخزين المؤقت**: تتميز بتخزين مؤقت ذكي لتحسين الأداء وتقليل العمليات المتكررة.
|
|
- **الدعم غير المتزامن**: تتعامل مع الأدوات المتزامنة وغير المتزامنة، مما يُمكّن العمليات غير الحاجبة.
|
|
|
|
## استخدام أدوات CrewAI
|
|
|
|
لتعزيز قدرات وكلائك بأدوات CrewAI، ابدأ بتثبيت حزمة الأدوات الإضافية:
|
|
|
|
```bash
|
|
pip install 'crewai[tools]'
|
|
```
|
|
|
|
إليك مثالًا يوضح استخدامها:
|
|
|
|
```python Code
|
|
import os
|
|
from crewai import Agent, Task, Crew
|
|
# استيراد أدوات crewAI
|
|
from crewai_tools import (
|
|
DirectoryReadTool,
|
|
FileReadTool,
|
|
SerperDevTool,
|
|
WebsiteSearchTool
|
|
)
|
|
|
|
# إعداد مفاتيح API
|
|
os.environ["SERPER_API_KEY"] = "Your Key" # serper.dev API key
|
|
os.environ["OPENAI_API_KEY"] = "Your Key"
|
|
|
|
# إنشاء الأدوات
|
|
docs_tool = DirectoryReadTool(directory='./blog-posts')
|
|
file_tool = FileReadTool()
|
|
search_tool = SerperDevTool()
|
|
web_rag_tool = WebsiteSearchTool()
|
|
|
|
# إنشاء الوكلاء
|
|
researcher = Agent(
|
|
role='Market Research Analyst',
|
|
goal='Provide up-to-date market analysis of the AI industry',
|
|
backstory='An expert analyst with a keen eye for market trends.',
|
|
tools=[search_tool, web_rag_tool],
|
|
verbose=True
|
|
)
|
|
|
|
writer = Agent(
|
|
role='Content Writer',
|
|
goal='Craft engaging blog posts about the AI industry',
|
|
backstory='A skilled writer with a passion for technology.',
|
|
tools=[docs_tool, file_tool],
|
|
verbose=True
|
|
)
|
|
|
|
# تعريف المهام
|
|
research = Task(
|
|
description='Research the latest trends in the AI industry and provide a summary.',
|
|
expected_output='A summary of the top 3 trending developments in the AI industry with a unique perspective on their significance.',
|
|
agent=researcher
|
|
)
|
|
|
|
write = Task(
|
|
description='Write an engaging blog post about the AI industry, based on the research analyst\'s summary. Draw inspiration from the latest blog posts in the directory.',
|
|
expected_output='A 4-paragraph blog post formatted in markdown with engaging, informative, and accessible content, avoiding complex jargon.',
|
|
agent=writer,
|
|
output_file='blog-posts/new_post.md'
|
|
)
|
|
|
|
# تجميع طاقم مع تفعيل التخطيط
|
|
crew = Crew(
|
|
agents=[researcher, writer],
|
|
tasks=[research, write],
|
|
verbose=True,
|
|
planning=True,
|
|
)
|
|
|
|
# تنفيذ المهام
|
|
crew.kickoff()
|
|
```
|
|
|
|
## أدوات CrewAI المتاحة
|
|
|
|
- **معالجة الأخطاء**: جميع الأدوات مبنية بقدرات معالجة الأخطاء، مما يسمح للوكلاء بإدارة الاستثناءات بسلاسة ومتابعة مهامهم.
|
|
- **آلية التخزين المؤقت**: جميع الأدوات تدعم التخزين المؤقت، مما يُمكّن الوكلاء من إعادة استخدام النتائج المحصلة سابقًا بكفاءة، مما يقلل الحمل على الموارد الخارجية ويسرّع وقت التنفيذ. يمكنك أيضًا تحديد تحكم أدق في آلية التخزين المؤقت باستخدام خاصية `cache_function` على الأداة.
|
|
|
|
إليك قائمة بالأدوات المتاحة وأوصافها:
|
|
|
|
| الأداة | الوصف |
|
|
| :------------------------------- | :--------------------------------------------------------------------------------------------- |
|
|
| **ApifyActorsTool** | أداة تدمج Apify Actors مع سير عملك لمهام استخراج البيانات من الويب والأتمتة. |
|
|
| **BrowserbaseLoadTool** | أداة للتفاعل مع المتصفحات واستخراج البيانات منها. |
|
|
| **CodeDocsSearchTool** | أداة RAG محسّنة للبحث في وثائق الكود والمستندات التقنية ذات الصلة. |
|
|
| **CodeInterpreterTool** | أداة لتفسير كود Python. |
|
|
| **ComposioTool** | تُمكّن استخدام أدوات Composio. |
|
|
| **CSVSearchTool** | أداة RAG مصممة للبحث في ملفات CSV، مخصصة للتعامل مع البيانات المنظمة. |
|
|
| **DALL-E Tool** | أداة لإنشاء الصور باستخدام DALL-E API. |
|
|
| **DirectorySearchTool** | أداة RAG للبحث في المجلدات، مفيدة للتنقل في أنظمة الملفات. |
|
|
| **DOCXSearchTool** | أداة RAG للبحث في مستندات DOCX، مثالية لمعالجة ملفات Word. |
|
|
| **DirectoryReadTool** | تسهّل قراءة ومعالجة هياكل المجلدات ومحتوياتها. |
|
|
| **ExaSearchTool** | أداة مصممة لإجراء عمليات بحث شاملة عبر مصادر بيانات متنوعة. |
|
|
| **FileReadTool** | تُمكّن قراءة واستخراج البيانات من الملفات، مع دعم تنسيقات ملفات متنوعة. |
|
|
| **FirecrawlSearchTool** | أداة للبحث في صفحات الويب باستخدام Firecrawl وإرجاع النتائج. |
|
|
| **FirecrawlCrawlWebsiteTool** | أداة لزحف صفحات الويب باستخدام Firecrawl. |
|
|
| **FirecrawlScrapeWebsiteTool** | أداة لاستخراج محتوى عناوين URL لصفحات الويب باستخدام Firecrawl. |
|
|
| **GithubSearchTool** | أداة RAG للبحث في مستودعات GitHub، مفيدة لبحث الكود والوثائق. |
|
|
| **SerperDevTool** | أداة متخصصة لأغراض التطوير، مع وظائف محددة قيد التطوير. |
|
|
| **TXTSearchTool** | أداة RAG مركّزة على البحث في ملفات النص (.txt)، مناسبة للبيانات غير المنظمة. |
|
|
| **JSONSearchTool** | أداة RAG مصممة للبحث في ملفات JSON، تخدم التعامل مع البيانات المنظمة. |
|
|
| **LlamaIndexTool** | تُمكّن استخدام أدوات LlamaIndex. |
|
|
| **MDXSearchTool** | أداة RAG مخصصة للبحث في ملفات Markdown (MDX)، مفيدة للوثائق. |
|
|
| **PDFSearchTool** | أداة RAG للبحث في مستندات PDF، مثالية لمعالجة المستندات الممسوحة ضوئيًا. |
|
|
| **PGSearchTool** | أداة RAG محسّنة للبحث في قواعد بيانات PostgreSQL، مناسبة لاستعلامات قواعد البيانات. |
|
|
| **Vision Tool** | أداة لإنشاء الصور باستخدام DALL-E API. |
|
|
| **RagTool** | أداة RAG للأغراض العامة قادرة على التعامل مع مصادر وأنواع بيانات متنوعة. |
|
|
| **ScrapeElementFromWebsiteTool** | تُمكّن استخراج عناصر محددة من المواقع، مفيدة لاستخراج البيانات المستهدف. |
|
|
| **ScrapeWebsiteTool** | تسهّل استخراج المواقع بالكامل، مثالية لجمع البيانات الشامل. |
|
|
| **WebsiteSearchTool** | أداة RAG للبحث في محتوى المواقع، محسّنة لاستخراج بيانات الويب. |
|
|
| **XMLSearchTool** | أداة RAG مصممة للبحث في ملفات XML، مناسبة لتنسيقات البيانات المنظمة. |
|
|
| **YoutubeChannelSearchTool** | أداة RAG للبحث في قنوات YouTube، مفيدة لتحليل محتوى الفيديو. |
|
|
| **YoutubeVideoSearchTool** | أداة RAG للبحث في مقاطع فيديو YouTube، مثالية لاستخراج بيانات الفيديو. |
|
|
|
|
## إنشاء أدواتك الخاصة
|
|
|
|
<Tip>
|
|
يمكن للمطورين إنشاء `أدوات مخصصة` مصممة خصيصًا لاحتياجات وكلائهم أو
|
|
استخدام الخيارات الجاهزة.
|
|
</Tip>
|
|
|
|
هناك طريقتان رئيسيتان لإنشاء أداة CrewAI:
|
|
|
|
### الوراثة من `BaseTool`
|
|
|
|
```python Code
|
|
from crewai.tools import BaseTool
|
|
from pydantic import BaseModel, Field
|
|
|
|
class MyToolInput(BaseModel):
|
|
"""Input schema for MyCustomTool."""
|
|
argument: str = Field(..., description="Description of the argument.")
|
|
|
|
class MyCustomTool(BaseTool):
|
|
name: str = "Name of my tool"
|
|
description: str = "What this tool does. It's vital for effective utilization."
|
|
args_schema: Type[BaseModel] = MyToolInput
|
|
|
|
def _run(self, argument: str) -> str:
|
|
# منطق أداتك هنا
|
|
return "Tool's result"
|
|
```
|
|
|
|
## دعم الأدوات غير المتزامنة
|
|
|
|
يدعم CrewAI الأدوات غير المتزامنة، مما يتيح لك تنفيذ أدوات تجري عمليات غير حاجبة مثل طلبات الشبكة وعمليات الإدخال/الإخراج على الملفات أو عمليات async أخرى بدون حجب مسار التنفيذ الرئيسي.
|
|
|
|
### إنشاء أدوات غير متزامنة
|
|
|
|
يمكنك إنشاء أدوات غير متزامنة بطريقتين:
|
|
|
|
#### 1. استخدام مزيّن `tool` مع دوال Async
|
|
|
|
```python Code
|
|
from crewai.tools import tool
|
|
|
|
@tool("fetch_data_async")
|
|
async def fetch_data_async(query: str) -> str:
|
|
"""Asynchronously fetch data based on the query."""
|
|
# محاكاة عملية غير متزامنة
|
|
await asyncio.sleep(1)
|
|
return f"Data retrieved for {query}"
|
|
```
|
|
|
|
#### 2. تنفيذ طرق Async في فئات الأدوات المخصصة
|
|
|
|
```python Code
|
|
from crewai.tools import BaseTool
|
|
|
|
class AsyncCustomTool(BaseTool):
|
|
name: str = "async_custom_tool"
|
|
description: str = "An asynchronous custom tool"
|
|
|
|
async def _run(self, query: str = "") -> str:
|
|
"""Asynchronously run the tool"""
|
|
# تنفيذك غير المتزامن هنا
|
|
await asyncio.sleep(1)
|
|
return f"Processed {query} asynchronously"
|
|
```
|
|
|
|
### استخدام الأدوات غير المتزامنة
|
|
|
|
تعمل الأدوات غير المتزامنة بسلاسة في كل من سير عمل الطاقم القياسي وسير عمل التدفق:
|
|
|
|
```python Code
|
|
# في طاقم قياسي
|
|
agent = Agent(role="researcher", tools=[async_custom_tool])
|
|
|
|
# في تدفق
|
|
class MyFlow(Flow):
|
|
@start()
|
|
async def begin(self):
|
|
crew = Crew(agents=[agent])
|
|
result = await crew.kickoff_async()
|
|
return result
|
|
```
|
|
|
|
يتعامل إطار عمل CrewAI تلقائيًا مع تنفيذ الأدوات المتزامنة وغير المتزامنة، لذا لا تحتاج للقلق بشأن كيفية استدعائها بشكل مختلف.
|
|
|
|
### استخدام مزيّن `tool`
|
|
|
|
```python Code
|
|
from crewai.tools import tool
|
|
@tool("Name of my tool")
|
|
def my_tool(question: str) -> str:
|
|
"""Clear description for what this tool is useful for, your agent will need this information to use it."""
|
|
# منطق الدالة هنا
|
|
return "Result from your custom tool"
|
|
```
|
|
|
|
### آلية التخزين المؤقت المخصصة
|
|
|
|
<Tip>
|
|
يمكن للأدوات اختياريًا تنفيذ `cache_function` لضبط سلوك
|
|
التخزين المؤقت. تحدد هذه الدالة متى يتم تخزين النتائج مؤقتًا بناءً على شروط
|
|
محددة، مما يوفر تحكمًا دقيقًا في منطق التخزين المؤقت.
|
|
</Tip>
|
|
|
|
```python Code
|
|
from crewai.tools import tool
|
|
|
|
@tool
|
|
def multiplication_tool(first_number: int, second_number: int) -> str:
|
|
"""Useful for when you need to multiply two numbers together."""
|
|
return first_number * second_number
|
|
|
|
def cache_func(args, result):
|
|
# في هذه الحالة، نخزّن النتيجة مؤقتًا فقط إذا كانت من مضاعفات 2
|
|
cache = result % 2 == 0
|
|
return cache
|
|
|
|
multiplication_tool.cache_function = cache_func
|
|
|
|
writer1 = Agent(
|
|
role="Writer",
|
|
goal="You write lessons of math for kids.",
|
|
backstory="You're an expert in writing and you love to teach kids but you know nothing of math.",
|
|
tools=[multiplication_tool],
|
|
allow_delegation=False,
|
|
)
|
|
#...
|
|
```
|
|
|
|
## الخلاصة
|
|
|
|
الأدوات محورية في توسيع قدرات وكلاء CrewAI، مما يمكّنهم من تنفيذ مجموعة واسعة من المهام والتعاون بفعالية.
|
|
عند بناء حلول مع CrewAI، استفد من كل من الأدوات المخصصة والموجودة لتمكين وكلائك وتعزيز نظام الذكاء الاصطناعي البيئي. فكّر في استخدام معالجة الأخطاء وآليات التخزين المؤقت ومرونة معاملات الأدوات لتحسين أداء وقدرات وكلائك.
|