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

Rename Prompt to Template and add deprecation warning to the prompt decorator #1440

Merged
merged 5 commits into from
Feb 24, 2025

Conversation

rlouf
Copy link
Member

@rlouf rlouf commented Feb 23, 2025

The current Prompt naming does not match what the object actually represents: a prompt template. I thus renamed it. I also made the decision to deprecate the @prompt decorator. Defining jinja templates in a docstring has always felt awkward, and users still have two ways to define a prompt template:

  • Writing a Jinja template in a separate text file and load it with Template.from_file
  • Defining a function that returns a string; anything can happen in this function, including using and rendering a Jinja template.

Closes #1438

I replace a couple `classmethod`s with simple function, and added
the default filter to the Jinja environment built when reading
the template from a file.
@rlouf rlouf requested a review from RobinPicard February 23, 2025 23:05
@rlouf rlouf force-pushed the template branch 3 times, most recently from 870922c to 386ce18 Compare February 24, 2025 00:13
Copy link
Contributor

@RobinPicard RobinPicard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that removing the prompt decorator is a good idea. I found it quite confusing.

@rlouf rlouf force-pushed the template branch 2 times, most recently from eac26dc to fe487c7 Compare February 24, 2025 08:37
The `Prompt` class really represents a prompt *template* and not a
prompt. I thus renamed it to `Template` to make it less confusing to the
user.
@rlouf rlouf merged commit ce27432 into dottxt-ai:main Feb 24, 2025
5 checks passed
@rlouf rlouf deleted the template branch February 24, 2025 08:46
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

Successfully merging this pull request may close these issues.

Rename s / Prompt / Template
2 participants