Skip to content

feat(langchain): add stuff and map reduce chains #32333

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

Merged
merged 2 commits into from
Aug 7, 2025

Conversation

eyurtsev
Copy link
Collaborator

@eyurtsev eyurtsev commented Jul 30, 2025

  • Add stuff and map reduce chains
  • We'll need to rename and add unit tests to the chains prior to official release

Copy link

vercel bot commented Jul 30, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Visit Preview Aug 6, 2025 9:26pm

Copy link

codspeed-hq bot commented Jul 30, 2025

CodSpeed WallTime Performance Report

Merging #32333 will not alter performance

Comparing eugene/add_summarization_chains (9746089) with master (bc4251b)

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

Summary

✅ 13 untouched benchmarks

Copy link

codspeed-hq bot commented Jul 30, 2025

CodSpeed Instrumentation Performance Report

Merging #32333 will not alter performance

Comparing eugene/add_summarization_chains (9746089) with master (bc4251b)

Summary

✅ 14 untouched benchmarks

@mdrxy mdrxy changed the title wip feat(langchain): wip Jul 30, 2025
@mdrxy mdrxy added this to the v1 milestone Jul 30, 2025
@mdrxy mdrxy added the langchain Related to the package `langchain` label Jul 30, 2025
@eyurtsev eyurtsev force-pushed the eugene/add_summarization_chains branch 2 times, most recently from 948aec1 to 5e6c1e8 Compare August 4, 2025 14:47
from langchain_core.documents import Document


def format_document_xml(doc: Document) -> str:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

expose in documents as format_as_xml?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I like _ prefixed files in _internal as well

Comment on lines 6 to 8
__all__ = [
"RunnableCallable",
]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm. I really think we should avoid using this if possible.

)

# Needs to be in global scope as the type annotation is used at runtime
from langchain_core.documents import Document as Document
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
from langchain_core.documents import Document as Document
from langchain_core.documents import Document

Copy link
Collaborator

Choose a reason for hiding this comment

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

Be more specific w/ comment here - by pydantic I presume. Where? In schema gen?

],
] = "default_reducer",
context_schema: ContextT = None,
response_format: Optional[type[BaseModel]] = None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's use new syntax for unions bc we use from __future__ import annotations, so we can use |. There's a ruff rule to enforce

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also we will drop 3.9 super soon anyways.

] = "default_reducer",
context_schema: ContextT = None,
response_format: Optional[type[BaseModel]] = None,
) -> StateGraph[MapReduceState, ContextT, InputSchema, OutputSchema]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Glad this is coming in handy :)



class _Extractor(Generic[ContextT]):
"""Stuff documents chain implementation.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove "stuff" right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We need to rename for a better name.

Could be create_document_analyzer

@eyurtsev eyurtsev force-pushed the eugene/add_summarization_chains branch from e3de85d to 3bc07fd Compare August 6, 2025 21:16
@eyurtsev eyurtsev changed the title feat(langchain): wip feat(langchain): add stuff and map reduce chains Aug 6, 2025
@eyurtsev eyurtsev marked this pull request as ready for review August 6, 2025 21:28
Copy link
Collaborator

Choose a reason for hiding this comment

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

I can make these public in langgraph if it'd help you out 🫡, easy to fix later though bc internal

@eyurtsev eyurtsev merged commit 754528d into master Aug 7, 2025
47 checks passed
@eyurtsev eyurtsev deleted the eugene/add_summarization_chains branch August 7, 2025 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
langchain Related to the package `langchain`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants