Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -64,11 +64,9 @@ async def process_message(message, history, model_name):
|
|
| 64 |
if "thinking" in model_name:
|
| 65 |
async for response, thinking in respond_thinking(message, history, model_name):
|
| 66 |
yield response
|
| 67 |
-
yield gr.update(value=thinking)
|
| 68 |
else:
|
| 69 |
async for response in respond(message, history, model_name):
|
| 70 |
yield response
|
| 71 |
-
yield gr.update(value="")
|
| 72 |
|
| 73 |
def clear_thinking():
|
| 74 |
return ""
|
|
@@ -95,7 +93,12 @@ with gr.Blocks() as demo:
|
|
| 95 |
clear_button = gr.Button("Очистить")
|
| 96 |
|
| 97 |
def change_chatbot(model_name):
|
| 98 |
-
return gr.ChatInterface.update()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
|
| 100 |
model_selection.change(
|
| 101 |
change_chatbot,
|
|
@@ -103,6 +106,12 @@ with gr.Blocks() as demo:
|
|
| 103 |
outputs=[chatbot],
|
| 104 |
)
|
| 105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
clear_button.click(lambda: None, None, chatbot, queue=False)
|
| 107 |
clear_button.click(clear_thinking, outputs=[thinking_output], queue=False)
|
| 108 |
|
|
|
|
| 64 |
if "thinking" in model_name:
|
| 65 |
async for response, thinking in respond_thinking(message, history, model_name):
|
| 66 |
yield response
|
|
|
|
| 67 |
else:
|
| 68 |
async for response in respond(message, history, model_name):
|
| 69 |
yield response
|
|
|
|
| 70 |
|
| 71 |
def clear_thinking():
|
| 72 |
return ""
|
|
|
|
| 93 |
clear_button = gr.Button("Очистить")
|
| 94 |
|
| 95 |
def change_chatbot(model_name):
|
| 96 |
+
return gr.ChatInterface.update()
|
| 97 |
+
|
| 98 |
+
async def update_thinking(history):
|
| 99 |
+
if history and history[-1][0] == "assistant" and len(history[-1]) > 1:
|
| 100 |
+
return history[-1][1]
|
| 101 |
+
return ""
|
| 102 |
|
| 103 |
model_selection.change(
|
| 104 |
change_chatbot,
|
|
|
|
| 106 |
outputs=[chatbot],
|
| 107 |
)
|
| 108 |
|
| 109 |
+
chatbot.on_message(
|
| 110 |
+
update_thinking,
|
| 111 |
+
inputs=[chatbot],
|
| 112 |
+
outputs=[thinking_output]
|
| 113 |
+
)
|
| 114 |
+
|
| 115 |
clear_button.click(lambda: None, None, chatbot, queue=False)
|
| 116 |
clear_button.click(clear_thinking, outputs=[thinking_output], queue=False)
|
| 117 |
|