Real_Estate_Bot / app.py
exnav29's picture
Update app.py
5dadac1
Raw History Blame Contribute Delete
1.29 kB
import os
import openai
import gradio as gr
openai.api_key = os.environ["OPENAI_API_KEY"]
messages = [
{"role": "system", "content": "You are an AI specialized in Real Estate Investing Do not answer anything other than Real Estate-related queries"},
]
counter = 0
def chatbot(input):
global counter
if input:
messages.append({"role": "user", "content": input})
chat = openai.ChatCompletion.create(
model="gpt-3.5-turbo", messages=messages, temperature=0.2
)
reply = chat.choices[0].message.content
messages.append({"role": "assistant", "content": reply})
counter += 1
if counter >= 3:
gr.Interface.show_feedback_message("Thank you for using our chatbot! If you find our service helpful, please consider making a donation to support us: <a href='https://www.paypal.me/exnav29' target='_blank'>Donate Now</a>")
counter = 0
return reply
inputs = gr.inputs.Textbox(lines=7, label="Ask your question")
outputs = gr.outputs.Textbox(label="Reply")
app = gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs,
title="JChat Real Estate Investing Chatbot",
description="Ask anything you want about investing in real estate")
app.launch()