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

fix: Revert back to straightforward PromptBuilder #6335

Merged
merged 2 commits into from
Nov 23, 2023

Conversation

vblagoje
Copy link
Member

@vblagoje vblagoje commented Nov 17, 2023

Why:

This Pull Request reverts the PromptBuilder class back to its more straightforward implementation before attempts to use it for both chat and non-chat messages. With the introduction of DynamicPromptBuilder, the original PromptBuilder will serve static prompt use cases. We'll subsequently see if it makes sense to adapt PromptBuilder to support chat-based prompting.

What:

The PR includes the following changes:

  • Removal of the capability to use dynamic templates based on template variables. The PromptBuilder will no longer support different templates for each message or dynamic templating on a per-user message basis.
  • Simplification of the PromptBuilder class. It now solely focuses on rendering a prompt from a Jinja2 template string. The input types for the component are strictly the template variables found in the template string.
  • Removal of several functionalities including handling of ChatMessage data class, conditional template rendering based on user messages, and error checks related to the presence of either template string or template variables.
  • The constructor of PromptBuilder is now simplified to accept only a template string and no longer supports the option of providing template variables separately.

How can it be used:

After this change, PromptBuilder will be used for static templating scenarios where a single, consistent template string is required throughout the component's lifetime. This can be useful in applications where dynamic templating is unnecessary and a straightforward, consistent, prompt structure is preferred.

How did you test it:

Testing should focus on ensuring that the PromptBuilder correctly renders prompts using the provided Jinja2 template string. Tests for chat-based prompting were also reverted.

Notes for the reviewer:

  • See changes

@vblagoje vblagoje requested a review from a team as a code owner November 17, 2023 16:22
@vblagoje vblagoje requested review from masci and removed request for a team November 17, 2023 16:22
@github-actions github-actions bot added topic:tests 2.x Related to Haystack v2.0 type:documentation Improvements on the docs labels Nov 17, 2023
@vblagoje vblagoje added the ignore-for-release-notes PRs with this flag won't be included in the release notes. label Nov 17, 2023
@vblagoje vblagoje changed the title fix: Revert back to simple PromptBuilder fix: Revert back to straightforward PromptBuilder Nov 17, 2023
Copy link
Contributor

@masci masci left a comment

Choose a reason for hiding this comment

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

LGTM!

@silvanocerza silvanocerza merged commit e57a593 into main Nov 23, 2023
@silvanocerza silvanocerza deleted the revert_prompt_builder branch November 23, 2023 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.x Related to Haystack v2.0 ignore-for-release-notes PRs with this flag won't be included in the release notes. topic:tests type:documentation Improvements on the docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants