prompt_text (prompt/lookup.py)

DeepTutor · deeptutor/services/prompt/lookup.py · python · Apache-2.0
ai, tag:knn-classified

Retrieves a string from nested prompt YAML mapping by path with fallback.

# Source: https://github.com/HKUDS/DeepTutor | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
# Provided via justclaw.it.com; keep this notice with the code.
"""Reading one string out of a loaded prompt pack.

Prompt packs are nested YAML mappings, and every caller wants the same thing
from them: the string at a path, or a fallback when that path is missing,
holds a mapping, or holds an empty string. Seven modules used to carry their
own copy of this walk — six of them the ``default=""`` special case of the
seventh.
"""

from __future__ import annotations

from typing import Any


def prompt_text(prompts: dict[str, Any], path: tuple[str, ...], default: str = "") -> str:
    """The string at *path* inside *prompts*, or *default*."""
    value: An

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key