rebase
This commit is contained in:
49
app/prompts/registry.py
Normal file
49
app/prompts/registry.py
Normal file
@@ -0,0 +1,49 @@
|
||||
"""Prompt registry — single entry point: `get_prompt(stage, language)`.
|
||||
|
||||
Per §10.1 of the TDD, all LLM prompts are stored in English (the "ru" key is
|
||||
legacy and not used for new development). The narrative output language is
|
||||
controlled by passing `{language}` into the prompt at format time.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from app.prompts.stages import (
|
||||
intro_scene,
|
||||
orchestrator_phase1,
|
||||
orchestrator_phase2,
|
||||
orchestrator_phase3_suggest,
|
||||
orchestrator_phase3_summary,
|
||||
subagent,
|
||||
summary,
|
||||
world_builder_entities,
|
||||
world_builder_env,
|
||||
world_builder_schema,
|
||||
world_editor,
|
||||
)
|
||||
|
||||
# Map stage name -> module
|
||||
_STAGE_MODULES = {
|
||||
"world_builder_schema": world_builder_schema,
|
||||
"world_builder_env": world_builder_env,
|
||||
"world_builder_entities": world_builder_entities,
|
||||
"world_editor": world_editor,
|
||||
"orchestrator_phase1": orchestrator_phase1,
|
||||
"orchestrator_phase2": orchestrator_phase2,
|
||||
"orchestrator_phase3_summary": orchestrator_phase3_summary,
|
||||
"orchestrator_phase3_suggest": orchestrator_phase3_suggest,
|
||||
"intro_scene": intro_scene,
|
||||
"subagent": subagent,
|
||||
"summary": summary,
|
||||
}
|
||||
|
||||
|
||||
def get_prompt(stage: str, language: str = "en") -> str:
|
||||
"""Return the prompt template string for the given stage and language.
|
||||
|
||||
Falls back to English if the requested language is not available.
|
||||
"""
|
||||
mod = _STAGE_MODULES.get(stage)
|
||||
if mod is None:
|
||||
raise KeyError(f"Unknown prompt stage: {stage!r}")
|
||||
prompts: dict[str, str] = getattr(mod, "PROMPTS", {})
|
||||
return prompts.get(language, prompts.get("en", ""))
|
||||
Reference in New Issue
Block a user