import json, torchfrom transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfigfrom peft import PeftModel base_id = "Qwen/Qwen3-14B"adapter_id = "Softsasi/Kanban-1-Planner" bnb_config = BitsAndBytesConfig( load_in_4bit=True, bnb_4bit_quant_type="nf4", bnb_4bit_compute_dtype=torch.float16, bnb_4bit_use_double_quant=True,) tokenizer = AutoTokenizer.from_pretrained(adapter_id)base_model = AutoModelForCausalLM.from_pretrained( base_id, quantization_config=bnb_config, device_map="auto",)model = PeftModel.from_pretrained(base_model, adapter_id).eval() system_prompt = ( "You are Softsasi Kanban AI, a precision project-planning and JSON engine for Softsasi Workspace boards. " "Output ONLY raw valid JSON (no markdown fences, no prose) matching the Softsasi Kanban Export v1 schema:\n" "- Top-level keys: `_softsasi_kanban_export`: true, `version`: 1, `exportedAt` (ISO 8601 UTC), `boardName` (string), `columns` (array), `tasks` (array).\n" "- Each column in `columns`: `{ \"id\": slug-no-spaces, \"name\": string, \"color\": \"#rrggbb\" }` using valid 6-digit hex colors (e.g. `#6b7280`, `#3b82f6`, `#10b981`, `#eab308`, `#a855f7`, `#ef4444`, `#f97316`, `#06b6d4`, `#ec4899`).\n" "- Each task in `tasks`: `title`, `description` (plain text with \\n, NO HTML tags), `status` (must strictly match an existing `columns[i].id`), `labels` (array from `[\"red\",\"orange\",\"yellow\",\"green\",\"blue\",\"purple\"]` where `red`=high priority, `orange`/`yellow`=medium priority, `green`=low priority, `blue`/`purple`=category tags), `completed` (boolean), `order` (integer spacing e.g. 1000, 2000), optional `dueDate` (ISO 8601 string or omitted), and `checklists` in grouped format: `[{\"name\": string, \"assignedMembers\": [], \"items\": [{\"text\": string, \"isCompleted\": boolean, \"assignedMembers\": []}]}]`.\n" "When modifying an existing board JSON, preserve all unaffected columns, tasks, due dates, labels, and checklists cleanly.") messages = [ {"role": "system", "content": system_prompt}, { "role": "user", "content": "Create a Softsasi Kanban board named 'Horizon Telemetry — Sprint 4' with 3 columns (Backlog, In Progress, Released) and 3 actionable tasks with priority labels, grouped checklists, and ISO due dates starting 2027-03-01.", },] text = tokenizer.apply_chat_template( messages, tokenize=False, add_generation_prompt=True, enable_thinking=False,)inputs = tokenizer(text, return_tensors="pt").to(model.device)with torch.no_grad(): out = model.generate(**inputs, max_new_tokens=1536, temperature=0.15, do_sample=True) reply = tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)board = json.loads(reply)print(json.dumps(board, indent=2))