• unwind ai
  • Posts
  • Build an AI Movie Production Agent with Claude 3.5 Sonnet

Build an AI Movie Production Agent with Claude 3.5 Sonnet

Fully-functional LLM app in just 30 lines of Python Code (step-by-step instructions)

AI tools are redefining creative fields, and movie production is no exception. Imagine a tool that brings your movie ideas to life by generating script outlines, casting suggestions, and complete concept summaries. That’s what we’ll build today using Claude 3.5 Sonnet, Phidata, and SerpAPI.

This tutorial will guide you through creating an AI-powered movie agent capable of generating film concepts in a Streamlit app with just 30 lines of code.

🎁 $50 worth AI Bonus Content at the end!

What We’re Building

This Streamlit app is an AI-powered movie production assistant that helps bring your movie ideas to life using Claude 3.5 Sonnet model. It automates the process of script writing and casting, allowing you to create compelling movie concepts with ease.

Features

  • Generates script outlines based on your movie idea, genre, and target audience

  • Suggests suitable actors for main roles, considering their past performances and current availability

  • Provides a concise movie concept overview

Prerequisites

Before we begin, make sure you have:

  1. Python installed on your machine (version 3.7 or higher is recommended)

  2. Your Anthropic API Key and SerpAPI Key

  3. Basic familiarity with Python programming

  4. A code editor of your choice (we recommend VS Code or PyCharm for their excellent Python support)

Step-by-Step Instructions

Setting Up the Environment

First, let's get our development environment ready:

  1. Clone the GitHub repository:

git clone https://github.com/Shubhamsaboo/awesome-llm-apps.git
  1. Go to the ai_movie_production_agent folder:

cd ai_movie_production_agent
pip install -r requirements.txt
  1. Get your API Keys: Sign up for Anthropic and SerpAPI account to obtain your API key.

Creating the Streamlit App

Let’s create our app. Create a new file movie_production_agent.py and add the following code:

  1. Import necessary libraries:

    • Streamlit for building the web app
    • phi for building AI agents and tools
    • Anthropic for using Claude 3.5 Sonnet
    • SerpAPI for web search functionality

import streamlit as st
from phi.assistant import Assistant
from phi.tools.serpapi_tools import SerpApiTools
from phi.llm.anthropic import Claude
from textwrap import dedent
  1. Set up the Streamlit App:
    Set up the Streamlit App
    • Add a title to the app using 'st.title()'
    • Add a description for the app using 'st.caption()'

st.title("AI Movie Production Agent 🎬")
st.caption("Bring your movie ideas to life with the teams of script writing and casting AI agents")
  1. Create and Initialize the AI Assistants:

    Create instances of Assistants:
    • ScriptWriter: Develops script outline with character descriptions
    • CastingDirector: Suggests suitable actors for the main roles
    • MovieProducer: Oversees the entire process

anthropic_api_key = st.text_input("Enter Anthropic API Key to access Claude Sonnet 3.5", type="password")
# Get SerpAPI key from the user
serp_api_key = st.text_input("Enter Serp API Key for Search functionality", type="password")

if anthropic_api_key and serp_api_key:
    script_writer = Assistant(.....)

    casting_director = Assistant(....)

    movie_producer = Assistant(.....)
  1. Generate and Display the Result: 
    • Get the input from the user about movie idea, genre, target audience and estimated runtime.
    • Based on that, run the movie producer AI assistant to generate the movie overview with script outline and cast

    movie_idea = st.text_area("Describe your movie idea in a few sentences:")
    genre = st.selectbox("Select the movie genre:", 
                         ["Action", "Comedy", "Drama", "Sci-Fi", "Horror", "Romance", "Thriller"])
    target_audience = st.selectbox("Select the target audience:", 
                                   ["General", "Children", "Teenagers", "Adults", "Mature"])
    estimated_runtime = st.slider("Estimated runtime (in minutes):", 60, 180, 120)

    # Process the movie concept
    if st.button("Develop Movie Concept"):
        with st.spinner("Developing movie concept..."):
            input_text = (
                f"Movie idea: {movie_idea}, Genre: {genre}, "
                f"Target audience: {target_audience}, Estimated runtime: {estimated_runtime} minutes"
            )
            # Get the response from the assistant
            response = movie_producer.run(input_text, stream=False)
            st.write(response)

How the Code Works

The AI Movie Production Agent utilizes three main components:

  • Script Writer: Develops a compelling script outline with character descriptions and key plot points based on the given movie idea and genre.

  • Casting Director: Suggests suitable actors for the main roles, considering their past performances and current availability.

  • Movie Producer: Oversees the entire process, coordinating between the ScriptWriter and CastingDirector, and providing a concise movie concept overview

Running the App

With our code in place, it's time to launch the app.

  • In your terminal, navigate to the project folder, and run the following command

streamlit run movie_production_agent.py
  • Streamlit will provide a local URL (typically http://localhost:8501). Open this in your web browser, put in your API keys, describe your movie idea, set other parameters, and watch your AI agent generate the script outline, actor suggestions, and more!

Working Application Demo

Conclusion

And there you have it! An AI agent that generates a movie concept in minutes, complete with cast and plot outline.

To expand the app, consider:

  • Storyboarding: Create visual storyboards to help illustrate key scenes and transitions.

  • Budget Estimation: Add a feature to estimate production costs and track spending.

  • International Casting: Broaden casting options by including actors from different regions and languages.

Keep experimenting and refining to build even smarter AI solutions!

We share hands-on tutorials like this 2-3 times a week, to help you stay ahead in the world of AI. If you're serious about levelling up your AI skills and staying ahead of the curve, subscribe now and be the first to access our latest tutorials.

Bonus worth $50 💵💰

Share this newsletter on your social channels and tag Unwind AI (X, LinkedIn, Threads, Facebook) to get AI resource pack worth $50 for FREE. Valid for limited time only!

Reply

or to participate.