Skip to main content

Python Prompt SDK Reference

AutoblocksPromptManager

This is the base class the autogenerated prompt manager classes inherit from. Below are the arguments that can be passed when initializing a prompt manager:

exec

A context manager that starts a prompt execution context by creating a new PromptExecutionContext instance.

PromptExecutionContext

An instance of this class is created every time a new execution context is started with the exec context manager. It contains a frozen copy of the prompt manager’s in-memory prompt at the time exec was called. This ensures the prompt is stable for the duration of an execution, even if the in-memory prompt on the manager instance is refreshed mid-execution.

params

A pydantic model instance with the prompt’s parameters.

render_template

The render_template attribute contains an instance of a class that has methods for rendering each of the prompt’s templates. The template IDs and template parameters are all converted to snake case so that the method and argument names follow Python naming conventions. For example, the prompt in the quick start guide contains the below templates:

system

user

util/language

util/tone

From this, the CLI autogenerates a class with the following methods:
As a result, you are able to render your templates with functions that are aware of the required parameters for each template:

render_tool

The render_tool attribute contains an instance of a class that has methods for rendering each of the prompt’s tools. The tool names and tool parameters are all converted to snake case so that the method and argument names follow Python naming conventions. The tool will be in the JSON schema format that OpenAI expects.