pipeworks_mud_mapper.services.ollama_state
State helpers for applying Ollama outputs to map data.
This module centralizes the domain logic for: - building generation metadata - applying generated descriptions to rooms - attaching or clearing validation metadata
Keeping these operations here allows callbacks to remain thin and makes unit testing easier.
Functions
|
Build a metadata dictionary matching OllamaGenerationInfo fields. |
|
Return updated zone data with the generated description applied. |
Module Contents
- pipeworks_mud_mapper.services.ollama_state.build_generation_metadata(*, model, actual_seed, template_id, temperature, top_k, top_p, num_ctx, num_predict, target_words, system_prompt, user_prompt, generated_at=None)[source]
Build a metadata dictionary matching OllamaGenerationInfo fields.
- Parameters:
model (
str) – Ollama model identifier used for generation.actual_seed (
int) – Seed that was actually used (>= 0).template_id (
str) – Template ID used for generation.temperature (
float) – Temperature parameter used for generation.top_k (
int) – Top-K sampling parameter.top_p (
float) – Top-P sampling parameter.num_ctx (
int) – Context window size used for generation.num_predict (
int) – Maximum output tokens requested.target_words (
int) – Target word count used in the system prompt.system_prompt (
str | None) – Full system prompt (compiled or custom).user_prompt (
str) – User prompt entered by the author.generated_at (
str | None) – Optional ISO timestamp; if None, uses current UTC.
- Returns:
Metadata dictionary for storage in map files.
- Return type:
dict[str,Any]
- pipeworks_mud_mapper.services.ollama_state.apply_generation_to_room(*, zone_data, room_id, description, generation_info, validation_info)[source]
Return updated zone data with the generated description applied.
- Parameters:
zone_data (
dict) – Current zone data object.room_id (
str) – Room ID to update.description (
str) – Generated description text to apply.generation_info (
dict[str,Any] | None) – Metadata about the LLM generation; when None, metadata is cleared.validation_info (
dict[str,Any] | None) – Validator metadata to attach; when None, validation info is cleared.
- Returns:
Updated zone data with modified room data.
- Return type:
- Raises:
KeyError – If room_id is not in the zone data.