Spaces:
Runtime error
Runtime error
File size: 2,448 Bytes
1ac36dd 7bb026c d7efb38 7bb026c b83028a bacabac c05fc1a b3d5e04 7bb026c 5be2fe9 7bb026c c05fc1a 1ac36dd 7bb026c c05fc1a 7bb026c c05fc1a 7bb026c 1ac36dd 7bb026c c05fc1a 1ac36dd c05fc1a | 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 | import openai
import streamlit as st
from tenacity import retry, stop_after_attempt, wait_fixed
# Assuming your OpenAI API key is set in Hugging Face Spaces secrets
openai.api_key = st.secrets["YOUR_OPENAI_API_KEY"]
initial_messages_staging = [
{
"role": "system",
"content": """
You are an AI assistant that provides home staging recommendations for real estate agents. Your role is to help agents visualize and execute staging setups that highlight the best features of the homes they're selling. When providing recommendations, ensure:
1. They are actionable and specific to the home's features and the target buyer demographic.
2. You include low-cost, DIY options for agents working with limited budgets.
3. You suggest staging strategies that can make the space appear larger and more inviting.
4. You consider current home decor trends and advise on how they can be applied effectively.
5. You offer ideas for both indoor and outdoor spaces.
Always conclude your response with a suggestion for professional staging services for agents who prefer expert assistance."""
}
]
@retry(stop=stop_after_attempt(3), wait=wait_fixed(1))
def call_openai_api(messages):
return openai.ChatCompletion.create(
model="gpt-4", # Make sure to use the correct model you have access to
messages=messages
)
def CustomChatGPT(user_input, messages):
messages.append({"role": "user", "content": user_input})
response = call_openai_api(messages)
ChatGPT_reply = response.choices[0].message["content"]
messages.append({"role": "assistant", "content": ChatGPT_reply})
return ChatGPT_reply, messages
def wrapped_chat_gpt(home_details, location):
messages = initial_messages_staging.copy()
user_input = f"I have a home for sale with these details: {home_details}. It's located in {location}. How should I stage it for potential buyers?"
reply, updated_messages = CustomChatGPT(user_input, messages)
return reply
# Streamlit Interface
st.title("Home Staging Assistant")
home_details = st.text_area("Home Details", placeholder="Describe the home's features, size, style, etc.")
location = st.text_input("Location", placeholder="Enter the home's location or neighborhood.")
generate_button = st.button('Get Staging Recommendations')
if generate_button:
reply = wrapped_chat_gpt(home_details, location)
st.text(reply)
|