Commit
·
3e809b7
1
Parent(s):
b348565
Update app.py
Browse files
app.py
CHANGED
@@ -1,25 +1,32 @@
|
|
1 |
import streamlit as st
|
2 |
import openai
|
3 |
|
4 |
-
# OpenAI API
|
5 |
openai.api_key = st.secrets["OPENAI_API_KEY"]
|
6 |
|
7 |
-
st.title("Holiday Video Script Generator for
|
8 |
|
9 |
-
#
|
10 |
-
agent_name = st.text_input("Your Name")
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
personal_anecdotes = st.text_area("Personal Anecdotes/Success Stories")
|
15 |
-
local_features = st.text_area("Local Community Features")
|
16 |
-
market_statistics = st.text_area("Real Estate Market Statistics")
|
17 |
|
18 |
if st.button('Generate Script'):
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
max_tokens=500
|
24 |
)
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
import openai
|
3 |
|
4 |
+
# Access the OpenAI API key from Hugging Face Spaces secrets
|
5 |
openai.api_key = st.secrets["OPENAI_API_KEY"]
|
6 |
|
7 |
+
st.title("Holiday Video Script Generator for Realtors")
|
8 |
|
9 |
+
# User inputs
|
10 |
+
agent_name = st.text_input("Your Name", placeholder="Enter your name")
|
11 |
+
community_focus = st.text_input("Community Focus", placeholder="Enter the community or area you focus on")
|
12 |
+
holiday_theme = st.selectbox("Holiday Theme", ["Christmas", "Hanukkah", "New Year's", "General Holiday Season"])
|
13 |
+
personal_message = st.text_area("Personal Message", placeholder="Enter any personal message or story you want to include")
|
|
|
|
|
|
|
14 |
|
15 |
if st.button('Generate Script'):
|
16 |
+
# Formulate the user input for the script
|
17 |
+
user_input = (
|
18 |
+
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}.
|
19 |
+
"""
|
|
|
20 |
)
|
21 |
+
|
22 |
+
# Call the OpenAI API with the chat model
|
23 |
+
response = openai.ChatCompletion.create(
|
24 |
+
model="gpt-4", # Use the appropriate GPT-4 model
|
25 |
+
messages=[
|
26 |
+
{"role": "system", "content": "You are a helpful assistant."},
|
27 |
+
{"role": "user", "content": user_input}
|
28 |
+
]
|
29 |
+
)
|
30 |
+
|
31 |
+
# Display the response from the API
|
32 |
+
st.write(response.choices[0].message['content'])
|