Skip to content

added PromptTemplateAdapter#3157

Open
udbhav4 wants to merge 3 commits intodeepset-ai:mainfrom
udbhav4:feat/dspy-prompt-template-adapter
Open

added PromptTemplateAdapter#3157
udbhav4 wants to merge 3 commits intodeepset-ai:mainfrom
udbhav4:feat/dspy-prompt-template-adapter

Conversation

@udbhav4
Copy link
Copy Markdown

@udbhav4 udbhav4 commented Apr 13, 2026

Related Issues

Proposed Changes:

Added the PromptTemplate Adaptor that wraps the user prompt under the custom model templates. This makes the job of the DSPy model better at making the prompts LLM ready.
This is not a component but a helper class that may be used by the DSPyChatGenerator and the DSPyProgramRunner.
Additional models can be internally added with the templates into the dictionary using a function whenever required.

How did you test it?

Ran test for every part of the code and checked for the working functionality. Added the test file to the branch.

Notes for the reviewer

Although I understand the earlier raised concern: "since it still requires users to understand DSPy's optimization concepts, I am not sure it adds much value on top of DSPy," I think this is still relevant since the user never really interacts with this like a component, but the algorithm extracts the model used by the user (which they were already mentioning), and uses the same model internally to wrap the prompt. This removes the concern of the user needing to understand DSPy's optimization concepts.

Checklist

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 13, 2026

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added the type:documentation Improvements or additions to documentation label Apr 13, 2026
@udbhav4 udbhav4 force-pushed the feat/dspy-prompt-template-adapter branch from 9c7e6ca to e13d813 Compare April 13, 2026 16:25
@github-actions
Copy link
Copy Markdown
Contributor

Coverage report (dspy)

This PR does not seem to contain any modification to coverable code.

@udbhav4 udbhav4 marked this pull request as ready for review April 13, 2026 16:31
@udbhav4 udbhav4 requested a review from a team as a code owner April 13, 2026 16:31
@udbhav4 udbhav4 requested review from davidsbatista and removed request for a team April 13, 2026 16:31
@anakin87 anakin87 requested review from anakin87 and removed request for anakin87 and davidsbatista April 13, 2026 16:32
@anakin87
Copy link
Copy Markdown
Member

Sorry, I find it hard to understand what the goal of this code is.

If you want to contribute, I recommend reading the Contributing guidelines and looking at Contributions wanted.

@anakin87 anakin87 closed this Apr 13, 2026
@julian-risch julian-risch reopened this Apr 14, 2026
@julian-risch julian-risch requested review from julian-risch and removed request for anakin87 April 14, 2026 09:09
@julian-risch
Copy link
Copy Markdown
Member

@udbhav4 I missed providing more context to anakin87 yesterday. I'll take over the review and see how we can align this PR with the other work on the DSPy integration that is going on in parallel. This will most likely take another week. Thank you for your patience.

@udbhav4
Copy link
Copy Markdown
Author

udbhav4 commented Apr 14, 2026

@udbhav4 I missed providing more context to anakin87 yesterday. I'll take over the review and see how we can align this PR with the other work on the DSPy integration that is going on in parallel. This will most likely take another week. Thank you for your patience.

Thanks @julian-risch ! Please have a look.
Rementioning- The goal is for the DSPy framework to receive a custom tagged prompt from Haystack based on the model initially chosen by the user. It is done to ensure tasks from the user are passed on under tag templates right from the beginning.
Suggestion- This can also be implemented post DSPy output, and before the revised prompt is fed to the inference LLM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants