Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import openai
|
2 |
+
import gradio as gr
|
3 |
+
from gradio.themes.utils import colors, fonts, sizes
|
4 |
+
|
5 |
+
openai.api_key = "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"
|
6 |
+
|
7 |
+
messages = [
|
8 |
+
{"role": "system", "content": "You are an AI specialized in Residential Real Estate market. Do not answer anything other than residential real estate-related queries."},
|
9 |
+
]
|
10 |
+
|
11 |
+
def chatbot(input):
|
12 |
+
if input:
|
13 |
+
messages.append({"role": "user", "content": input})
|
14 |
+
chat = openai.ChatCompletion.create(
|
15 |
+
model="gpt-3.5-turbo", messages=messages
|
16 |
+
)
|
17 |
+
reply = chat.choices[0].message.content
|
18 |
+
messages.append({"role": "assistant", "content": reply})
|
19 |
+
return reply
|
20 |
+
|
21 |
+
def clear():
|
22 |
+
return None, None
|
23 |
+
|
24 |
+
#inputss = gr.inputs.Textbox(lines=7, label="Porozmawiaj z naszym chatbotem trioGPT, virtualnym ekspertem rynku nieruchomości")
|
25 |
+
#outputss = gr.outputs.Textbox(label="Odpowiedź")
|
26 |
+
|
27 |
+
css = """
|
28 |
+
.textbox {background-color: #FFFFFF; color: #1B2937;}
|
29 |
+
.textbox textarea {background-color: #FFFFFF; color: #1B2937; border: 1px ridge #EAEAEA; border-radius: 8px;}
|
30 |
+
.textbox span {background-color: #FFFFFF; color: #1B2937;}
|
31 |
+
.textbox form {color: #1B2937; border: 1px ridge #EAEAEA; border-radius: 8px;}
|
32 |
+
.scroll-hide {background-color: #FFFFFF; color: #1B2937;}
|
33 |
+
.gradio-container {background-color: #FFFFFF; color: #1B2937}
|
34 |
+
#inputs {background-color: #FFFFFF; color: #1B2937 !important;}
|
35 |
+
#outputs {background-color: #FFFFFF; color: #1B2937 !important;}
|
36 |
+
"""
|
37 |
+
|
38 |
+
theme = gr.themes.Default(font=[gr.themes.GoogleFont("Roboto"), "sans-serif", "sans-serif"], primary_hue="neutral", secondary_hue="neutral", neutral_hue="neutral").set(
|
39 |
+
button_primary_background_fill="#3FCCA5",
|
40 |
+
button_primary_background_fill_dark="#3FCCA5",
|
41 |
+
button_primary_text_color="#003F62",
|
42 |
+
body_background_fill="FFFFFF",
|
43 |
+
body_background_fill_dark="FFFFFF"
|
44 |
+
)
|
45 |
+
|
46 |
+
with gr.Blocks(theme=theme) as trioGPT:
|
47 |
+
inputs = gr.Textbox(lines=4, elem_id="inputs", label="Porozmawiaj z naszym chatbotem Real-Estate AI")#, elem_classes="textbox")
|
48 |
+
outputs = gr.Textbox(label="Odpowiedź", elem_id="outputs")#, elem_classes="textbox")
|
49 |
+
with gr.Row():
|
50 |
+
submit_btn = gr.Button("Wyślij", variant="primary")
|
51 |
+
clear_btn = gr.Button("Wyczyść")
|
52 |
+
|
53 |
+
submit_btn.click(chatbot, inputs=inputs, outputs=outputs)
|
54 |
+
clear_btn.click(fn=clear, inputs=None, outputs=[inputs, outputs])
|
55 |
+
|
56 |
+
trioGPT.launch(share=True)
|