Spaces:
Runtime error
Runtime error
Donation Screen Added
Browse files
app.py
CHANGED
|
@@ -8,15 +8,27 @@ messages = [
|
|
| 8 |
{"role": "system", "content": "You are an AI specialized in Real Estate Investing Do not answer anything other than Real Estate-related queries"},
|
| 9 |
]
|
| 10 |
|
|
|
|
| 11 |
def chatbot(input):
|
|
|
|
| 12 |
if input:
|
| 13 |
messages.append({"role": "user", "content": input})
|
| 14 |
-
chat = openai.
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
)
|
| 17 |
-
reply = chat.choices[0].
|
| 18 |
messages.append({"role": "assistant", "content": reply})
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
inputs = gr.inputs.Textbox(lines=7, label="Ask your question")
|
| 22 |
outputs = gr.outputs.Textbox(label="Reply")
|
|
|
|
| 8 |
{"role": "system", "content": "You are an AI specialized in Real Estate Investing Do not answer anything other than Real Estate-related queries"},
|
| 9 |
]
|
| 10 |
|
| 11 |
+
counter = 0
|
| 12 |
def chatbot(input):
|
| 13 |
+
global counter
|
| 14 |
if input:
|
| 15 |
messages.append({"role": "user", "content": input})
|
| 16 |
+
chat = openai.Completion.create(
|
| 17 |
+
engine="gpt-3.5-turbo",
|
| 18 |
+
prompt=messages,
|
| 19 |
+
temperature=0.2,
|
| 20 |
+
max_tokens=1024,
|
| 21 |
+
n=1,
|
| 22 |
+
stop=None,
|
| 23 |
+
timeout=None,
|
| 24 |
)
|
| 25 |
+
reply = chat.choices[0].text
|
| 26 |
messages.append({"role": "assistant", "content": reply})
|
| 27 |
+
counter += 1
|
| 28 |
+
if counter >= 3:
|
| 29 |
+
gr.Interface.show_feedback_message("Thank you for using me for your Real Estate questions! If you find me helpful, please consider making a donation to support my developer exnav29: <a href='https://www.paypal.me/exnav29' target='_blank'>Donate Now</a>")
|
| 30 |
+
counter = 0
|
| 31 |
+
return reply
|
| 32 |
|
| 33 |
inputs = gr.inputs.Textbox(lines=7, label="Ask your question")
|
| 34 |
outputs = gr.outputs.Textbox(label="Reply")
|