ArpitM commited on
Commit
b77ef56
·
1 Parent(s): 2f1690a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -15
app.py CHANGED
@@ -39,13 +39,13 @@ def predict(
39
  top_k: int,
40
  repetition_penalty: float,
41
  watermark: bool,
42
- # chatbot,
43
- # history,
44
  ):
45
  client = get_client(model)
46
  preprompt, user_name, assistant_name, sep = get_usernames(model)
47
 
48
- # history.append(inputs)
49
 
50
  past = []
51
  for data in chatbot:
@@ -96,16 +96,16 @@ def predict(
96
  if partial_words.endswith(assistant_name.rstrip()):
97
  partial_words = partial_words.rstrip(assistant_name.rstrip())
98
 
99
- # if i == 0:
100
- # history.append(" " + partial_words)
101
- # elif response.token.text not in user_name:
102
- # history[-1] = partial_words
103
 
104
- # chat = [
105
- # (history[i].strip(), history[i + 1].strip())
106
- # for i in range(0, len(history) - 1, 2)
107
  ]
108
- yield chat#, history
109
 
110
 
111
  def reset_textbox():
@@ -291,8 +291,8 @@ with gr.Blocks(
291
  top_k,
292
  repetition_penalty,
293
  watermark,
294
- # chatbot,
295
- # state,
296
  ],
297
  [chatbot, state],
298
  api_name = "chat_text",
@@ -308,8 +308,8 @@ with gr.Blocks(
308
  top_k,
309
  repetition_penalty,
310
  watermark,
311
- # chatbot,
312
- # state,
313
  ],
314
  [chatbot, state],
315
  api_name = "chat_button",
 
39
  top_k: int,
40
  repetition_penalty: float,
41
  watermark: bool,
42
+ chatbot,
43
+ history,
44
  ):
45
  client = get_client(model)
46
  preprompt, user_name, assistant_name, sep = get_usernames(model)
47
 
48
+ history.append(inputs)
49
 
50
  past = []
51
  for data in chatbot:
 
96
  if partial_words.endswith(assistant_name.rstrip()):
97
  partial_words = partial_words.rstrip(assistant_name.rstrip())
98
 
99
+ if i == 0:
100
+ history.append(" " + partial_words)
101
+ elif response.token.text not in user_name:
102
+ history[-1] = partial_words
103
 
104
+ chat = [
105
+ (history[i].strip(), history[i + 1].strip())
106
+ for i in range(0, len(history) - 1, 2)
107
  ]
108
+ yield chat, history
109
 
110
 
111
  def reset_textbox():
 
291
  top_k,
292
  repetition_penalty,
293
  watermark,
294
+ chatbot,
295
+ state,
296
  ],
297
  [chatbot, state],
298
  api_name = "chat_text",
 
308
  top_k,
309
  repetition_penalty,
310
  watermark,
311
+ chatbot,
312
+ state,
313
  ],
314
  [chatbot, state],
315
  api_name = "chat_button",