vortex123 commited on
Commit
8e84e2a
·
verified ·
1 Parent(s): d61ca9b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -56,17 +56,19 @@ async def respond_thinking(message, history, selected_model):
56
  else:
57
  model_response_text += (part.text or "")
58
 
59
- yield ({"role": "assistant", "content": model_response_text}, thinking_process_text)
60
  except Exception as e:
61
- yield ({"role": "assistant", "content": f"Error during API call: {e}"}, f"Error during API call: {e}")
62
 
63
  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_thinking
 
67
  else:
68
  async for response in respond(message, history, model_name):
69
- yield response, ""
 
70
 
71
  def clear_thinking():
72
  return ""
@@ -86,8 +88,7 @@ with gr.Blocks() as demo:
86
  additional_inputs=[model_selection],
87
  title="Gemini Chat",
88
  description="Общайтесь с моделями Gemini от Google.",
89
- type="messages",
90
- outputs=[gr.Chatbot(), thinking_output] # Явное указание выходов
91
  )
92
 
93
  with gr.Row():
 
56
  else:
57
  model_response_text += (part.text or "")
58
 
59
+ yield {"role": "assistant", "content": model_response_text}, thinking_process_text
60
  except Exception as e:
61
+ yield {"role": "assistant", "content": f"Error during API call: {e}"}, f"Error during API call: {e}"
62
 
63
  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 ""
 
88
  additional_inputs=[model_selection],
89
  title="Gemini Chat",
90
  description="Общайтесь с моделями Gemini от Google.",
91
+ type="messages"
 
92
  )
93
 
94
  with gr.Row():