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("Short-Form Video Planner") | |
# 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("Initial Video Ideas") | |
initial_ideas = st.text_area("Initial Video Ideas", placeholder="Any initial ideas or themes you have in mind for the TikTok video?") | |
if st.button('Generate Video Plan'): | |
# Detailed prompt for AI including the steps | |
ai_instructions = """ | |
You are an AI consultant skilled in crafting short-form (think TikTok or Reels) video scripts for small business owners working from their home offices. Your expertise lies in creating | |
engaging short-form video content that is perfect for the TikTok platform. Generate a single, creative video idea that can be filmed in a home office | |
setting, ensuring it is under 60 seconds and suitable for TikTok or Reels. Follow these steps as you create the script. Complete the steps first, then reply to the user. | |
1. Consider the idea and details provided by the user. Think of 20 potential ideas for the video and create a compelling hook for each idea. The hook is the first sentence | |
or two of the video. It should be in the form of a strong statement or question that summarizes what the video is about. You can recommend easy to find household items to | |
use a prop in the hook as well. | |
2. Choose the best idea and hook. Then write the body of the video. Review the most effective formats for short-form videos and structure the script based on those formats. | |
Keep the script under 200 words while also delivering a valuable experience for the viewer. The script should inform, educate, or entertain the viewer. | |
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. | |
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 | |
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 | |
and paste it into a teleprmopter to read without any editing. Below the script you can then provide any additional notes. | |
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. | |
""" | |
# Construct the prompt for the AI | |
prompt_text = f""" | |
{ai_instructions} | |
Business description: {business_description}. | |
Target audience: {target_audience}. | |
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": "You are an AI assistant specializing in social media content planning."}, | |
{"role": "user", "content": prompt_text} | |
] | |
) | |
video_plan = response_text.choices[0].message['content'] | |
except Exception as e: | |
video_plan = f"Error in generating video plan: {e}" | |
# Display the video plan | |
st.markdown("### Your TikTok Video Plan") | |
st.write(video_plan) | |
# Disclaimer | |
st.write("Disclaimer: This tool provides AI-generated suggestions. Final content should be tailored to your specific business needs.") | |