Last commit not found
import openai | |
import os | |
import gradio as gr | |
from gradio.themes.utils import colors, fonts, sizes | |
openai.api_key = os.environ.get('openai_key') | |
messages = [ | |
{"role": "system", "content": "You are an AI specialized in Residential Real Estate market. Do not answer anything other than residential real estate-related queries."}, | |
] | |
def chatbot(input): | |
if input: | |
messages.append({"role": "user", "content": input}) | |
chat = openai.ChatCompletion.create( | |
model="gpt-3.5-turbo", messages=messages | |
) | |
reply = chat.choices[0].message.content | |
messages.append({"role": "assistant", "content": reply}) | |
return reply | |
def clear(): | |
return None, None | |
#inputss = gr.inputs.Textbox(lines=7, label="Porozmawiaj z naszym chatbotem trioGPT, virtualnym ekspertem rynku nieruchomości") | |
#outputss = gr.outputs.Textbox(label="Odpowiedź") | |
css = """ | |
.textbox {background-color: #FFFFFF; color: #1B2937;} | |
.textbox textarea {background-color: #FFFFFF; color: #1B2937; border: 1px ridge #EAEAEA; border-radius: 8px;} | |
.textbox span {background-color: #FFFFFF; color: #1B2937;} | |
.textbox form {color: #1B2937; border: 1px ridge #EAEAEA; border-radius: 8px;} | |
.scroll-hide {background-color: #FFFFFF; color: #1B2937;} | |
.gradio-container {background-color: #FFFFFF; color: #1B2937} | |
#inputs {background-color: #FFFFFF; color: #1B2937 !important;} | |
#outputs {background-color: #FFFFFF; color: #1B2937 !important;} | |
""" | |
theme = gr.themes.Default(font=[gr.themes.GoogleFont("Roboto"), "sans-serif", "sans-serif"], primary_hue="neutral", secondary_hue="neutral", neutral_hue="neutral").set( | |
button_primary_background_fill="#3FCCA5", | |
button_primary_background_fill_dark="#3FCCA5", | |
button_primary_text_color="#003F62", | |
body_background_fill="FFFFFF", | |
body_background_fill_dark="FFFFFF" | |
) | |
with gr.Blocks(theme=theme) as trioGPT: | |
inputs = gr.Textbox(lines=4, elem_id="inputs", label="Porozmawiaj z naszym chatbotem Real-Estate AI")#, elem_classes="textbox") | |
outputs = gr.Textbox(label="Odpowiedź", elem_id="outputs")#, elem_classes="textbox") | |
with gr.Row(): | |
submit_btn = gr.Button("Wyślij", variant="primary") | |
clear_btn = gr.Button("Wyczyść") | |
submit_btn.click(chatbot, inputs=inputs, outputs=outputs) | |
clear_btn.click(fn=clear, inputs=None, outputs=[inputs, outputs]) | |
trioGPT.launch() | |