toprompt
Class info¶
Re-exported classes¶
| Class | Module | Description |
|---|---|---|
| PromptConvertible | toprompt.to_prompt | Protocol for instances that can be converted to prompts. |
| PromptTypeConvertible | toprompt.to_prompt | Protocol for types that can be converted to prompts. |
| Template | toprompt.to_prompt | Marker class for strings that should be templated. |
🛈 DocStrings¶
ToPrompt: main package.
Convert python objects to LLM-friendly descriptions.
PromptConvertible
¶
PromptTypeConvertible
¶
Template
¶
render_prompt
¶
Render a Jinja prompt template using MiniJinja.
The context is exposed to the template as agent, e.g.
render_prompt("Hi {{ agent.name }}", {"name": "Bot"}) returns "Hi Bot".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
template
|
str
|
Jinja template string |
required |
agent_context
|
dict[str, Any]
|
Variables available as |
required |
Returns:
| Type | Description |
|---|---|
str
|
The rendered string |