KingNish commited on
Commit
cd90270
1 Parent(s): 8fbbb6f

Update chatbot.py

Browse files
Files changed (1) hide show
  1. chatbot.py +10 -10
chatbot.py CHANGED
@@ -206,7 +206,13 @@ def qwen_inference(user_prompt, chat_history):
206
  )
207
  generation_kwargs = dict(inputs, streamer=streamer, max_new_tokens=2048)
208
 
209
- return streamer, generation_kwargs
 
 
 
 
 
 
210
 
211
  image_extensions = Image.registered_extensions()
212
  video_extensions = ("avi", "mp4", "mov", "mkv", "flv", "wmv", "mjpeg", "wav", "gif", "webm", "m4v", "3gp")
@@ -219,15 +225,9 @@ client_mistral_nemo = InferenceClient("mistralai/Mistral-Nemo-Instruct-2407")
219
 
220
  def model_inference(user_prompt, chat_history):
221
  if user_prompt["files"]:
222
- streamer, generation_kwargs = qwen_inference(user_prompt, chat_history)
223
-
224
- thread = Thread(target=model.generate, kwargs=generation_kwargs)
225
- thread.start()
226
-
227
- buffer = ""
228
- for new_text in streamer:
229
- buffer += new_text
230
- yield buffer
231
 
232
  else:
233
  func_caller = []
 
206
  )
207
  generation_kwargs = dict(inputs, streamer=streamer, max_new_tokens=2048)
208
 
209
+ thread = Thread(target=model.generate, kwargs=generation_kwargs)
210
+ thread.start()
211
+
212
+ buffer = ""
213
+ for new_text in streamer:
214
+ buffer += new_text
215
+ yield buffer
216
 
217
  image_extensions = Image.registered_extensions()
218
  video_extensions = ("avi", "mp4", "mov", "mkv", "flv", "wmv", "mjpeg", "wav", "gif", "webm", "m4v", "3gp")
 
225
 
226
  def model_inference(user_prompt, chat_history):
227
  if user_prompt["files"]:
228
+
229
+ for chunk in qwen_inference(user_prompt, chat_history):
230
+ yield chunk
 
 
 
 
 
 
231
 
232
  else:
233
  func_caller = []