Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -101,7 +101,7 @@ def bot_streaming(message, history):
|
|
101 |
stop_str = '<|im_end|>'
|
102 |
keywords = [stop_str]
|
103 |
stopping_criteria = KeywordsStoppingCriteria(keywords, tokenizer, input_ids)
|
104 |
-
streamer = TextIteratorStreamer(tokenizer, skip_prompt=
|
105 |
|
106 |
image_tensor = model.process_images([image], model.config).to(dtype=model.dtype)
|
107 |
generation_kwargs = dict(input_ids=input_ids.to('cuda'), images=image_tensor.to('cuda'), streamer=streamer, max_new_tokens=100, stopping_criteria=[stopping_criteria])
|
@@ -115,7 +115,7 @@ def bot_streaming(message, history):
|
|
115 |
|
116 |
buffer += new_text
|
117 |
|
118 |
-
generated_text_without_prompt = buffer[
|
119 |
time.sleep(0.04)
|
120 |
yield generated_text_without_prompt
|
121 |
|
|
|
101 |
stop_str = '<|im_end|>'
|
102 |
keywords = [stop_str]
|
103 |
stopping_criteria = KeywordsStoppingCriteria(keywords, tokenizer, input_ids)
|
104 |
+
streamer = TextIteratorStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
|
105 |
|
106 |
image_tensor = model.process_images([image], model.config).to(dtype=model.dtype)
|
107 |
generation_kwargs = dict(input_ids=input_ids.to('cuda'), images=image_tensor.to('cuda'), streamer=streamer, max_new_tokens=100, stopping_criteria=[stopping_criteria])
|
|
|
115 |
|
116 |
buffer += new_text
|
117 |
|
118 |
+
generated_text_without_prompt = buffer[:]
|
119 |
time.sleep(0.04)
|
120 |
yield generated_text_without_prompt
|
121 |
|