Return a prompt template, optionally with variables filled in.
(
arguments: Dict[str, Any],
store: SessionStore,
)
| 75 | |
| 76 | |
| 77 | def handle_get_prompt( |
| 78 | arguments: Dict[str, Any], |
| 79 | store: SessionStore, |
| 80 | ) -> str: |
| 81 | """Return a prompt template, optionally with variables filled in.""" |
| 82 | prompt_type = arguments["prompt_type"] |
| 83 | variables = arguments.get("variables", {}) |
| 84 | |
| 85 | if prompt_type not in _PROMPT_CATALOG: |
| 86 | available = list(_PROMPT_CATALOG.keys()) |
| 87 | return json.dumps({ |
| 88 | "error": f"Unknown prompt_type: {prompt_type}", |
| 89 | "available_types": available, |
| 90 | }) |
| 91 | |
| 92 | catalog_entry = _PROMPT_CATALOG[prompt_type] |
| 93 | |
| 94 | # Resolve the prompt content |
| 95 | content = _resolve_prompt(prompt_type, variables) |
| 96 | |
| 97 | result = { |
| 98 | "prompt_type": prompt_type, |
| 99 | "description": catalog_entry["description"], |
| 100 | "usage_hint": catalog_entry["usage_hint"], |
| 101 | "content": content, |
| 102 | } |
| 103 | return json.dumps(result, indent=2, ensure_ascii=False) |
| 104 | |
| 105 | |
| 106 | def _resolve_prompt(prompt_type: str, variables: Dict[str, Any]) -> str: |
nothing calls this directly
no test coverage detected