Jithin James commited on
Commit
ee1ba0d
·
1 Parent(s): 78db084

clear till index - bug fixes

Browse files
Files changed (1) hide show
  1. app.py +15 -7
app.py CHANGED
@@ -1,10 +1,10 @@
1
  import gradio as gr
2
 
3
 
4
- def get_model_response(chat_txt, user_chats, full_chat_history):
5
- response = f'Hello, you said "{chat_txt}"'
6
- full_chat_history = full_chat_history + [chat_txt, response]
7
- user_chats.append(chat_txt)
8
  responses = [
9
  (full_chat_history[i], full_chat_history[i + 1])
10
  for i in range(0, len(full_chat_history) - 1, 2)
@@ -13,11 +13,19 @@ def get_model_response(chat_txt, user_chats, full_chat_history):
13
 
14
 
15
  def clear_chat(
16
- full_chat_history, chatbox, user_chats, cleartill_dropdown_choices, drop_down
 
 
 
 
17
  ):
18
- index = user_chats.index(drop_down)
 
 
 
19
  return (
20
- full_chat_history[:index],
 
21
  chatbox[:index],
22
  user_chats[:index],
23
  cleartill_dropdown_choices[:index],
 
1
  import gradio as gr
2
 
3
 
4
+ def get_model_response(txt: str, user_chats: list[str], full_chat_history: list[str]):
5
+ response = f'Hello, you said "{txt}"'
6
+ full_chat_history = full_chat_history + [txt, response]
7
+ user_chats.append(txt)
8
  responses = [
9
  (full_chat_history[i], full_chat_history[i + 1])
10
  for i in range(0, len(full_chat_history) - 1, 2)
 
13
 
14
 
15
  def clear_chat(
16
+ full_chat_history: list[str],
17
+ chatbox: list[tuple[str, str]],
18
+ user_chats: list[str],
19
+ cleartill_dropdown_choices: list[str],
20
+ drop_down: str,
21
  ):
22
+ if drop_down == "":
23
+ index = 0
24
+ else:
25
+ index = user_chats.index(drop_down)
26
  return (
27
+ # full_chat_history has user_chat and response chats in a single line.
28
+ full_chat_history[: index * 2],
29
  chatbox[:index],
30
  user_chats[:index],
31
  cleartill_dropdown_choices[:index],