Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supporting composable prompts and templates #620

Open
mhalle opened this issue Nov 8, 2024 · 0 comments
Open

Supporting composable prompts and templates #620

mhalle opened this issue Nov 8, 2024 · 0 comments

Comments

@mhalle
Copy link
Contributor

mhalle commented Nov 8, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant