Prompt management
Opik provides a prompt library that you can use to manage your prompts. Storing prompts in a library allows you to version them, reuse them across projects, and manage them in a central location.
Using a prompt library does not mean you can’t store your prompt in code, we have designed the prompt library to be work seamlessly with your existing prompt files while providing the benefits of a central prompt library.
Managing prompts stored in code
The recommend way to create and manage prompts is using The
Prompt
object. This will allow you to continue versioning your prompts in code while
also getting the benefit of having prompt versions managed in the Opik platform
so you can more easily keep track of your progress.
Prompts stored in code
Prompts stored in a file
The prompt will now be stored in the library and versioned:

The Prompt
object will create a new prompt in the library if this prompt doesn’t already exist,
otherwise it will return the existing prompt.
This means you can safely run the above code multiple times without creating duplicate prompts.
Using the low level SDK
If you would rather keep prompts in the Opik platform and manually update / download them, you can use the low-level Python SDK to manage you prompts.
Creating prompts
You can create a new prompt in the library using both the SDK and the UI:
Using the Python SDK
Using the UI
Downloading your prompts
Once a prompt is created in the library, you can download it in code using the Opik.get_prompt
method:
If you are not using the SDK, you can download a prompt by using the REST API.
Linking prompts to Experiments
Experiments allow you to evaluate the performance
of your LLM application on a set of examples. When evaluating different prompts,
it can be useful to link the evaluation to a specific prompt version. This can
be achieved by passing the prompt
parameter when creating an Experiment:
The experiment will now be linked to the prompt allowing you to view all experiments that use a specific prompt:
