Spaces:
Runtime error
Runtime error
import streamlit as st | |
import openai | |
# Access the OpenAI API key from Hugging Face Spaces secrets | |
openai.api_key = st.secrets["OPENAI_API_KEY"] | |
st.title("Valentine's Day Video Scripter for Small Businesses") | |
# User inputs | |
st.subheader("About Your Business") | |
business_description = st.text_area("Describe Your Business", placeholder="What does your business do? What are its unique features?") | |
target_audience = st.text_area("Target Audience", placeholder="Describe the kinds of people you want to attract (e.g., demographics, interests)") | |
st.subheader("Video Type and Platform") | |
video_type = st.text_input("Video Type/Platform", placeholder="E.g., TikTok, Instagram Reels, YouTube") | |
st.subheader("Initial Video Ideas") | |
initial_ideas = st.text_area("Initial Video Ideas", placeholder="Any initial Valentine's Day themes or ideas you have in mind for the video?") | |
if st.button('Generate Video Script'): | |
# Detailed prompt for AI focusing on Valentine's Day | |
ai_instructions = """ | |
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. | |
Steps: | |
1. Review the business description, target audience, and initial video ideas, then brainstorm 20 potential video concepts with compelling Valentine's Day themed hooks. | |
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 | |
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. | |
3. Include a strong and relevant call to action for Valentine's Day, encouraging viewers to engage with the business. | |
4. Provide the script first, followed by additional filming and editing tips suitable for the chosen platform, emphasizing Valentine's Day aesthetics. | |
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. | |
""" | |
# Construct the prompt for the AI | |
prompt_text = f"{ai_instructions}\nBusiness description: {business_description}. Target audience: {target_audience}. Video type/platform: {video_type}. Initial video ideas: {initial_ideas}." | |
# Call the OpenAI API for text generation | |
try: | |
response_text = openai.ChatCompletion.create( | |
model="gpt-4", | |
messages=[ | |
{"role": "system", "content": ai_instructions}, | |
{"role": "user", "content": prompt_text} | |
] | |
) | |
script = response_text.choices[0].message['content'] | |
except Exception as e: | |
script = f"Error in generating video script: {e}" | |
# Display the video script | |
st.markdown("### Your Valentine's Day Video Script") | |
st.write(script) | |
# Disclaimer | |
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.") | |