Skip to content

Conversation

khushmanvar
Copy link

Enhance MergerRetriever to support mixed retriever types

  • Updated the retrievers attribute in MergerRetriever to accept both BaseRetriever and RetrieverOutputLike types.
  • Modified the _get_relevant_documents method to handle invocation for both types of retrievers.
  • Added comprehensive unit tests for MergerRetriever to validate functionality with mixed retriever types, including async support and integration with history-aware retrievers.

Fixes #33184

Thank you for contributing to LangChain! Follow these steps to mark your pull request as ready for review. If any of these steps are not completed, your PR will not be considered for review.

  • PR title: Follows the format: {TYPE}({SCOPE}): {DESCRIPTION}

    • Examples:
      • feat(core): add multi-tenant support
      • fix(cli): resolve flag parsing error
      • docs(openai): update API usage examples
    • Allowed {TYPE} values:
      • feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert, release
    • Allowed {SCOPE} values (optional):
      • core, cli, langchain, standard-tests, text-splitters, docs, anthropic, chroma, deepseek, exa, fireworks, groq, huggingface, mistralai, nomic, ollama, openai, perplexity, prompty, qdrant, xai, infra
    • Once you've written the title, please delete this checklist item; do not include it in the PR.
  • PR message: Delete this entire checklist and replace with

  • Lint and test: Run make format, make lint and make test from the root of the package(s) you've modified. We will not consider a PR unless these three are passing in CI. See contribution guidelines for more.

Additional guidelines:

  • Most PRs should not touch more than one package.
  • Please do not add dependencies to pyproject.toml files (even optional ones) unless they are required for unit tests. Likewise, please do not update the uv.lock files unless you are adding a required dependency.
  • Changes should be backwards compatible.
  • Make sure optional dependencies are imported within a function.

…types

- Updated the `retrievers` attribute in `MergerRetriever` to accept both `BaseRetriever` and `RetrieverOutputLike` types.
- Modified the `_get_relevant_documents` method to handle invocation for both types of retrievers.
- Added comprehensive unit tests for `MergerRetriever` to validate functionality with mixed retriever types, including async support and integration with history-aware retrievers.

Fixes langchain-ai#33184
@github-actions github-actions bot added langchain Related to the package `langchain` feature labels Oct 14, 2025
@khushmanvar khushmanvar changed the title feat(retrievers): enhance MergerRetriever to support mixed retriever feat(langchain): enhance MergerRetriever to support mixed retriever Oct 14, 2025
@github-actions github-actions bot added feature and removed feature labels Oct 14, 2025
"""Retriever that merges the results of multiple retrievers."""

retrievers: list[BaseRetriever]
retrievers: list[BaseRetriever | RetrieverOutputLike]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would RetrieverLike work? (Since it has as input a str?)

RetrieverLike = Runnable[RetrieverInput, RetrieverOutput]

@eyurtsev eyurtsev self-requested a review October 14, 2025 19:15
@eyurtsev eyurtsev self-assigned this Oct 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature langchain Related to the package `langchain`

Projects

None yet

Development

Successfully merging this pull request may close these issues.

create_history_aware_retriever is not compatible with MergerRetriever

2 participants