bizvideoschool commited on
Commit
bbd807d
1 Parent(s): 552b52c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -49
app.py CHANGED
@@ -1,55 +1,46 @@
1
  import streamlit as st
2
  import openai
 
3
 
4
- # Access the OpenAI API key from Hugging Face Spaces secrets
5
  openai.api_key = st.secrets["OPENAI_API_KEY"]
6
 
7
- st.title("Valentine's Day Video Scripter for Small Businesses")
8
-
9
- # User inputs
10
- st.subheader("About Your Business")
11
- business_description = st.text_area("Describe Your Business", placeholder="What does your business do? What are its unique features?")
12
- target_audience = st.text_area("Target Audience", placeholder="Describe the kinds of people you want to attract (e.g., demographics, interests)")
13
-
14
- st.subheader("Video Type and Platform")
15
- video_type = st.text_input("Video Type/Platform", placeholder="E.g., TikTok, Instagram Reels, YouTube")
16
-
17
- st.subheader("Initial Video Ideas")
18
- initial_ideas = st.text_area("Initial Video Ideas", placeholder="Any initial Valentine's Day themes or ideas you have in mind for the video?")
19
-
20
- if st.button('Generate Video Script'):
21
- # Detailed prompt for AI focusing on Valentine's Day
22
- ai_instructions = """
23
- Create a playful and engaging Valentine's Day themed video script for the specified platform, focusing on content that resonates with the target audience for Valentine's promotions. The script should creatively promote the business while incorporating Valentine's Day elements.
24
- Steps:
25
- 1. Review the business description, target audience, and initial video ideas, then brainstorm 20 potential video concepts with compelling Valentine's Day themed hooks.
26
- 2. Select the best concept that is playful and aligns with Valentine's Day. Develop a script under 200 words, suitable for short-form video formats. Consider 10 varied
27
- ideas for a compelling hook, the first sentence or two of the video. This should grab the viewer's attention and spark their curiosity to watch the rest of the video.
28
- 3. Include a strong and relevant call to action for Valentine's Day, encouraging viewers to engage with the business.
29
- 4. Provide the script first, followed by additional filming and editing tips suitable for the chosen platform, emphasizing Valentine's Day aesthetics.
30
-
31
- The script should be ready to use in a teleprompter, free of shot directions or speaker references, and tailored to Valentine's Day promotional activities.
32
- """
33
-
34
- # Construct the prompt for the AI
35
- prompt_text = f"{ai_instructions}\nBusiness description: {business_description}. Target audience: {target_audience}. Video type/platform: {video_type}. Initial video ideas: {initial_ideas}."
36
-
37
- # Call the OpenAI API for text generation
38
- try:
39
- response_text = openai.ChatCompletion.create(
40
- model="gpt-4",
41
- messages=[
42
- {"role": "system", "content": ai_instructions},
43
- {"role": "user", "content": prompt_text}
44
- ]
45
- )
46
- script = response_text.choices[0].message['content']
47
- except Exception as e:
48
- script = f"Error in generating video script: {e}"
49
-
50
- # Display the video script
51
- st.markdown("### Your Valentine's Day Video Script")
52
  st.write(script)
53
-
54
- # Disclaimer
55
- st.write("Disclaimer: This script is AI-generated. Please review and customize it to fit your specific business needs and video platform, especially for Valentine's Day.")
 
1
  import streamlit as st
2
  import openai
3
+ from tenacity import retry, wait_fixed, stop_after_attempt
4
 
5
+ # Assuming your OpenAI API key is stored in Streamlit's secrets or set as an environment variable
6
  openai.api_key = st.secrets["OPENAI_API_KEY"]
7
 
8
+ initial_messages = [{
9
+ "role": "system",
10
+ "content": """Act as a real estate marketing video script writer. You respond with
11
+ fully written video scripts that contain only the words that should be read out loud into the camera. A real estate agent should be
12
+ able to take the response you give and immediately read it word-for-word into a camera without editing it. The scripts you create do not include
13
+ shot directions, references to who is speaking, or any other extraneous notes that are not the actual words that should be read out oud.
14
+ As a real estate video marketing expert you have studied
15
+ the most effective marketing and social media videos made by real estate agents. You consider that it's better to be different than to
16
+ sound like everyone else when you write scripts. The scripts you write are succinct and compelling. They work well as short social media
17
+ videos shared by real estate agents. They always begin with engaging opening lines that tease what the rest of the video is about and they end
18
+ with a single strong call to action. If the script is a list the video starts with at least a single sentence explaining what that list
19
+ contains. They never start with the first item on the list.
20
+ They never include someone saying hi or introducing themselves. The final text you will receive after this sentence is a topic
21
+ you base your script on."""
22
+ }]
23
+
24
+ @retry(stop=stop_after_attempt(3), wait=wait_fixed(1))
25
+ def call_openai_api(messages):
26
+ return openai.ChatCompletion.create(
27
+ model="gpt-3.5-turbo",
28
+ messages=messages
29
+ )
30
+
31
+ def custom_chat_gpt(user_input):
32
+ messages = initial_messages.copy()
33
+ messages.append({"role": "user", "content": user_input})
34
+ response = call_openai_api(messages)
35
+ chat_gpt_reply = response.choices[0].message['content']
36
+ return chat_gpt_reply
37
+
38
+ st.title("Real Estate Video Script Writer")
39
+
40
+ user_input = st.text_area("Enter your video topic or theme:", placeholder="Enter a topic or theme for the video script")
41
+ generate_button = st.button('Generate Script')
42
+
43
+ if generate_button:
44
+ script = custom_chat_gpt(user_input)
45
+ st.markdown("### Generated Video Script")
 
 
 
 
 
 
 
46
  st.write(script)