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

SequentialChain that runs next chain on each output of the prior chain? #223

Closed
jmontroy90 opened this issue Nov 29, 2022 · 3 comments
Closed

Comments

@jmontroy90
Copy link

jmontroy90 commented Nov 29, 2022

Given:

  • Chain A generates N outputs, e.g. we get back the text and immediately split it into a list based on post-processing we control and expect.
  • Chain B should then run over each of those outputs from Chain A.

Is there any way to do this elegantly in langchain? Perhaps some way to provide an output formatter to a chain, or some for_each pre- / post-processor? Or does this seem like just two independent chains with processing in between?

@hwchase17
Copy link
Contributor

@jmontroy90 im super glad you asked this question - i've been noodling around on some stuff but looking for some user feedback before landing.

im thinking that it would make sense to have a postprocessor for a prompt - since the return format of the LLM is dictated by the prompt. you could have many types of postprocessors, but one of the most common ones is probably a list. i have a branch that implements something like this, and here's a notebook using it: https://github.com/hwchase17/langchain/blob/harrison/use_output_parser/docs/examples/chains/llm_for_loop.ipynb

what do you think? would that cover your use case? happy to brainstorm/work on this together more - its def a common use case so id love to get it right

@jmontroy90
Copy link
Author

Ah, lovely, just like that. I can try to pull down your branch and play with it, see how it works for us. Thank you!

@hwchase17
Copy link
Contributor

Ah, lovely, just like that. I can try to pull down your branch and play with it, see how it works for us. Thank you!

perfect - let me know what you think!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants