Spaces:
Runtime error
Runtime error
File size: 3,810 Bytes
bf70abc 0a480c8 c1fbddd a452991 a3215c8 bf70abc 004a832 f23c1ac a452991 c3fad62 b724b7a a452991 c3fad62 a452991 b724b7a d06f639 d1dedb2 c07d5d6 d06f639 b6958a4 d06f639 d7b42dd c07d5d6 b724b7a a452991 b724b7a 3cd9850 a452991 a3215c8 a452991 a3215c8 a452991 a3215c8 a452991 a3215c8 a452991 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
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.")
|