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

feat: add ChatPromptBuilder, deprecate DynamicChatPromptBuilder #7663

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

tstadel
Copy link
Member

@tstadel tstadel commented May 7, 2024

Related Issues

Proposed Changes:

This extends ChatPromptBuilder to change prompts at query time.

default_template = [ChatMessage.from_user("This is the default prompt: \\n Query: {{query}}")]
prompt_builder = ChatPromptBuilder(template=default_template)

pipe = Pipeline()
pipe.add_component("prompt_builder", prompt_builder)

# using the default prompt
result = pipe.run(
    data={
        "prompt_builder": {
            "query": "Where does the speaker live?",
        },
    }
)
#  "This is the default prompt: \n Query: Where does the speaker live?"

# using the dynamic prompt
result = pipe.run(
    data={
        "prompt_builder": {
            "template": [ChatMessage.from_user("This is the dynamic prompt:\\n Query: {{query}}")],
            "query": "Where does the speaker live?",
        },
    }
)
#  "This is the dynamic prompt: \n Query: Where does the speaker live?"

How did you test it?

  • added tests

Notes for the reviewer

  • There are no breaking changes
  • DynamicChatPromptBuilder is being deprecated

Checklist

@tstadel tstadel requested review from a team as code owners May 7, 2024 16:38
@tstadel tstadel requested review from dfokina and masci and removed request for a team May 7, 2024 16:38
@github-actions github-actions bot added topic:tests 2.x Related to Haystack v2.0 type:documentation Improvements on the docs labels May 7, 2024
@coveralls
Copy link
Collaborator

coveralls commented May 7, 2024

Pull Request Test Coverage Report for Build 9173707445

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.07%) to 90.621%

Totals Coverage Status
Change from base Build 9129529675: 0.07%
Covered Lines: 6638
Relevant Lines: 7325

💛 - Coveralls

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 topic:tests type:documentation Improvements on the docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants