Mer1Alii commited on
Commit
3cbb154
·
1 Parent(s): 6b99196

Add type hints to event handlers to prevent schema parsing bugs

Browse files
Files changed (2) hide show
  1. README.md +1 -1
  2. app.py +6 -3
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 🚀
4
  colorFrom: blue
5
  colorTo: red
6
  sdk: gradio
7
- sdk_version: 4.44.1
8
  app_file: app.py
9
  pinned: false
10
  ---
 
4
  colorFrom: blue
5
  colorTo: red
6
  sdk: gradio
7
+ sdk_version: 4.39.0
8
  app_file: app.py
9
  pinned: false
10
  ---
app.py CHANGED
@@ -153,21 +153,24 @@ with gr.Blocks(title="AI Kripto Portföy Yöneticisi", css=css) as demo:
153
  msg = gr.Textbox(label="Asistana komut ver...", placeholder="Örn: BTC fiyatı nedir?")
154
  clear = gr.ClearButton([msg, chatbot])
155
 
156
- def user_action(user_message, chat_history):
157
  chat_history.append([user_message, None])
158
  return "", chat_history
159
 
160
- def bot_action(chat_history):
161
  user_message = chat_history[-1][0]
162
  bot_response = chat_interface(user_message, chat_history[:-1])
163
  chat_history[-1][1] = bot_response
164
  return chat_history, get_balance_ui()
165
 
 
 
 
166
  msg.submit(user_action, [msg, chatbot], [msg, chatbot]).then(
167
  bot_action, [chatbot], [chatbot, balance_panel]
168
  )
169
 
170
- refresh_btn.click(lambda: get_balance_ui(), None, balance_panel)
171
 
172
  if __name__ == "__main__":
173
  demo.launch()
 
153
  msg = gr.Textbox(label="Asistana komut ver...", placeholder="Örn: BTC fiyatı nedir?")
154
  clear = gr.ClearButton([msg, chatbot])
155
 
156
+ def user_action(user_message: str, chat_history: list) -> tuple[str, list]:
157
  chat_history.append([user_message, None])
158
  return "", chat_history
159
 
160
+ def bot_action(chat_history: list) -> tuple[list, str]:
161
  user_message = chat_history[-1][0]
162
  bot_response = chat_interface(user_message, chat_history[:-1])
163
  chat_history[-1][1] = bot_response
164
  return chat_history, get_balance_ui()
165
 
166
+ def update_balance() -> str:
167
+ return get_balance_ui()
168
+
169
  msg.submit(user_action, [msg, chatbot], [msg, chatbot]).then(
170
  bot_action, [chatbot], [chatbot, balance_panel]
171
  )
172
 
173
+ refresh_btn.click(update_balance, None, balance_panel)
174
 
175
  if __name__ == "__main__":
176
  demo.launch()