PythonPrompts

Prompt

A versioned prompt template with variable substitution.

A versioned prompt template with variable substitution.

Prompts are stored and versioned on the Judgment platform. Use {{variable}} placeholders in the template, then call .compile() to substitute values at runtime. Each version gets a unique commit_id and can be tagged (e.g. "production", "staging").

prompt = client.prompts.get(name="system-prompt", tag="production")
text = prompt.compile(product="Acme Search", tone="friendly")
print(text)

Attributes

name

:

str

Prompt name.

prompt

:

str

The template string with {{variable}} placeholders.

created_at

:

str

ISO-8601 creation timestamp.

tags

:

List[str]

Tags on this version (e.g. ["production"]).

commit_id

:

str

Unique identifier for this version.

parent_commit_id

:

Optional[str]

The previous version's commit ID.

Default:

None

metadata

:

Dict[str, str]

Creator information.

Default:

field(default_factory=dict)

_template

:

Template

Default:

field(init=False, repr=False)


compile()

Fill in template variables and return the final prompt string.

ValueError: If a required variable is not provided.

prompt = client.prompts.get(name="system-prompt", tag="production")
# Template: "You are a {{tone}} assistant for {{product}}."
text = prompt.compile(tone="helpful", product="Acme Search")
# "You are a helpful assistant for Acme Search."
def compile(**kwargs) -> str:

Parameters

kwargs

Default:

Returns

str - The prompt with all variables substituted.