File size: 1,657 Bytes
bf70abc
0a480c8
c1fbddd
3e809b7
b348565
bf70abc
3e809b7
bf70abc
3e809b7
 
 
 
 
bf70abc
 
3e809b7
 
 
 
c1fbddd
3e809b7
 
 
 
 
 
 
 
 
 
 
 
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
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("Holiday Video Script Generator for Realtors")

# User inputs
agent_name = st.text_input("Your Name", placeholder="Enter your name")
community_focus = st.text_input("Community Focus", placeholder="Enter the community or area you focus on")
holiday_theme = st.selectbox("Holiday Theme", ["Christmas", "Hanukkah", "New Year's", "General Holiday Season"])
personal_message = st.text_area("Personal Message", placeholder="Enter any personal message or story you want to include")

if st.button('Generate Script'):
    # Formulate the user input for the script
    user_input = (
        f"""You are an AI assistant that helps real estate agents create compelling holiday video scripts. The script should be festive, engaging, and approximately one minute long. Include elements like community engagement, local highlights, market insights, home decoration tips, and a personalized message. The agent's name is {agent_name}. They focus on the {community_focus} community. The holiday theme is {holiday_theme}. They want to include the following personal message: {personal_message}.
        """
    )

    # Call the OpenAI API with the chat model
    response = openai.ChatCompletion.create(
        model="gpt-4",  # Use the appropriate GPT-4 model
        messages=[
            {"role": "system", "content": "You are a helpful assistant."},
            {"role": "user", "content": user_input}
        ]
    )

    # Display the response from the API
    st.write(response.choices[0].message['content'])