mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-07-02 13:48:09 +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>
268 lines
7.4 KiB
Plaintext
268 lines
7.4 KiB
Plaintext
---
|
|
title: Files
|
|
description: Pass images, PDFs, audio, video, and text files to your agents for multimodal processing.
|
|
icon: file-image
|
|
---
|
|
|
|
## Overview
|
|
|
|
CrewAI supports native multimodal file inputs, allowing you to pass images, PDFs, audio, video, and text files directly to your agents. Files are automatically formatted for each LLM provider's API requirements.
|
|
|
|
<Note type="info" title="Optional Dependency">
|
|
File support requires the optional `crewai-files` package. Install it with:
|
|
|
|
```bash
|
|
uv add 'crewai[file-processing]'
|
|
```
|
|
</Note>
|
|
|
|
<Note type="warning" title="Early Access">
|
|
The file processing API is currently in early access.
|
|
</Note>
|
|
|
|
## File Types
|
|
|
|
CrewAI supports five specific file types plus a generic `File` class that auto-detects the type:
|
|
|
|
| Type | Class | Use Cases |
|
|
|:-----|:------|:----------|
|
|
| **Image** | `ImageFile` | Photos, screenshots, diagrams, charts |
|
|
| **PDF** | `PDFFile` | Documents, reports, papers |
|
|
| **Audio** | `AudioFile` | Voice recordings, podcasts, meetings |
|
|
| **Video** | `VideoFile` | Screen recordings, presentations |
|
|
| **Text** | `TextFile` | Code files, logs, data files |
|
|
| **Generic** | `File` | Auto-detect type from content |
|
|
|
|
```python
|
|
from crewai_files import File, ImageFile, PDFFile, AudioFile, VideoFile, TextFile
|
|
|
|
image = ImageFile(source="screenshot.png")
|
|
pdf = PDFFile(source="report.pdf")
|
|
audio = AudioFile(source="meeting.mp3")
|
|
video = VideoFile(source="demo.mp4")
|
|
text = TextFile(source="data.csv")
|
|
|
|
file = File(source="document.pdf")
|
|
```
|
|
|
|
## File Sources
|
|
|
|
The `source` parameter accepts multiple input types and auto-detects the appropriate handler:
|
|
|
|
### From Path
|
|
|
|
```python
|
|
from crewai_files import ImageFile
|
|
|
|
image = ImageFile(source="./images/chart.png")
|
|
```
|
|
|
|
### From URL
|
|
|
|
```python
|
|
from crewai_files import ImageFile
|
|
|
|
image = ImageFile(source="https://example.com/image.png")
|
|
```
|
|
|
|
### From Bytes
|
|
|
|
```python
|
|
from crewai_files import ImageFile, FileBytes
|
|
|
|
image_bytes = download_image_from_api()
|
|
image = ImageFile(source=FileBytes(data=image_bytes, filename="downloaded.png"))
|
|
image = ImageFile(source=image_bytes)
|
|
```
|
|
|
|
## Using Files
|
|
|
|
Files can be passed at multiple levels, with more specific levels taking precedence.
|
|
|
|
### With Crews
|
|
|
|
Pass files when kicking off a crew:
|
|
|
|
```python
|
|
from crewai import Crew
|
|
from crewai_files import ImageFile
|
|
|
|
crew = Crew(agents=[analyst], tasks=[analysis_task])
|
|
|
|
result = crew.kickoff(
|
|
inputs={"topic": "Q4 Sales"},
|
|
input_files={
|
|
"chart": ImageFile(source="sales_chart.png"),
|
|
"report": PDFFile(source="quarterly_report.pdf"),
|
|
}
|
|
)
|
|
```
|
|
|
|
### With Tasks
|
|
|
|
Attach files to specific tasks:
|
|
|
|
```python
|
|
from crewai import Task
|
|
from crewai_files import ImageFile
|
|
|
|
task = Task(
|
|
description="Analyze the sales chart and identify trends in {chart}",
|
|
expected_output="A summary of key trends",
|
|
input_files={
|
|
"chart": ImageFile(source="sales_chart.png"),
|
|
}
|
|
)
|
|
```
|
|
|
|
### With Flows
|
|
|
|
Pass files to flows, which automatically inherit to crews:
|
|
|
|
```python
|
|
from crewai.flow.flow import Flow, start
|
|
from crewai_files import ImageFile
|
|
|
|
class AnalysisFlow(Flow):
|
|
@start()
|
|
def analyze(self):
|
|
return self.analysis_crew.kickoff()
|
|
|
|
flow = AnalysisFlow()
|
|
result = flow.kickoff(
|
|
input_files={"image": ImageFile(source="data.png")}
|
|
)
|
|
```
|
|
|
|
### With Standalone Agents
|
|
|
|
Pass files directly to agent kickoff:
|
|
|
|
```python
|
|
from crewai import Agent
|
|
from crewai_files import ImageFile
|
|
|
|
agent = Agent(
|
|
role="Image Analyst",
|
|
goal="Analyze images",
|
|
backstory="Expert at visual analysis",
|
|
llm="gpt-4o",
|
|
)
|
|
|
|
result = agent.kickoff(
|
|
messages="What's in this image?",
|
|
input_files={"photo": ImageFile(source="photo.jpg")},
|
|
)
|
|
```
|
|
|
|
## File Precedence
|
|
|
|
When files are passed at multiple levels, more specific levels override broader ones:
|
|
|
|
```
|
|
Flow input_files < Crew input_files < Task input_files
|
|
```
|
|
|
|
For example, if both Flow and Task define a file named `"chart"`, the Task's version is used.
|
|
|
|
## Provider Support
|
|
|
|
Different providers support different file types. CrewAI automatically formats files for each provider's API.
|
|
|
|
| Provider | Image | PDF | Audio | Video | Text |
|
|
|:---------|:-----:|:---:|:-----:|:-----:|:----:|
|
|
| **OpenAI** (completions API) | ✓ | | | | |
|
|
| **OpenAI** (responses API) | ✓ | ✓ | ✓ | | |
|
|
| **Anthropic** (claude-3.x) | ✓ | ✓ | | | |
|
|
| **Google Gemini** (gemini-1.5, 2.0, 2.5) | ✓ | ✓ | ✓ | ✓ | ✓ |
|
|
| **AWS Bedrock** (claude-3) | ✓ | ✓ | | | |
|
|
| **Azure OpenAI** (gpt-4o) | ✓ | | ✓ | | |
|
|
|
|
<Note type="info" title="Gemini for Maximum File Support">
|
|
Google Gemini models support all file types including video (up to 1 hour, 2GB). Use Gemini when you need to process video content.
|
|
</Note>
|
|
|
|
<Note type="warning" title="Unsupported File Types">
|
|
If you pass a file type that the provider doesn't support (e.g., video to OpenAI), you'll receive an `UnsupportedFileTypeError`. Choose your provider based on the file types you need to process.
|
|
</Note>
|
|
|
|
## How Files Are Sent
|
|
|
|
CrewAI automatically chooses the optimal method to send files to each provider:
|
|
|
|
| Method | Description | Used When |
|
|
|:-------|:------------|:----------|
|
|
| **Inline Base64** | File embedded directly in the request | Small files (< 5MB typically) |
|
|
| **File Upload API** | File uploaded separately, referenced by ID | Large files that exceed threshold |
|
|
| **URL Reference** | Direct URL passed to the model | File source is already a URL |
|
|
|
|
### Provider Transmission Methods
|
|
|
|
| Provider | Inline Base64 | File Upload API | URL References |
|
|
|:---------|:-------------:|:---------------:|:--------------:|
|
|
| **OpenAI** | ✓ | ✓ (> 5 MB) | ✓ |
|
|
| **Anthropic** | ✓ | ✓ (> 5 MB) | ✓ |
|
|
| **Google Gemini** | ✓ | ✓ (> 20 MB) | ✓ |
|
|
| **AWS Bedrock** | ✓ | | ✓ (S3 URIs) |
|
|
| **Azure OpenAI** | ✓ | | ✓ |
|
|
|
|
<Note type="info" title="Automatic Optimization">
|
|
You don't need to manage this yourself. CrewAI automatically uses the most efficient method based on file size and provider capabilities. Providers without file upload APIs use inline base64 for all files.
|
|
</Note>
|
|
|
|
## File Handling Modes
|
|
|
|
Control how files are processed when they exceed provider limits:
|
|
|
|
```python
|
|
from crewai_files import ImageFile, PDFFile
|
|
|
|
image = ImageFile(source="large.png", mode="strict")
|
|
image = ImageFile(source="large.png", mode="auto")
|
|
image = ImageFile(source="large.png", mode="warn")
|
|
pdf = PDFFile(source="large.pdf", mode="chunk")
|
|
```
|
|
|
|
## Provider Constraints
|
|
|
|
Each provider has specific limits for file sizes and dimensions:
|
|
|
|
### OpenAI
|
|
- **Images**: Max 20 MB, up to 10 images per request
|
|
- **PDFs**: Max 32 MB, up to 100 pages
|
|
- **Audio**: Max 25 MB, up to 25 minutes
|
|
|
|
### Anthropic
|
|
- **Images**: Max 5 MB, max 8000x8000 pixels, up to 100 images
|
|
- **PDFs**: Max 32 MB, up to 100 pages
|
|
|
|
### Google Gemini
|
|
- **Images**: Max 100 MB
|
|
- **PDFs**: Max 50 MB
|
|
- **Audio**: Max 100 MB, up to 9.5 hours
|
|
- **Video**: Max 2 GB, up to 1 hour
|
|
|
|
### AWS Bedrock
|
|
- **Images**: Max 4.5 MB, max 8000x8000 pixels
|
|
- **PDFs**: Max 3.75 MB, up to 100 pages
|
|
|
|
## Referencing Files in Prompts
|
|
|
|
Use the file's key name in your task descriptions to reference files:
|
|
|
|
```python
|
|
task = Task(
|
|
description="""
|
|
Analyze the provided materials:
|
|
1. Review the chart in {sales_chart}
|
|
2. Cross-reference with data in {quarterly_report}
|
|
3. Summarize key findings
|
|
""",
|
|
expected_output="Analysis summary with key insights",
|
|
input_files={
|
|
"sales_chart": ImageFile(source="chart.png"),
|
|
"quarterly_report": PDFFile(source="report.pdf"),
|
|
}
|
|
)
|
|
```
|