Update app.py
Browse files
app.py
CHANGED
@@ -177,6 +177,12 @@ def user_message(msg: str, history: list) -> tuple[str, list]:
|
|
177 |
history.append(ChatMessage(role="user", content=msg))
|
178 |
return "", history
|
179 |
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
|
181 |
# Create the Gradio interface
|
182 |
with gr.Blocks(theme=gr.themes.Soft(primary_hue="teal", secondary_hue="slate", neutral_hue="neutral")) as demo: # Using Soft theme with adjusted hues for a refined look
|
@@ -230,19 +236,10 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="teal", secondary_hue="slate", n
|
|
230 |
examples_per_page=5 # Adjust as needed
|
231 |
)
|
232 |
|
233 |
-
# Created by gemini-2.5-pro-exp-03-25
|
234 |
-
def process_message(msg):
|
235 |
-
"""Обрабатывает сообщение пользователя: сохраняет, отображает и генерирует ответ."""
|
236 |
-
msg_store_val, _, _ = lambda msg: (msg, msg, "")(msg) # Store message and clear input (inline lambda)
|
237 |
-
input_box_val, chatbot_val = user_message(msg_store_val, chatbot) # Add user message to chat
|
238 |
-
chatbot_val_final = stream_gemini_response(msg_store_val, chatbot_val) # Generate and stream response
|
239 |
-
return msg_store_val, input_box_val, chatbot_val_final
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
# Set up event handlers
|
244 |
msg_store = gr.State("") # Store for preserving user message
|
245 |
|
|
|
246 |
input_box.submit(
|
247 |
process_message,
|
248 |
inputs=[input_box],
|
|
|
177 |
history.append(ChatMessage(role="user", content=msg))
|
178 |
return "", history
|
179 |
|
180 |
+
def process_message(msg):
|
181 |
+
"""Обрабатывает сообщение пользователя: сохраняет, отображает и генерирует ответ."""
|
182 |
+
msg_store_val, _, _ = lambda msg: (msg, msg, "")(msg) # Store message and clear input (inline lambda)
|
183 |
+
input_box_val, chatbot_val = user_message(msg_store_val, chatbot) # Add user message to chat
|
184 |
+
chatbot_val_final = stream_gemini_response(msg_store_val, chatbot_val) # Generate and stream response
|
185 |
+
return msg_store_val, input_box_val, chatbot_val_final
|
186 |
|
187 |
# Create the Gradio interface
|
188 |
with gr.Blocks(theme=gr.themes.Soft(primary_hue="teal", secondary_hue="slate", neutral_hue="neutral")) as demo: # Using Soft theme with adjusted hues for a refined look
|
|
|
236 |
examples_per_page=5 # Adjust as needed
|
237 |
)
|
238 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
# Set up event handlers
|
240 |
msg_store = gr.State("") # Store for preserving user message
|
241 |
|
242 |
+
# Created by gemini-2.5-pro-exp-03-25
|
243 |
input_box.submit(
|
244 |
process_message,
|
245 |
inputs=[input_box],
|