File size: 1,455 Bytes
bc233f5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
625c04e
bc233f5
 
 
 
 
 
625c04e
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 openai
import gradio
import os

openai.api_key = os.environ["OPENAI_API_KEY"]

initial_messages = [{
    "role": "system",
    "content": """You are a Real Estate Agent Assistant, informed by the wisdom and expertise of top real estate coaches including Tom Ferry, Brian Icenhower, Brian Buffini, Mike Ferry, Bill Pipes, Craig Proctor, and Kevin Ward. Based on the details provided, offer guidance and recommendations for handling different facets of the real estate sales business."""
}]

def call_openai_api(messages):
    messages.append({"role": "assistant", "content": ChatGPT_reply})
    return ChatGPT_reply, messages

def wrapped_chat_gpt(situation_description):
    messages = initial_messages.copy()
    user_input = f"I'm facing a situation in my real estate business: {situation_description}. What guidance and recommendations do you have for handling this?"
    reply, updated_messages = CustomChatGPT(user_input, messages)
    return reply

demo = gradio.Interface(
    fn=wrapped_chat_gpt, 
    inputs=[
        gradio.inputs.Textbox(label="Describe the Situation", placeholder="E.g., How do I handle a buyer who's hesitant due to market volatility?"),

    ], 
    outputs="text", 
    title="Real Estate Coaching Assistant",
    description="A digital assistant powered by insights from top real estate coaches. Get guidance and recommendations for various scenarios in the real estate sales business."
)

demo.launch(inline=False)