Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -14,7 +14,6 @@ system_message = "Ты — умный помощник по Университе
|
|
14 |
def respond(user_message, history):
|
15 |
if history is None:
|
16 |
history = []
|
17 |
-
# Формируем полный контекст (если нужно)
|
18 |
prompt = system_message + "\n"
|
19 |
for user_text, bot_text in history:
|
20 |
prompt += f"User: {user_text}\nAssistant: {bot_text}\n"
|
@@ -39,9 +38,10 @@ def respond(user_message, history):
|
|
39 |
with gr.Blocks() as demo:
|
40 |
chatbot = gr.Chatbot()
|
41 |
message = gr.Textbox(placeholder="Введите вопрос...")
|
42 |
-
state = gr.State([]) #
|
43 |
|
|
|
44 |
message.submit(respond, inputs=[message, state], outputs=[chatbot, state])
|
45 |
-
message.submit(lambda: "", None, message) #
|
46 |
|
47 |
demo.launch(share=True)
|
|
|
14 |
def respond(user_message, history):
|
15 |
if history is None:
|
16 |
history = []
|
|
|
17 |
prompt = system_message + "\n"
|
18 |
for user_text, bot_text in history:
|
19 |
prompt += f"User: {user_text}\nAssistant: {bot_text}\n"
|
|
|
38 |
with gr.Blocks() as demo:
|
39 |
chatbot = gr.Chatbot()
|
40 |
message = gr.Textbox(placeholder="Введите вопрос...")
|
41 |
+
state = gr.State([]) # состояние — история
|
42 |
|
43 |
+
# Привязываем submit на поле ввода
|
44 |
message.submit(respond, inputs=[message, state], outputs=[chatbot, state])
|
45 |
+
message.submit(lambda: "", None, message) # Очистка поля после отправки
|
46 |
|
47 |
demo.launch(share=True)
|