Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
abefd07
1
Parent(s):
f0f354e
Refactor predict function for improved readability and update history handling
Browse files
app.py
CHANGED
@@ -198,7 +198,12 @@ def predict(message,
|
|
198 |
# history = state.get_prompt()[:-1]
|
199 |
# logger.info(f"==== History ====\n{history}")
|
200 |
|
201 |
-
generation_config = dict(temperature=temperature,
|
|
|
|
|
|
|
|
|
|
|
202 |
|
203 |
pixel_values = None
|
204 |
if image_path is not None:
|
@@ -215,7 +220,12 @@ def predict(message,
|
|
215 |
|
216 |
logger.info(f"==== Lenght Pixel values ====\n{len(pixel_values)}")
|
217 |
|
218 |
-
response, conv_history = model.chat(tokenizer,
|
|
|
|
|
|
|
|
|
|
|
219 |
logger.info(f"==== Conv History ====\n{conv_history}")
|
220 |
return response, conv_history
|
221 |
|
|
|
198 |
# history = state.get_prompt()[:-1]
|
199 |
# logger.info(f"==== History ====\n{history}")
|
200 |
|
201 |
+
generation_config = dict(temperature=temperature,
|
202 |
+
max_new_tokens=max_output_tokens,
|
203 |
+
top_p=top_p,
|
204 |
+
do_sample=do_sample,
|
205 |
+
num_beams = 3,
|
206 |
+
repetition_penalty=repetition_penalty)
|
207 |
|
208 |
pixel_values = None
|
209 |
if image_path is not None:
|
|
|
220 |
|
221 |
logger.info(f"==== Lenght Pixel values ====\n{len(pixel_values)}")
|
222 |
|
223 |
+
response, conv_history = model.chat(tokenizer,
|
224 |
+
pixel_values,
|
225 |
+
message,
|
226 |
+
generation_config,
|
227 |
+
history=None,
|
228 |
+
return_history=True)
|
229 |
logger.info(f"==== Conv History ====\n{conv_history}")
|
230 |
return response, conv_history
|
231 |
|