prompt
prompt ¶
PromptMessage
dataclass
¶
PromptMessage(
*,
system_text: str = "",
contexts: tuple[tuple[str, str], ...] = (),
ask_text: str = "",
)
Fluent builder for structured LLM prompts with system text, XML context sections, and a question.
Chain .system(), .context(tag, content), and .ask() to build prompts.
str() renders the full prompt with XML-wrapped context blocks.
load
classmethod
¶
Load a prompt from a .md file and render it via :meth:from_template.
Resolution searches directories in order, returning the first existing file:
the base directory if given (otherwise a prompts/ directory beside the
calling module), then the framework's bundled captain_hook/prompts/. The
file path is <dir>/<name>.md; name may contain / to nest.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Prompt name without the |
required |
base
|
str | Path | None
|
Optional directory to search instead of the caller-relative |
None
|
**vars
|
object
|
Template variables substituted into the file via |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
PromptMessage
|
class: |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If no matching file exists in any searched directory. |
KeyError
|
If the file references a placeholder not supplied in |