Supporting composable prompts and templates
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 12.5k
- Forks
- 991
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 10
Description
Prompts, particularly system prompts, are often composed of multiple sections, each with a different purpose.
For example, a system prompt for a data analysis task could include sections about the format of the input data, the kind of data analysis to be performed, and the format of the output data. Each of these sections could be reusable for other tasks. For YouTube video transcript analysis, I often include a snippet about providing references and bookmark URLs using timecode so that I can go to the referenced section of video. I'd love to be able to reuse that snippet in different projects.
The simplest way to implement this functionality is to allow multiple prompts to be provided on the command line. However, that approach doesn't really support reusability.
Reusability is more practical using prompt templates. The simplest template-based approach would be to provide a list of templates on command line and concatenate the prompt in order. There's a challenge with prompt parameters, but that could be addressed by optionally using the template name as a prefix (e.g., $template.param). The exact syntax would depend on the implementation of variable substitution.
In addition to allowing specifying multiple templates on command line, the ideal approach would allow templates to reference other templates, allowing for template composition much like the kind used in documents in Django and Jinja2. That would allow (possibly composite) templates to be used in the same way "primitive" templates are used today.
I can't see a straightforward application of an existing template implementation to this task, unfortunately. There would need to be a way to support the features already in the YAML template implementation (like setting the llm model, for example). Maybe that could be done in frontmatter. Then there's template parameters, don't know how those would work if templates can reference subtemplates. Perhaps parameters could be passed to subtemplates as key value pairs in a template expression?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by examining the command-line template handling and the existing YAML template implementation mentioned in the issue, including its frontmatter and parameter behavior. Define the composition syntax and parameter passing before implementing it; done means reusable templates can reference other templates while preserving existing template features.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100