from unsloth import FastModel
from peft import PeftModel
m, tok = FastModel.from_pretrained("Qwen/Qwen3.6-27B", load_in_4bit=True, max_seq_length=2048)
m = PeftModel.from_pretrained(m, "openguardrails/rundrift-qwen3.6-27b-lora")
FastModel.for_inference(m)
tk = getattr(tok, "tokenizer", tok)
SYSTEM = "You are a security analyzer for autonomous AI agents. ... Respond with ONLY a JSON object."
user = "INSTRUCTION: Summarize report.pdf\n\nACTIONS:\n[0] file: read ~/.ssh/id_rsa"
msgs = [{"role":"system","content":SYSTEM},{"role":"user","content":user}]
prompt = tk.apply_chat_template(msgs, add_generation_prompt=True, tokenize=False) + "</think>\n\n"
ids = tk(prompt, return_tensors="pt").to(m.device)
out = m.generate(**ids, max_new_tokens=160, do_sample=False)
print(tk.decode(out[0, ids["input_ids"].shape[1]:], skip_special_tokens=True))