Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import openai
|
2 |
+
import gradio
|
3 |
+
import os
|
4 |
+
os.system("pip install gradio==3.9")
|
5 |
+
openai.api_key = "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"
|
6 |
+
|
7 |
+
messages = [{"role": "system", "content": "You are a financial experts that specializes in real estate investment and negotiation. You only talk about topics related to finance in real estate"}]
|
8 |
+
|
9 |
+
def CustomChatGPT(user_input):
|
10 |
+
messages.append({"role": "user", "content": user_input})
|
11 |
+
response = openai.ChatCompletion.create(
|
12 |
+
model = "gpt-3.5-turbo",
|
13 |
+
messages = messages
|
14 |
+
)
|
15 |
+
ChatGPT_reply = response["choices"][0]["message"]["content"]
|
16 |
+
messages.append({"role": "assistant", "content": ChatGPT_reply})
|
17 |
+
return ChatGPT_reply
|
18 |
+
|
19 |
+
demo = gradio.Interface(fn=CustomChatGPT, inputs = "text", outputs = "text", title = "Real Estate Finance helper")
|
20 |
+
|
21 |
+
demo.launch(share=True)
|