Skip to content
anders0821Public

About

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 con

Resources

Stars

2 stars

Watchers

1 watching

Forks

Repository files navigation

OpenFilm

中文 | English

An AI-powered screenwriting assistant that helps you create scripts, storyboards, and shot lists with natural language interaction.

OpenFilm Logo

Overview

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.

Features

  • 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

Project Structure

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

Requirements

  • Python 3.12
  • LangChain and LangGraph
  • OpenAI-compatible API endpoint (configurable)
  • Windows (for os.startfile and ctypes features)

Dependencies

Key dependencies include:

  • langchain, langchain-openai, langgraph
  • rich - Console output formatting
  • pyttsx3 - Text-to-speech
  • send2trash - Safe file deletion
  • beautifulsoup4, requests - Web scraping
  • emoji - Emoji handling for TTS

Installation

  1. Clone the repository:
git clone <repository-url>
cd OpenFilm
  1. Install dependencies:
pip install langchain langchain-openai langgraph rich pyttsx3 send2trash beautifulsoup4 requests emoji tenacity pydantic
  1. 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"

Usage

Run the application:

python main.py

The 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"

Architecture

Import System

OpenFilm uses a layered import approach:

  1. common_early_import.py - System libraries, rich console setup
  2. common_const.py - Configuration constants and prompts
  3. common_lazy_import.py - LangChain and third-party libraries
  4. common.py - Combines all imports and initializes workspace

Middleware Stack

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

Security

  • 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

Configuration

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

File Safety

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

Development

Code Style

  • 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

Adding New Tools

  1. Define a function in tool_module.py:
@tool
def my_tool(param: str) -> str:
    """Tool description in Chinese"""
    # Implementation
    return "Result message"
  1. The tool auto-registers via __list_all_tools()

License

[Your License Here]

Acknowledgments

Built with LangChain, LangGraph, and Rich.

About

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 con

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages