mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-07-01 21:28: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>
142 lines
6.5 KiB
Plaintext
142 lines
6.5 KiB
Plaintext
---
|
|
title: استخدام الوكلاء متعددي الوسائط
|
|
description: تعلم كيفية تفعيل واستخدام القدرات متعددة الوسائط في وكلائك لمعالجة الصور والمحتوى غير النصي ضمن إطار عمل CrewAI.
|
|
icon: video
|
|
mode: "wide"
|
|
---
|
|
|
|
## استخدام الوكلاء متعددي الوسائط
|
|
|
|
يدعم CrewAI الوكلاء متعددي الوسائط القادرين على معالجة المحتوى النصي وغير النصي مثل الصور. سيوضح لك هذا الدليل كيفية تفعيل واستخدام القدرات متعددة الوسائط في وكلائك.
|
|
|
|
### تفعيل القدرات متعددة الوسائط
|
|
|
|
لإنشاء وكيل متعدد الوسائط، ما عليك سوى تعيين معامل `multimodal` إلى `True` عند تهيئة وكيلك:
|
|
|
|
```python
|
|
from crewai import Agent
|
|
|
|
agent = Agent(
|
|
role="Image Analyst",
|
|
goal="Analyze and extract insights from images",
|
|
backstory="An expert in visual content interpretation with years of experience in image analysis",
|
|
multimodal=True # This enables multimodal capabilities
|
|
)
|
|
```
|
|
|
|
عند تعيين `multimodal=True`، يتم إعداد الوكيل تلقائياً بالأدوات اللازمة للتعامل مع المحتوى غير النصي، بما في ذلك `AddImageTool`.
|
|
|
|
### العمل مع الصور
|
|
|
|
يأتي الوكيل متعدد الوسائط مُعداً مسبقاً بأداة `AddImageTool`، التي تتيح له معالجة الصور. لا تحتاج إلى إضافة هذه الأداة يدوياً — فهي مضمنة تلقائياً عند تفعيل القدرات متعددة الوسائط.
|
|
|
|
إليك مثالاً كاملاً يوضح كيفية استخدام وكيل متعدد الوسائط لتحليل صورة:
|
|
|
|
```python
|
|
from crewai import Agent, Task, Crew
|
|
|
|
# Create a multimodal agent
|
|
image_analyst = Agent(
|
|
role="Product Analyst",
|
|
goal="Analyze product images and provide detailed descriptions",
|
|
backstory="Expert in visual product analysis with deep knowledge of design and features",
|
|
multimodal=True
|
|
)
|
|
|
|
# Create a task for image analysis
|
|
task = Task(
|
|
description="Analyze the product image at https://example.com/product.jpg and provide a detailed description",
|
|
expected_output="A detailed description of the product image",
|
|
agent=image_analyst
|
|
)
|
|
|
|
# Create and run the crew
|
|
crew = Crew(
|
|
agents=[image_analyst],
|
|
tasks=[task]
|
|
)
|
|
|
|
result = crew.kickoff()
|
|
```
|
|
|
|
### الاستخدام المتقدم مع السياق
|
|
|
|
يمكنك تقديم سياق إضافي أو أسئلة محددة حول الصورة عند إنشاء مهام للوكلاء متعددي الوسائط. يمكن أن يتضمن وصف المهمة جوانب محددة تريد أن يركز عليها الوكيل:
|
|
|
|
```python
|
|
from crewai import Agent, Task, Crew
|
|
|
|
# Create a multimodal agent for detailed analysis
|
|
expert_analyst = Agent(
|
|
role="Visual Quality Inspector",
|
|
goal="Perform detailed quality analysis of product images",
|
|
backstory="Senior quality control expert with expertise in visual inspection",
|
|
multimodal=True # AddImageTool is automatically included
|
|
)
|
|
|
|
# Create a task with specific analysis requirements
|
|
inspection_task = Task(
|
|
description="""
|
|
Analyze the product image at https://example.com/product.jpg with focus on:
|
|
1. Quality of materials
|
|
2. Manufacturing defects
|
|
3. Compliance with standards
|
|
Provide a detailed report highlighting any issues found.
|
|
""",
|
|
expected_output="A detailed report highlighting any issues found",
|
|
agent=expert_analyst
|
|
)
|
|
|
|
# Create and run the crew
|
|
crew = Crew(
|
|
agents=[expert_analyst],
|
|
tasks=[inspection_task]
|
|
)
|
|
|
|
result = crew.kickoff()
|
|
```
|
|
|
|
### تفاصيل الأداة
|
|
|
|
عند العمل مع الوكلاء متعددي الوسائط، يتم إعداد `AddImageTool` تلقائياً بالمخطط التالي:
|
|
|
|
```python
|
|
class AddImageToolSchema:
|
|
image_url: str # Required: The URL or path of the image to process
|
|
action: Optional[str] = None # Optional: Additional context or specific questions about the image
|
|
```
|
|
|
|
سيتعامل الوكيل متعدد الوسائط تلقائياً مع معالجة الصور من خلال أدواته المدمجة، مما يتيح له:
|
|
- الوصول إلى الصور عبر عناوين URL أو مسارات الملفات المحلية
|
|
- معالجة محتوى الصورة مع سياق اختياري أو أسئلة محددة
|
|
- تقديم تحليلات ورؤى بناءً على المعلومات البصرية ومتطلبات المهمة
|
|
|
|
### أفضل الممارسات
|
|
|
|
عند العمل مع الوكلاء متعددي الوسائط، ضع هذه الممارسات في الاعتبار:
|
|
|
|
1. **الوصول إلى الصور**
|
|
- تأكد من أن صورك قابلة للوصول عبر عناوين URL التي يمكن للوكيل الوصول إليها
|
|
- للصور المحلية، فكر في استضافتها مؤقتاً أو استخدام مسارات ملفات مطلقة
|
|
- تحقق من أن عناوين URL للصور صالحة وقابلة للوصول قبل تشغيل المهام
|
|
|
|
2. **وصف المهمة**
|
|
- كن محدداً حول الجوانب التي تريد من الوكيل تحليلها في الصورة
|
|
- قم بتضمين أسئلة أو متطلبات واضحة في وصف المهمة
|
|
- فكر في استخدام معامل `action` الاختياري للتحليل المركز
|
|
|
|
3. **إدارة الموارد**
|
|
- قد تتطلب معالجة الصور موارد حسابية أكثر من المهام النصية فقط
|
|
- قد تتطلب بعض نماذج اللغة ترميز base64 لبيانات الصورة
|
|
- فكر في المعالجة الدفعية لصور متعددة لتحسين الأداء
|
|
|
|
4. **إعداد البيئة**
|
|
- تحقق من أن بيئتك تحتوي على الاعتماديات اللازمة لمعالجة الصور
|
|
- تأكد من أن نموذج اللغة الخاص بك يدعم القدرات متعددة الوسائط
|
|
- اختبر بصور صغيرة أولاً للتحقق من إعدادك
|
|
|
|
5. **معالجة الأخطاء**
|
|
- نفّذ معالجة أخطاء مناسبة لحالات فشل تحميل الصور
|
|
- ضع استراتيجيات احتياطية لحالات فشل معالجة الصور
|
|
- راقب وسجل عمليات معالجة الصور لأغراض التصحيح
|