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

Simplify prompts.template and make it composable #17

Closed
rlouf opened this issue Aug 7, 2024 · 0 comments · Fixed by #22
Closed

Simplify prompts.template and make it composable #17

rlouf opened this issue Aug 7, 2024 · 0 comments · Fixed by #22
Labels
enhancement New feature or request

Comments

@rlouf
Copy link
Member

rlouf commented Aug 7, 2024

We want a better interface for prompts that does not use too much magic. Essentially what we want is a simpler, modular interface to jinja2 plus some magic to avoid prompting mistakes

import prompts


@prompts.template
def new_template(username: str):
    return "{{ prompt }}"

What the decorator does:

  1. Gather function signature
  2. Execute the function
  3. Gather argument values and bind to variable names. Apply defaults.
  4. Render the Jinja2 template using the variables detected by finding undeclared variables, if any.

This allows composition (#7)

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

Successfully merging a pull request may close this issue.

1 participant