code_execution_files / HuggingFaceTB_SmolLM3-3B_6.txt
ariG23498's picture
ariG23498 HF Staff
Upload HuggingFaceTB_SmolLM3-3B_6.txt with huggingface_hub
5a316b2 verified
raw
history blame contribute delete
899 Bytes
```CODE:
tools = [
{
"name": "get_weather",
"description": "Get the weather in a city",
"parameters": {"type": "object", "properties": {"city": {"type": "string", "description": "The city to get the weather for"}}}}
]
messages = [
{
"role": "user",
"content": "Hello! How is the weather today in Copenhagen?"
}
]
inputs = tokenizer.apply_chat_template(
messages,
enable_thinking=False, # True works as well, your choice!
xml_tools=tools,
add_generation_prompt=True,
tokenize=True,
return_tensors="pt"
).to(model.device)
outputs = model.generate(inputs)
print(tokenizer.decode(outputs[0]))
```
ERROR:
Traceback (most recent call last):
File "/tmp/HuggingFaceTB_SmolLM3-3B_6Wkbs8V.py", line 30, in <module>
inputs = tokenizer.apply_chat_template(
^^^^^^^^^
NameError: name 'tokenizer' is not defined