pipeworks_mud_mapper.models.template
Ollama template models for LLM prompt generation.
This module defines Pydantic models for Ollama templates that encode theme, voice guidance, and craft constraints for generating room descriptions.
Template Structure
Templates follow the Craft of Constraint philosophy and compile into comprehensive system prompts for small LLMs like Gemma2:2B.
OllamaTemplate
├── template_name, template_id, version
├── description
├── theme: TemplateTheme
│ ├── name (thematic world)
│ ├── tone (emotional register)
│ ├── era (time period)
│ └── aesthetic (sensory flavor)
├── voice_guidance: TemplateVoiceGuidance
│ ├── style (how the GM speaks)
│ ├── register (formality level)
│ ├── keyword_include (words to weave in)
│ └── keyword_exclude (words to avoid)
├── craft_constraints: TemplateCraftConstraints
│ ├── multi_part_spaces
│ ├── locked_things_approach
│ ├── silence_tone
│ └── exit_hints
├── examples: TemplateExamples
│ ├── good_crossroads / bad_crossroads
│ ├── good_locked_thing / bad_locked_thing
│ └── good_multi_part / bad_multi_part
├── author_notes
└── author_credit
Usage
Load and validate a template:
from pipeworks_mud_mapper.models import OllamaTemplate
import json
with open("template.json") as f:
data = json.load(f)
template = OllamaTemplate.model_validate(data)
See also
-, -
Classes
Theme configuration for an Ollama template. |
|
Voice and style guidance for an Ollama template. |
|
Craft of Constraint specific guidance for an Ollama template. |
|
Good and bad examples for an Ollama template. |
|
A complete Ollama template for room description generation. |
Module Contents
- class pipeworks_mud_mapper.models.template.TemplateTheme(/, **data)[source]
Bases:
pydantic.BaseModelTheme configuration for an Ollama template.
Defines the thematic world, emotional register, time period, and sensory flavor for room descriptions.
- class pipeworks_mud_mapper.models.template.TemplateVoiceGuidance(/, **data)[source]
Bases:
pydantic.BaseModelVoice and style guidance for an Ollama template.
Defines how the Game Master “speaks” in room descriptions, including formality, style, and keyword guidance.
- voice_register
Formality level (e.g., “matter-of-fact with dry humor”). Note: Named voice_register to avoid shadowing Pydantic’s register method.
- Type:
- keyword_include
Words/concepts to weave in when fitting.
- Type:
list[str]
- keyword_exclude
Words/concepts to avoid.
- Type:
list[str]
- model_config
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class pipeworks_mud_mapper.models.template.TemplateCraftConstraints(/, **data)[source]
Bases:
pydantic.BaseModelCraft of Constraint specific guidance for an Ollama template.
Provides theme-specific guidance for common description challenges: multi-part spaces, locked things, silence, and exit descriptions.
- class pipeworks_mud_mapper.models.template.TemplateExamples(/, **data)[source]
Bases:
pydantic.BaseModelGood and bad examples for an Ollama template.
Provides concrete examples that guide small LLMs to produce correct descriptions by showing what TO do and what NOT to do.
- class pipeworks_mud_mapper.models.template.OllamaTemplate(/, **data)[source]
Bases:
pydantic.BaseModelA complete Ollama template for room description generation.
Templates compile into comprehensive system prompts that guide small LLMs (like Gemma2:2B) to produce consistent, constraint-respecting room descriptions following the Craft of Constraint philosophy.
- theme
Thematic world configuration.
- Type:
- voice_guidance
Voice and style guidance.
- Type:
- craft_constraints
Craft of Constraint specific guidance.
- Type:
- examples
Good and bad examples for the template.
- Type:
Examples
Create a minimal template:
>>> template = OllamaTemplate( ... template_name="My Theme", ... template_id="my_theme", ... theme=TemplateTheme(name="A fantasy world", tone="epic"), ... voice_guidance=TemplateVoiceGuidance( ... style="grand narrator", ... register="formal" ... ), ... )
Load from JSON file:
>>> import json >>> with open("template.json") as f: ... data = json.load(f) >>> template = OllamaTemplate.model_validate(data)