Get started with the Autoblocks Python Prompt SDK to manage and execute your prompts with type safety and autocomplete.
pydantic
v2 to be installed.You can install it with poetry add pydantic
or pip install pydantic
.autoblocksai
package adds the prompts generate_v2
CLI to your path:
outfile-dir
location you have configured.
You will need to run the prompts generate-v2
CLI any time you deploy a new major version of a prompt.
prompts generate-v2
poetry
, make sure to activate the virtualenv where the autoblocksai
package is installed
so that the prompts generate-v2
CLI can be found."my_app"
, then you can import like from autoblocks_prompts import my_app
.
Using that factory, you can initialize a prompt manager for each prompt in the application. If you have a prompt with
the ID "text-summarization"
, then you can initialize a prompt manager like my_app.text_summarizatio_prompt_manager
.
"latest"
, the prompt manager periodically refresh the in-memory prompt
in the background according to the refresh_interval
.
See the AutoblocksPromptManager
reference for more information.exec
method on the prompt manager starts a new prompt execution context.
It is a context manager that creates a PromptExecutionContext
instance that gives you fully-typed access to the prompt’s templates and parameters:
prompt_managers.py
:
prompt_managers
module and use the prompt managers as needed: