from transformers import AutoModelForCausalLM, AutoTokenizerrepo = "MMOPD/Qwen3-4B-OT3-tau2-3ep"tok = AutoTokenizer.from_pretrained(repo)model = AutoModelForCausalLM.from_pretrained(repo, dtype="auto", device_map="auto")tools = [{"type": "function", "function": {"name": "get_customer_by_phone", "description": "Look up a customer by phone number.", "parameters": {"type": "object", "properties": {"phone_number": {"type": "string"}}, "required": ["phone_number"]}}}]messages = [{"role": "system", "content": "You are a customer service agent for a telecom company. Follow the policy."}, {"role": "user", "content": "Hi, I can't send MMS messages since this morning. My number is 555-123-2002."}]text = tok.apply_chat_template(messages, tools=tools, tokenize=False, add_generation_prompt=True, enable_thinking=True)out = model.generate(**tok(text, return_tensors="pt").to(model.device), max_new_tokens=4096, do_sample=True, temperature=1.0, top_p=1.0)print(tok.decode(out[0][tok(text, return_tensors="pt").input_ids.shape[1]:], skip_special_tokens=False))