fix: Revert back to straightforward PromptBuilder #6335
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 adaptPromptBuilder
to support chat-based prompting.What:
The PR includes the following changes:
PromptBuilder
will no longer support different templates for each message or dynamic templating on a per-user message basis.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.ChatMessage
data class, conditional template rendering based on user messages, and error checks related to the presence of either template string or template variables.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: