File size: 1,999 Bytes
bdda117
 
 
 
 
 
983300a
 
19f4495
983300a
bdda117
 
 
 
 
 
 
 
 
 
 
 
 
 
21fea59
bdda117
19f4495
bdda117
 
 
 
 
 
19f4495
 
bdda117
 
e25b2b4
19f4495
bdda117
 
 
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
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)