alexacuff's picture
Update app.py
e25b2b4
Raw History Blame Contribute Delete
2 kB
import openai
import gradio
import os
openai.api_key = os.environ["OPENAI_API_KEY"]
initial_messages = [{
"role": "system",
"content": """You are a Home Staging Assistant designed for homeowners, and investors of both long-term and short-term rentals. Based on the home's description and location, provide tailored recommendations for staging. This includes suggesting styles of furniture, fixtures, floor coverings, and colors for each room to enhance the appeal and functionality of the space."""
}]
def call_openai_api(messages):
return openai.ChatCompletion.create(
model="gpt-3.5-turbo",
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.copy()
user_input = f"I own a property described as: {home_details}. It's situated in {location}. What are your staging recommendations considering furniture style, fixtures, floor coverings, and colors for each room?"
reply, updated_messages = CustomChatGPT(user_input, messages)
return reply
demo = gradio.Interface(
fn=wrapped_chat_gpt,
inputs=[
gradio.inputs.Textbox(label="Home Details", placeholder="Describe the home: e.g., 3-bedroom contemporary apartment with a balcony."),
gradio.inputs.Textbox(label="Location", placeholder="Enter the location or neighborhood: e.g., Brooklyn's DUMBO area."),
],
outputs="text",
title="StagifyAI - Your Personal Home Staging Assistant",
description="An AI-driven assistant for homeowners and rental investors. Get recommendations on furniture style, fixtures, floor coverings, and colors for staging each room of your property."
)
demo.launch(inline=False)