docs: add file upload to kickoff guide, clarify flow state population, all languages

- Added new "File Uploads" section to kickoff-crew.mdx with multipart,
  JSON URL, and separate upload + kickoff examples
- Clarified that file-typed fields in flow state schema signal the
  Platform UI to render file dropzones
- Updated flows.mdx File Inputs section to show state population pattern
- Updated files.mdx With Flows section with state schema example
- Applied all changes to en, ar, ko, pt-BR translations

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Alex
2026-04-06 00:34:05 -07:00
committed by Joao Moura
parent f01f33de69
commit 50c4b6e99f
12 changed files with 316 additions and 64 deletions

View File

@@ -117,20 +117,28 @@ task = Task(
### مع التدفقات
مرر الملفات إلى التدفقات، والتي تنتقل تلقائيًا إلى الأطقم:
تعمل الحقول من نوع الملف (`File`، `ImageFile`، `PDFFile`) في مخطط حالة التدفق كإشارة لواجهة المنصة. عند النشر، تُعرض هذه الحقول كمناطق سحب وإفلات لرفع الملفات. يمكن أيضًا تمرير الملفات عبر `input_files` في API.
```python
from crewai.flow.flow import Flow, start
from crewai_files import ImageFile
from crewai_files import File, ImageFile
from pydantic import BaseModel
class AnalysisFlow(Flow):
class MyState(BaseModel):
document: File # Renders as file dropzone in Platform UI
cover_image: ImageFile # Image-specific dropzone
title: str = ""
class AnalysisFlow(Flow[MyState]):
@start()
def analyze(self):
# Files are automatically populated in state
content = self.state.document.read()
return self.analysis_crew.kickoff()
flow = AnalysisFlow()
result = flow.kickoff(
input_files={"image": ImageFile(source="data.png")}
input_files={"document": File(source="report.pdf")}
)
```

View File

@@ -343,27 +343,28 @@ flow.kickoff()
### مدخلات الملفات
عند استخدام الحالة المهيكلة، يمكنك تضمين حقول من نوع الملف باستخدام فئات من `crewai-files`. هذا يتيح رفع الملفات كجزء من مدخلات التدفق الخاص بك:
عند استخدام الحالة المهيكلة، يمكنك تضمين حقول من نوع الملف باستخدام فئات من `crewai-files`. تعمل الحقول من نوع الملف في حالة التدفق كإشارة للمنصة — فهي تُعرض تلقائيًا كمناطق سحب وإفلات لرفع الملفات في واجهة علامة تبويب Run ويتم تعبئتها عند رفع الملفات عبر المنصة أو تمريرها عبر `input_files` في API.
```python
from crewai.flow.flow import Flow, start
from crewai_files import ImageFile, PDFFile
from crewai_files import File, ImageFile, PDFFile
from pydantic import BaseModel
class OnboardingState(BaseModel):
document: PDFFile # File upload
cover_image: ImageFile # Image upload
title: str = "" # Text input
class MyState(BaseModel):
document: File # Renders as file dropzone in Platform
title: str = ""
class OnboardingFlow(Flow[OnboardingState]):
class MyFlow(Flow[MyState]):
@start()
def process_upload(self):
# Access files directly from state
print(f"Processing: {self.state.title}")
return self.state.document
def process(self):
# File object is automatically populated in state
# when uploaded via Platform UI or passed via API
content = self.state.document.read()
print(f"Processing {self.state.title}: {len(content)} bytes")
return content
```
عند النشر على **منصة CrewAI**، تُعرض الحقول من نوع الملف تلقائيًا كمناطق سحب وإفلات لرفع الملفات في واجهة المستخدم. يمكن للمستخدمين سحب وإفلات الملفات، والتي تُمرر بعد ذلك إلى التدفق الخاص بك.
عند النشر على **منصة CrewAI**، تُعرض الحقول من نوع الملف (`File`، `ImageFile`، `PDFFile` من `crewai-files`) تلقائيًا كمناطق سحب وإفلات لرفع الملفات في واجهة المستخدم. يمكن للمستخدمين سحب وإفلات الملفات، والتي تُملأ بعد ذلك في حالة التدفق الخاص بك.
**بدء التشغيل مع الملفات عبر API:**

View File

@@ -86,6 +86,60 @@ curl -H "Authorization: Bearer YOUR_CREW_TOKEN" https://your-crew-url.crewai.com
رمز الحامل متاح في علامة تبويب Status في صفحة تفاصيل طاقمك.
## رفع الملفات
عندما يتضمن طاقمك أو تدفقك حقول حالة من نوع الملف (باستخدام `ImageFile` أو `PDFFile` أو `File` من `crewai-files`)، تُعرض هذه الحقول تلقائيًا كمناطق سحب وإفلات لرفع الملفات في واجهة علامة تبويب Run. يمكن للمستخدمين سحب وإفلات الملفات مباشرة، وتتولى المنصة التخزين والتسليم إلى وكلائك.
### بدء تشغيل Multipart (موصى به)
أرسل الملفات مباشرة مع طلب بدء التشغيل باستخدام `multipart/form-data`:
```bash
curl -X POST https://your-deployment.crewai.com/kickoff \
-H 'Authorization: Bearer YOUR_TOKEN' \
-F 'inputs={"title": "Report"}' \
-F 'document=@/path/to/file.pdf'
```
يتم تخزين الملفات تلقائيًا وتحويلها إلى كائنات ملفات. يتلقى الوكيل الملف مع تحسين خاص بالمزود (base64 مضمّن، أو API لرفع الملفات، أو مرجع URL حسب مزود LLM).
### بدء تشغيل JSON مع عناوين URL للملفات
إذا كانت لديك ملفات مستضافة بالفعل على عناوين URL، مررها عبر `input_files`:
```bash
curl -X POST https://your-deployment.crewai.com/kickoff \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"inputs": {"title": "Report"},
"input_files": {"document": "https://example.com/file.pdf"}
}'
```
### رفع منفصل + بدء تشغيل
ارفع الملفات أولاً، ثم أشِر إليها بواسطة URL:
```bash
# Step 1: Upload
curl -X POST https://your-deployment.crewai.com/files \
-H 'Authorization: Bearer YOUR_TOKEN' \
-F 'file=@/path/to/file.pdf' \
-F 'field_name=document'
# Returns: {"url": "https://...", "field_name": "document"}
# Step 2: Kickoff with URL
curl -X POST https://your-deployment.crewai.com/kickoff \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"inputs": {"title": "Report"}, "input_files": {"document": "https://..."}}'
```
<Note type="info">
يعمل رفع الملفات بنفس الطريقة لكل من الطواقم والتدفقات. عرّف حقول من نوع الملف في مخطط حالتك، وستتولى واجهة المنصة وAPI الرفع تلقائيًا.
</Note>
### التحقق من صحة الطاقم
قبل تنفيذ العمليات، يمكنك التحقق من أن طاقمك يعمل بشكل صحيح: