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("TikTok Video Planner for Real Estate Agents") | |
# 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 TikTok video strategies for real estate agents working from their home offices. Use your understanding of engaging short-form video content to generate a single, creative video idea that can be filmed in a home office setting. The video should be under 60 seconds, suitable for TikTok. Begin with a captivating hook, provide valuable and relatable content, and conclude with a clear call to action. The plan should include a brief outline of the video structure, suggestions for visuals using the home office backdrop, and a draft script for dialogue. | |
Steps: | |
1. Start with a strong hook that captures attention within the first few seconds. | |
2. Develop a body that delivers valuable insights or showcases the agent's expertise, using props or elements available in a home office. | |
3. Conclude with a compelling call to action. | |
4. Provide guidance on shooting techniques that can be employed in a home office setting, like using natural lighting and office aesthetics. | |
5. Write a script with a natural and engaging dialogue that resonates with the target audience. | |
""" | |
# 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.") | |