CoolFace
Apppublic

exnav29/Real_Estate_Bot

sourceHugging Facecc-by-4.0updated 3y agoView on Hugging Face
2likes
app.py32 linesDownload Raw Back to root
1import os2import openai3import gradio as gr4 5openai.api_key = os.environ["OPENAI_API_KEY"]6 7messages = [8    {"role": "system", "content": "You are an AI specialized in Real Estate Investing Do not answer anything other than Real Estate-related queries"},9]10counter = 011def chatbot(input):12    global counter13    if input:14        messages.append({"role": "user", "content": input})15        chat = openai.ChatCompletion.create(16            model="gpt-3.5-turbo", messages=messages, temperature=0.217        )18        reply = chat.choices[0].message.content19        messages.append({"role": "assistant", "content": reply})20        counter += 121        if counter >= 3:22            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>")23            counter = 024        return reply25 26inputs = gr.inputs.Textbox(lines=7, label="Ask your question")27outputs = gr.outputs.Textbox(label="Reply")28 29app = gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, 30                   title="JChat Real Estate Investing Chatbot", 31                   description="Ask anything you want about investing in real estate")32app.launch()