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

Fixed multi input prompt for MapReduceChain #4979

Merged
merged 8 commits into from
Jun 3, 2023

Conversation

imeckr
Copy link
Contributor

@imeckr imeckr commented May 19, 2023

Fixed multi input prompt for MapReduceChain

Added kwargs support for inner chains of MapReduceChain via from_params method
Currently the from_method method of intialising MapReduceChain chain doesn't work if prompt has multiple inputs. It happens because it uses StuffDocumentsChain and MapReduceDocumentsChain underneath, both of them require specifying document_variable_name if prompt of their llm_chain has more than one input.

With this PR, I have added support for passing their respective kwargs via the from_params method.

Fixes #4752

Who can review?

@dev2049 @hwchase17 @agola11

Copy link
Collaborator

@eyurtsev eyurtsev left a comment

Choose a reason for hiding this comment

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

Looks good! Wondering if we could update the type to a Mapping for immutability :)

langchain/chains/mapreduce.py Outdated Show resolved Hide resolved
@imeckr imeckr changed the title Added kwargs support for intermediate chains of MapReduceChain via from_params method Fixed multi input prompt for MapReduceChain May 20, 2023
@imeckr
Copy link
Contributor Author

imeckr commented May 22, 2023

@dev2049 @hwchase17 @agola11 Can anyone of you review this ?

@dev2049
Copy link
Contributor

dev2049 commented May 22, 2023

could we add either an example to the map reduce notebook or an integration test where this is used

@dev2049 dev2049 added the needs documentation PR needs to be updated with documentation label May 23, 2023
@imeckr
Copy link
Contributor Author

imeckr commented May 26, 2023

@dev2049 Let me know if this example works.

@hwchase17 hwchase17 merged commit bc875a9 into langchain-ai:master Jun 3, 2023
Undertone0809 pushed a commit to Undertone0809/langchain that referenced this pull request Jun 19, 2023
# Fixed multi input prompt for MapReduceChain

Added `kwargs` support for inner chains of `MapReduceChain` via
`from_params` method
Currently the `from_method` method of intialising `MapReduceChain` chain
doesn't work if prompt has multiple inputs. It happens because it uses
`StuffDocumentsChain` and `MapReduceDocumentsChain` underneath, both of
them require specifying `document_variable_name` if `prompt` of their
`llm_chain` has more than one `input`.

With this PR, I have added support for passing their respective `kwargs`
via the `from_params` method.

## Fixes langchain-ai#4752

## Who can review? 
@dev2049 @hwchase17 @agola11

---------

Co-authored-by: imeckr <chandanroutray2012@gmail.com>
This was referenced Jun 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs documentation PR needs to be updated with documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LLM Not Receiving prompt ARGS
4 participants