Custom System Prompts
Adopting custom system prompts for OramaCore Answer Sessions
When performing Answer Sessions and Advanced Reasoning Answer Sessions, OramaCore uses a standard system prompt to instruct the LLM on how to reply, provide guardrails, and ensure a low rate of hallucinations in the response.
If you're curious, you can find the full system prompt on GitHub.
Although the OramaCore system prompt is pretty strong, you may want to provide additional guidance and information to the system prompt.
For example, if a user is using an old, unmaintained version of your software, you could instruct OramaCore to advise the user to upgrade to the latest version with a prompt like:
Or, you may want to set a different tone of voice:
You can also put all together and specify a set of rules
Markdown is fully supported and encouraged.
Adding a Custom System Prompt to a Collection
Custrom system prompts are managed on a collection-basis. A single system prompt is not shared between collections.
When creating a new custom system prompt, you will have the opportunity of setting wether it should be used my OramaCore manually or automatically.
Manual System Prompts
Manual system prompts are system prompts stored as part of a collection, but won't be used by OramaCore unless explicitly specified when creating an Answer Session:
You can decide to A/B test them manually, set a specific system prompt for a specific group of users, or just enable them programmatically.
Automatic System Prompts
Automatic system prompts are system prompts that get randomly and automatically applied by OramaCore when no system_prompt_id
is specified in the createAnswerSession
configuration.
When using Orama Cloud, you will be able to see which system prompt has been used on every conversation, allowing you to understand which system prompts leads to better interaction scores (less hallucinations, better context recall, faithfulness, and more).
In summary, automatic system prompts will get randomly selected, allowing you to A/B test automatically various alternative and determine which one works best.
Creating a new System Prompt
To create a new system prompt, you can use the following method:
You can also pass an optional "id"
to the request body, if you want to specify a custom one. If no "id"
is found, OramaCore will generate a CUID for you.
Validating a System Prompt
Before inserting a new system prompt, we highly recommend run a validation check on it. This is to help you prevent:
- Injection and hijacking
- Too many instructions (which could confuse the LLM)
- Prompts that are too looking
To validate a system prompt, you can use the following API:
The API will return the following data:
List all System Prompts in a collection
You can always list all the prompts in a collection:
Get a System Prompt
Once you have inserted at least one System Prompt, you can retrieve it using the following API:
Delete a System Prompt
You can delete a System Prompt by using the following API:
Update a System Prompt
To update a System Prompt, you can use the following API: