Automate create_category via normal-mode generation of the decision model

This commit is contained in:
Denton Social
2026-09-23 20:45:28 -05:00
parent 147b6cba5f
commit ea2e5b8045
9 changed files with 307 additions and 18 deletions
+24
View File
@@ -91,3 +91,27 @@ class SemIfEngine:
"total_seconds": result.get("total_seconds"),
},
)
def generate(
self,
messages: list[dict],
temperature: float = 0.2,
max_tokens: int = 256,
) -> str:
"""Drive the pinned decision model in the normal way: text generation.
SemIf scoring reads option logits directly; this instead uses the
underlying llama.cpp chat-completion endpoint on the same loaded model,
e.g. for skill-tree authoring. Each call resets the KV cache by
default, so interleaving scoring and generation on one model is safe.
"""
model, tokenizer, metadata = self._ensure_loaded()
try:
reply = model.create_chat_completion(
messages=messages,
temperature=temperature,
max_tokens=max_tokens,
)
except Exception as exc:
raise EngineUnavailable(f"generation failed: {exc}") from exc
return reply["choices"][0]["message"]["content"].strip()