alexacuff commited on
Commit
bc233f5
·
verified ·
1 Parent(s): 42bff49

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -0
app.py CHANGED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import openai
2
+ import gradio
3
+ import os
4
+
5
+ openai.api_key = os.environ["OPENAI_API_KEY"]
6
+
7
+ initial_messages = [{
8
+ "role": "system",
9
+ "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."""
10
+ }]
11
+
12
+ def call_openai_api(messages):
13
+ return openai.ChatCompletion.create(
14
+ model="gpt-3.5-turbo",
15
+ messages=messages
16
+ )
17
+
18
+ def CustomChatGPT(user_input, messages):
19
+ messages.append({"role": "user", "content": user_input})
20
+ response = call_openai_api(messages)
21
+ ChatGPT_reply = response["choices"][0]["message"]["content"]
22
+ messages.append({"role": "assistant", "content": ChatGPT_reply})
23
+ return ChatGPT_reply, messages
24
+
25
+ def wrapped_chat_gpt(situation_description):
26
+ messages = initial_messages.copy()
27
+ 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?"
28
+ reply, updated_messages = CustomChatGPT(user_input, messages)
29
+ return reply
30
+
31
+ demo = gradio.Interface(
32
+ fn=wrapped_chat_gpt,
33
+ inputs=[
34
+ gradio.inputs.Textbox(label="Describe the Situation", placeholder="E.g., How do I handle a buyer who's hesitant due to market volatility?"),
35
+ ],
36
+ outputs="text",
37
+ title="Real Estate Coaching Assistant",
38
+ 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."
39
+ )
40
+
41
+ demo.launch(inline=False)