Siddartha10 commited on
Commit
c117701
1 Parent(s): 14e6408
Files changed (2) hide show
  1. app.py +87 -0
  2. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import streamlit as st
3
+ from langchain.prompts import PromptTemplate
4
+ from dotenv import load_dotenv
5
+ import google.generativeai as genai
6
+ from langchain_google_genai import ChatGoogleGenerativeAI
7
+ from langchain.prompts import PromptTemplate
8
+ # Load environment variables from .env file
9
+ load_dotenv()
10
+ genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
11
+ model_gemini = ChatGoogleGenerativeAI(model="gemini-pro")
12
+
13
+
14
+ def model(genre,no_of_characters,location,characters_prompt,hook_prompt,climax_prompt):
15
+ # here we are creating a template for the prompt
16
+ main_c = """
17
+ Crafting a compelling short film necessitates a concise and straightforward premise, a key ingredient for success when storytelling within the constraints of a limited timeframe. The best short films often feature a main character with a specific goal or a tight deadline, such as two friends embarking on a bike ride, a woman seeking new friendship, or a grieving son delivering a eulogy. With time being a precious commodity, short films cannot afford to delve extensively into character backstories. Instead, filmmakers must discern the essential information required to engage the audience in the hero's journey.
18
+ Details like an ex-husband may prove extraneous and dilute the impact of the narrative.Moreover, judiciously selecting the number of characters is pivotal.
19
+ Each character, whether a protagonist, supporting role, or minor part, should serve a purpose directly tied to the central goal.
20
+ If a character's exclusion doesn't impede the main character's progression,
21
+ it might be prudent to omit them. Many successful short films unfold within a singular location, not only to streamline the story but also to mitigate budgetary constraints,
22
+ particularly for independent filmmakers. "Sam Did It," a renowned 10-minute short set entirely in a morgue operating room, exemplifies how a confined space can intensify the storytelling experience.
23
+ A useful exercise during brainstorming involves formulating a premise and identifying a single location, prompting creators to contemplate whether the entire narrative can unfold within those confines.
24
+ This approach not only sharpens the focus but also aligns with budget considerations for those contemplating a self-produced project.
25
+
26
+ """
27
+
28
+ template = main_c +"""
29
+ write a short film story in {genre} genre with {no_of_characters} characters in {location} location
30
+ Consider being economical with characters and backstory There are {characters_prompt} characters and their behaviours. This is the hook {hook_prompt}
31
+ and this is the climax {climax_prompt}
32
+ """
33
+
34
+ # here we are creating a prompt using the template and the input variables
35
+ prompt = PromptTemplate(input_variables=["genre","no_of_characters","location","characters_prompt","hook_prompt","climax_prompt"],template=template)
36
+
37
+ # here we are generating the blog
38
+ response = model_gemini.invoke(prompt.format(genre=genre,no_of_characters=no_of_characters,location=location,characters_prompt=characters_prompt,hook_prompt=hook_prompt,climax_prompt=climax_prompt))
39
+ print(response)
40
+ return response.content
41
+
42
+ def short_film_story_generator(genre):
43
+ st.title("Short Film Story Generator")
44
+
45
+ # Prompt for being economical with characters and backstory
46
+ no_of_characters = st.text_input("How many character do you want? (leave empty for default of 4 characters):")
47
+ if not no_of_characters:
48
+ # Default characters if the user leaves it empty
49
+ no_of_characters = "The story follows four characters who..."
50
+ # Prompt for minimal locations
51
+ location = st.text_input("Think about keeping the locations to a minimum. Specify a key location for your short film (leave empty for random location):")
52
+ if not location:
53
+ # Default location if the user leaves it empty
54
+ location = "You can use any location you want"
55
+
56
+ # Prompt for interesting characters
57
+ characters_prompt = st.text_input("Describe interesting traits or quirks of the main characters:")
58
+ if not characters_prompt:
59
+ characters_prompt = "You can use any interesting traits or quirks you want"
60
+
61
+ # Prompt for the hook
62
+ hook_prompt = st.text_input("Create a hook for your short film:")
63
+ if not hook_prompt:
64
+ # Default hook if the user leaves it empty
65
+ hook_prompt = "You can use any hook you want"
66
+
67
+
68
+ # Prompt for the climax
69
+ climax_prompt = st.text_input("Develop a great climax for your short film:")
70
+ if not climax_prompt:
71
+ climax_prompt = "You can use climax you want but should match with the genre"
72
+
73
+
74
+ if st.button("Generate Story"):
75
+ response = model(genre,no_of_characters,location,characters_prompt,hook_prompt,climax_prompt)
76
+
77
+ # Extract the AI's response and display it
78
+ ai_response = response
79
+ st.write(f"{ai_response}")
80
+
81
+ if __name__ == "__main__":
82
+ genres = ["Sci-Fi", "Drama", "Comedy", "Thriller", "Mystery", "Fantasy", "Horror", "Romance", "Action", "Adventure"]
83
+
84
+ # Create a dropdown menu for genres
85
+ user_genre = st.sidebar.selectbox("Select the genre:", genres, index=genres.index("Sci-Fi"))
86
+
87
+ short_film_story_generator(user_genre)
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ google-generativeai
2
+ streamlit
3
+ python-dotenv
4
+ langchain