feat: System message template system to easily edit system messages. #880
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Please describe the purpose of this pull request.
It adds a simple but effective template system for building the system message of memgpt.
It has predefined template fields that can be used to add parts of the default memgpt_chat system message.
The following shows the memgpt_chat system message in template form:
Each field adds a part of the system message of memgpt_chat, the template system will generate the memgpt system message automatically from it.
The template system get triggered when the system message string in the memgpt preset, ends with '_templated'. Like for example the following memgpt preset:
It then will load the built in template fields, like 'memgpt_introduction' or 'memgpt_realism_authenticity' and tries to load a file with the same name and path as the system message file, but having a file ending of '.yaml' consisting of field names with their respective content. The following is a complete example for instructing memgpt to talk like an old pirate:
memgpt_chat_pirate_templated.txt (in the user folder system_prompts)
memgpt_chat_pirate_templated.yaml (in the user folder system_prompts)
memgpt_pirate_preset.yaml (in the user folder presets)
Here are is the example in text form:
memgpt_chat_pirate_templated.txt (in the user folder system_prompts)
memgpt_chat_pirate_templated.yaml (in the user folder system_prompts)
memgpt_pirate_preset.yaml (in the user folder presets)
How to test
Start debug mode and look at the system message.
Have you tested this PR?
Yes.
Here is the resulting chat response of memgpt using the example preset:
Is your PR over 500 lines of code?
No. Very few lines!