Skip to content

feat(dspy): add metadata output, fix kwargs merging, and Mistral prompts#3161

Open
ahlemtr wants to merge 4 commits intodeepset-ai:mainfrom
ahlemtr:feat/dspy-metadata-kwargs
Open

feat(dspy): add metadata output, fix kwargs merging, and Mistral prompts#3161
ahlemtr wants to merge 4 commits intodeepset-ai:mainfrom
ahlemtr:feat/dspy-metadata-kwargs

Conversation

@ahlemtr
Copy link
Copy Markdown

@ahlemtr ahlemtr commented Apr 13, 2026

Related Issues
Part of #1635

Proposed Changes:

  • Fix: Config Merging: Implemented deep-merge strategy {**self.generation_kwargs, **(generation_kwargs or {})} to prevent runtime overrides from dropping default parameters.

  • Feat: Metadata & Observability: Updated run/run_async to return a metadata dictionary containing DSPy rationale, model_name, and signature type.

  • Improvement: Mistral Support: Added conditional [INST] {prompt} [/INST] wrapping for Mistral models to ensure correct instruction-tuning syntax.

  • Infrastructure: Native Async: Fully implemented run_async via self._module.acall() for compatibility with Haystack AsyncPipeline.

How did you test it?

  • Unit tests: Verified logic across 40 tests including new cases for kwarg merging and metadata (hatch run test:unit).

  • Linters: Passed all formatting checks (hatch run default:ruff check). Fixed E501 and W293 issues to comply with PEP 8.

  • Serialization: Confirmed component integrity via to_dict and from_dict checks.

Notes for the reviewer:

  • The metadata structure is unified across both sync and async execution paths.

  • Runtime generation_kwargs correctly prioritize user input over component defaults.

  • Updated test mocks to accommodate the new return dictionary structure.

Checklist:
I have read the contributors guidelines and the code of conduct
I have updated the related issue with new insights and changes
I added unit tests and updated the docstrings
I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test:.

@ahlemtr ahlemtr requested a review from a team as a code owner April 13, 2026 17:46
@ahlemtr ahlemtr requested review from anakin87 and removed request for a team April 13, 2026 17:46
@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
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 13, 2026

Coverage report (dspy)

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  integrations/dspy/src/haystack_integrations/components/generators/dspy/chat
  chat_generator.py
Project Total  

This report was generated by python-coverage-comment-action

@ahlemtr
Copy link
Copy Markdown
Author

ahlemtr commented Apr 13, 2026

This is my first-ever Pull Request to the Haystack core-integrations repository (and my first contribution ). Looking forward to the review and happy to make any adjustments needed!

@anakin87
Copy link
Copy Markdown
Member

Hello!

Unfortunately, we are still working on the DSPy integration (not published yet), and I think those changes are not needed.

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

@anakin87 anakin87 closed this Apr 14, 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:11
@julian-risch
Copy link
Copy Markdown
Member

@ahlemtr 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.

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

Labels

integration:dspy type:documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants