Versioning
While prompt templates start with a single version, versioning allows you to maintain multiple variations of the same template. Versioning provides:
- Experimentation: Test different approaches while preserving the original template
- History Tracking: Maintain a record of how your prompts evolve over time
- Safe Updates: Make changes without losing previous working versions
The following example shows how to work with prompt template versions in elluminate:
| from dotenv import load_dotenv
from elluminate import Client
load_dotenv(override=True)
client = Client()
# Create a first version of the prompt template with name "P vs NP"
prompt_template, _ = client.prompt_templates.get_or_create(
"Explain whether {{question}} is in P or NP.",
name="P vs NP",
)
assert prompt_template.version == 1
# Create a second version of the prompt template with name "P vs NP"
prompt_template, _ = client.prompt_templates.get_or_create(
"Explain whether {{question}} is in polynomial or nondeterministic polynomial time.",
name="P vs NP",
)
assert prompt_template.version == 2
# Get or create a prompt with the same user prompt as the first version returns the first version
prompt_template, _ = client.prompt_templates.get_or_create(
"Explain whether {{question}} is in P or NP.",
name="P vs NP",
)
assert prompt_template.version == 1
# Explicitly get the second version of the prompt template
prompt_template = client.prompt_templates.get(name="P vs NP", version=2)
assert (
prompt_template.user_prompt_template
== "Explain whether {{question}} is in polynomial or nondeterministic polynomial time."
)
|
Versioning happens automatically when creating prompt templates with the same name. Each new template with an existing name becomes a new version. This automatic versioning applies both when using the SDK and the UI, making it easy to experiment with variations, maintain different versions for different use cases, or iteratively improve prompts.
