中文 | English
An AI-powered screenwriting assistant that helps you create scripts, storyboards, and shot lists with natural language interaction.
OpenFilm is an intelligent agent built on LangChain/LangGraph that specializes in film and video production workflows. It can write scripts, generate storyboards, create shot lists, and manage project files through conversational interactions.
- Script Writing: Generate screenplays and scripts in Markdown format
- Storyboard Generation: Create detailed storyboard documents from scripts
- Visual Storyboarding: Generate SVG shot visualization diagrams
- File System Management: Secure file operations with automatic backup to recycle bin
- Web Integration: Search and open websites directly from conversations
- Voice Feedback: Text-to-speech output for AI responses
- Persistent Context: SQLite-based conversation checkpointing
- Human-in-the-Loop: Interactive confirmation for creative decisions
OpenFilm/
├── main.py # Application entry point and agent setup
├── common.py # Combined imports and workspace initialization
├── common_early_import.py # System libraries and rich console setup
├── common_const.py # Constants, prompts, and LLM configuration
├── common_lazy_import.py # Third-party and LangChain imports
├── tool_module.py # Custom tool definitions
├── tts.py # Text-to-speech module
├── workspace/ # User data directory (gitignored)
├── .openfilm/ # Config and checkpoint database (hidden)
└── misc/ # Miscellaneous files
- Python 3.12
- LangChain and LangGraph
- OpenAI-compatible API endpoint (configurable)
- Windows (for
os.startfileandctypesfeatures)
Key dependencies include:
langchain,langchain-openai,langgraphrich- Console output formattingpyttsx3- Text-to-speechsend2trash- Safe file deletionbeautifulsoup4,requests- Web scrapingemoji- Emoji handling for TTS
- Clone the repository:
git clone <repository-url>
cd OpenFilm- Install dependencies:
pip install langchain langchain-openai langgraph rich pyttsx3 send2trash beautifulsoup4 requests emoji tenacity pydantic- Configure the LLM endpoint in
common_const.py:
LLM_BASE_URL = "http://your-llm-endpoint/v1"
LLM_API_KEY = "your-api-key"
LLM_MODEL = "your-model-name"Run the application:
python main.pyThe agent will start and display a colorful ASCII logo. You can then interact with it using natural language commands such as:
- "Write a 5-minute comedy script and save it as script.md"
- "Create a storyboard based on the script.md file"
- "Generate a shot diagram and save it as storyboard.svg"
- "List all files"
- "Open example.com"
OpenFilm uses a layered import approach:
- common_early_import.py - System libraries,
richconsole setup - common_const.py - Configuration constants and prompts
- common_lazy_import.py - LangChain and third-party libraries
- common.py - Combines all imports and initializes workspace
The agent uses several middleware components:
- Tool Error Handler - Catches and formats tool execution errors
- Summarization Middleware - Compresses conversation context when reaching token limits
- Filesystem Middleware - Virtual filesystem operations with security checks
- Call Limiters - Prevents runaway model/tool calls (10 each)
- Todo List Middleware - Manages task lists
- All file operations are restricted to the
workspace/directory - Files are backed up to the recycle bin before modification
- Paths are normalized and validated before access
- Config directory (
.openfilm/) is protected from user operations
Edit common_const.py to customize:
- LLM Settings: Base URL, API key, model name, max tokens
- System Prompt: Agent personality and behavior rules
- Summary Prompt: Context compression instructions
OpenFilm implements several safety measures:
- Automatic backup to recycle bin before file writes
- Path validation to prevent directory traversal
- Hidden file/directory filtering in glob/grep results
- Mutex lock to prevent multiple instances on the same workspace
- Use wildcard imports:
from common import * - Function names:
snake_case - Private functions:
__double_underscore_prefix - Constants:
UPPER_SNAKE_CASE - User-facing messages: Chinese with emoji prefixes
- Define a function in
tool_module.py:
@tool
def my_tool(param: str) -> str:
"""Tool description in Chinese"""
# Implementation
return "Result message"- The tool auto-registers via
__list_all_tools()
[Your License Here]
Built with LangChain, LangGraph, and Rich.
