forked from exo-explore/exo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_utils.py
More file actions
29 lines (24 loc) 路 810 Bytes
/
Copy pathtest_utils.py
File metadata and controls
29 lines (24 loc) 路 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from transformers import AutoTokenizer
from exo.worker.engines.mlx.generator.batch_generate import TextGenerationTaskParams
from exo.worker.engines.mlx.utils_mlx import apply_chat_template
tokenizer = AutoTokenizer.from_pretrained(
"mlx-community/Qwen2.5-Coder-32B-Instruct-4bit"
)
messages = [
{
"role": "user",
"content": [
{"type": "text", "text": "What is in this image?"},
{"type": "image_url", "image_url": {"url": "data:image/jpeg;base64,..."}},
],
}
]
params = TextGenerationTaskParams(
chat_template_messages=messages, input=[], model="qwen", request_id="123"
)
try:
print(apply_chat_template(tokenizer, params))
except Exception as e:
print(f"CRASH: {type(e).__name__}: {e}")
import traceback
traceback.print_exc()