Rulga commited on
Commit
7d91871
·
1 Parent(s): 581df1a

Refactor clear_conversation function for better accessibility and update model info display initialization

Browse files
Files changed (1) hide show
  1. app.py +6 -11
app.py CHANGED
@@ -294,15 +294,13 @@ def change_model(model_key):
294
  except Exception as e:
295
  return f"Error changing model: {str(e)}"
296
 
297
- def clear_conversation():
298
- """Clear conversation and save history before clearing"""
299
- # Save current history if there's a conversation
300
- if chatbot and conversation_id:
301
- save_chat_history(chatbot, conversation_id)
302
- return [], None
303
-
304
  # Create interface
305
  with gr.Blocks() as demo:
 
 
 
 
 
306
  with gr.Tabs():
307
  with gr.Tab("Chat"):
308
  gr.Markdown("# ⚖️ Status Law Assistant")
@@ -365,7 +363,7 @@ with gr.Blocks() as demo:
365
  )
366
 
367
  # Current model info display
368
- model_info = gr.Markdown()
369
 
370
  # Model Parameters
371
  with gr.Row():
@@ -464,9 +462,6 @@ with gr.Blocks() as demo:
464
  inputs=[model_selector],
465
  outputs=[model_info]
466
  )
467
-
468
- # ПЕРЕМЕЩЕНО ВНУТРЬ БЛОКА: При инициализации устанавливаем информацию о текущей модели
469
- model_info.update(value=update_model_info(DEFAULT_MODEL))
470
 
471
  # Launch application
472
  if __name__ == "__main__":
 
294
  except Exception as e:
295
  return f"Error changing model: {str(e)}"
296
 
 
 
 
 
 
 
 
297
  # Create interface
298
  with gr.Blocks() as demo:
299
+ # Определяем функцию clear_conversation внутри блока для доступа к компонентам
300
+ def clear_conversation():
301
+ """Clear conversation and save history before clearing"""
302
+ return [], None # Просто возвращаем пустые значения
303
+
304
  with gr.Tabs():
305
  with gr.Tab("Chat"):
306
  gr.Markdown("# ⚖️ Status Law Assistant")
 
363
  )
364
 
365
  # Current model info display
366
+ model_info = gr.Markdown(value=update_model_info(DEFAULT_MODEL))
367
 
368
  # Model Parameters
369
  with gr.Row():
 
462
  inputs=[model_selector],
463
  outputs=[model_info]
464
  )
 
 
 
465
 
466
  # Launch application
467
  if __name__ == "__main__":