Spaces:
Runtime error
Runtime error
bizvideoschool
commited on
Commit
•
e2c5f07
1
Parent(s):
b6958a4
Update app.py
Browse files
app.py
CHANGED
@@ -4,61 +4,52 @@ import openai
|
|
4 |
# Access the OpenAI API key from Hugging Face Spaces secrets
|
5 |
openai.api_key = st.secrets["OPENAI_API_KEY"]
|
6 |
|
7 |
-
st.title("
|
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("Initial Video Ideas")
|
15 |
-
initial_ideas = st.text_area("Initial Video Ideas", placeholder="Any initial ideas or themes you have in mind for the
|
16 |
|
17 |
-
if st.button('Generate Video
|
18 |
# Detailed prompt for AI including the steps
|
19 |
ai_instructions = """
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
Include a strong call to action that invites the viewer to contact the small business owner to take the next step. If the user requests a specific call to action use that instead.
|
30 |
-
3. Once you have determined a hook and script. Reply to the user with the full script first, followed by any additional tips or sugggestions for the video. The script
|
31 |
-
must be only the words the user will read. It should be formatted without any shot instructions or references to who is speaking. The user should be able to copy the script
|
32 |
-
and paste it into a teleprmopter to read without any editing. Below the script you can then provide any additional notes.
|
33 |
-
|
34 |
-
Complete these steps first. Then only reply to the user with the script and suggestions. Do not reply with any of your internal decision making.
|
35 |
-
|
36 |
"""
|
37 |
|
38 |
# Construct the prompt for the AI
|
39 |
-
prompt_text = f""
|
40 |
-
{ai_instructions}
|
41 |
-
Business description: {business_description}.
|
42 |
-
Target audience: {target_audience}.
|
43 |
-
Initial video ideas: {initial_ideas}.
|
44 |
-
"""
|
45 |
|
46 |
# Call the OpenAI API for text generation
|
47 |
try:
|
48 |
response_text = openai.ChatCompletion.create(
|
49 |
model="gpt-4",
|
50 |
messages=[
|
51 |
-
{"role": "system", "content":
|
52 |
{"role": "user", "content": prompt_text}
|
53 |
]
|
54 |
)
|
55 |
-
|
56 |
except Exception as e:
|
57 |
-
|
58 |
|
59 |
-
# Display the video
|
60 |
-
st.markdown("### Your
|
61 |
-
st.write(
|
62 |
|
63 |
# Disclaimer
|
64 |
-
st.write("Disclaimer: This
|
|
|
4 |
# Access the OpenAI API key from Hugging Face Spaces secrets
|
5 |
openai.api_key = st.secrets["OPENAI_API_KEY"]
|
6 |
|
7 |
+
st.title("Small Business Video Scripter")
|
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 ideas or themes you have in mind for the video?")
|
19 |
|
20 |
+
if st.button('Generate Video Script'):
|
21 |
# Detailed prompt for AI including the steps
|
22 |
ai_instructions = """
|
23 |
+
As an AI consultant, create a video script suitable for the specified platform and format, focusing on engaging content that resonates with the business's target audience.
|
24 |
+
|
25 |
+
Steps:
|
26 |
+
1. Review the business description, target audience, and initial video ideas to brainstorm 20 potential video concepts with compelling hooks.
|
27 |
+
2. Select the best concept and develop a script. The script should be under 200 words, aligning with effective short-form video formats.
|
28 |
+
3. Include a strong call to action relevant to the small business.
|
29 |
+
4. Provide the script first, followed by additional filming and editing tips suitable for the chosen platform.
|
30 |
+
|
31 |
+
The script should be teleprompter-ready, free of shot directions or speaker references.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 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.")
|