Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -34,135 +34,41 @@ def respond(
|
|
34 |
api_name="/chat"
|
35 |
)
|
36 |
|
37 |
-
yield response
|
38 |
|
39 |
# Ссылка на файл CSS
|
40 |
css_url = "https://neurixyufi-aihub.static.hf.space/style.css"
|
41 |
|
42 |
# Получение CSS по ссылке
|
43 |
response = requests.get(css_url)
|
44 |
-
css = response.text + "
|
45 |
-
* {
|
46 |
-
transition: all 0.2s;
|
47 |
-
}
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
color: #FFF !important;
|
76 |
-
font-size: 16px !important;
|
77 |
-
padding: 10px 20px !important;
|
78 |
-
border: 3px solid rgb(234 181 238) !important;
|
79 |
-
border-radius: 15px !important;
|
80 |
-
text-decoration: none !important;
|
81 |
-
transition: 0.5s ease-in-out !important;
|
82 |
-
font-weight: normal !important;
|
83 |
-
background: none !important;
|
84 |
-
}
|
85 |
-
.primary:hover {
|
86 |
-
background: rgb(234 181 238) !important;
|
87 |
-
color: #000 !important;
|
88 |
-
}
|
89 |
-
div.svelte-19hvt5v {
|
90 |
-
border: 0px solid #510067 !important;
|
91 |
-
background: #101010;
|
92 |
-
}
|
93 |
-
.selected.svelte-1uw5tnk {
|
94 |
-
border-color: #510067 !important;
|
95 |
-
border-width: 0px !important;
|
96 |
-
}
|
97 |
-
.tab-nav.svelte-1uw5tnk {
|
98 |
-
border-bottom: 0px solid #510067 !important;
|
99 |
-
}
|
100 |
-
.secondary {
|
101 |
-
color: #FFF !important;
|
102 |
-
font-size: 18px !important;
|
103 |
-
border: 3px solid rgb(96 55 103) !important;
|
104 |
-
border-radius: 15px !important;
|
105 |
-
transition: background-color 0.5s ease-in-out !important;
|
106 |
-
width: 100% !important;
|
107 |
-
background-color: transparent !important;
|
108 |
-
height: 50px !important;
|
109 |
-
font-weight: bold !important;
|
110 |
-
align-items: center !important;
|
111 |
-
justify-content: center !important;
|
112 |
-
background: none !important;
|
113 |
-
}
|
114 |
-
.secondary:hover {
|
115 |
-
background-color: rgb(96 55 103) !important;
|
116 |
-
}
|
117 |
-
.svelte-zyxd38 {
|
118 |
-
display: none !important;
|
119 |
-
visibility: hidden !important
|
120 |
-
}
|
121 |
-
.selected.svelte-1uw5tnk {
|
122 |
-
background: #151515;
|
123 |
-
border-radius: 25px !important;
|
124 |
-
margin-bottom: 3px !important;
|
125 |
-
}
|
126 |
-
button.svelte-1uw5tnk {
|
127 |
-
margin-bottom: 3px !important;
|
128 |
-
}
|
129 |
-
label.svelte-1mhtq7j.svelte-1mhtq7j.svelte-1mhtq7j:hover {
|
130 |
-
background: #291928 !important;
|
131 |
-
}
|
132 |
-
.controls.svelte-euo1cw.svelte-euo1cw {
|
133 |
-
background: #321f37 !important;
|
134 |
-
}
|
135 |
-
.padded.svelte-p87ime {
|
136 |
-
border: none !important;
|
137 |
-
}
|
138 |
-
label.svelte-1b6s6s {
|
139 |
-
background: #210e24 !important;
|
140 |
-
}
|
141 |
-
"""
|
142 |
-
|
143 |
-
# Определяем интерфейс Gradio
|
144 |
-
demo = gr.ChatInterface(
|
145 |
-
respond,
|
146 |
-
additional_inputs=[
|
147 |
-
gr.Textbox(value="Вы дружелюбный чат-бот, созданный balianone.com", label="Системное сообщение"),
|
148 |
-
gr.Slider(minimum=100, maximum=18000, value=18000, step=1, label="Максимальное количество новых токенов"),
|
149 |
-
gr.Slider(minimum=0.0, maximum=1.0, value=0.7, step=0.1, label="Температура"),
|
150 |
-
gr.Slider(
|
151 |
-
minimum=0.0,
|
152 |
-
maximum=1.0,
|
153 |
-
value=0.95,
|
154 |
-
step=0.05,
|
155 |
-
label="Top-p (нуклеарное сэмплирование)",
|
156 |
-
),
|
157 |
-
],
|
158 |
-
title="Чат-бот",
|
159 |
-
css=css
|
160 |
-
)
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
# Добавляем CSS для скрытия футера
|
165 |
-
demo.css = css
|
166 |
|
167 |
# Запускаем интерфейс
|
168 |
if __name__ == "__main__":
|
|
|
34 |
api_name="/chat"
|
35 |
)
|
36 |
|
37 |
+
yield [(message, response)]
|
38 |
|
39 |
# Ссылка на файл CSS
|
40 |
css_url = "https://neurixyufi-aihub.static.hf.space/style.css"
|
41 |
|
42 |
# Получение CSS по ссылке
|
43 |
response = requests.get(css_url)
|
44 |
+
css = response.text + ".gradio-container{max-width: 700px !important} h1{text-align:center}"
|
|
|
|
|
|
|
45 |
|
46 |
+
# Создаем интерфейс с использованием gr.Blocks
|
47 |
+
with gr.Blocks(css=css) as demo:
|
48 |
+
gr.Markdown("# Чат-бот")
|
49 |
+
|
50 |
+
with gr.Row():
|
51 |
+
with gr.Column():
|
52 |
+
chatbot = gr.Chatbot(label="Чат")
|
53 |
+
message = gr.Textbox(label="Введите ваше сообщение", placeholder="Введите ваше сообщение здесь...")
|
54 |
+
submit = gr.Button("Отправить")
|
55 |
+
|
56 |
+
with gr.Accordion("Настройки", open=False):
|
57 |
+
system_message = gr.Textbox(value="Вы дружелюбный чат-бот, созданный balianone.com", label="Системное сообщение")
|
58 |
+
max_tokens = gr.Slider(minimum=100, maximum=18000, value=18000, step=1, label="Максимальное количество новых токенов")
|
59 |
+
temperature = gr.Slider(minimum=0.0, maximum=1.0, value=0.7, step=0.1, label="Температура")
|
60 |
+
top_p = gr.Slider(minimum=0.0, maximum=1.0, value=0.95, step=0.05, label="Top-p (нуклеарное сэмплирование)")
|
61 |
+
|
62 |
+
# Обработка отправки сообщения
|
63 |
+
submit.click(
|
64 |
+
fn=respond,
|
65 |
+
inputs=[message, chatbot, system_message, max_tokens, temperature, top_p],
|
66 |
+
outputs=chatbot
|
67 |
+
).then(
|
68 |
+
fn=lambda: "",
|
69 |
+
inputs=None,
|
70 |
+
outputs=message
|
71 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
|
73 |
# Запускаем интерфейс
|
74 |
if __name__ == "__main__":
|