langchainjs
langchainjs copied to clipboard
[Question]: Ability to see intermediate steps in MapReduceChain?
Is there any way to see the intermediate steps in the mapreduce chain when using the OpenAI llm?
I'm only able to see the original prompts at this time, even when setting it to "verbose"
Hi @Marviel we don't have that functionality yet, but it is planned, will update this issue once we have this
Cool!
FWIW I'd be happy to work on this if you can point me in the right direction. Looking through the openai llm, in theory it should already be outputting everything that is fed to it? I'm confused about why the verbosity is only off for the intermediate prompts in this mode.
Is the plan to make a secondary "verbose" argument that controls intermediate verbosity?
Great, happy to help you contribute this
If you're familiar with python the first place to look is the equivalent in the python library https://github.com/hwchase17/langchain/blob/c01f9100e4da26ba7014733f82ea04827b98eb16/langchain/chains/combine_documents/map_reduce.py#L75 We'd want to follow the same API, ie. have a return_intermediate_steps arg to the constructor that controls whether this is available.
Then what you want to do is make sure you add the intermediate steps to the final output object returned here https://github.com/hwchase17/langchainjs/blob/main/langchain/src/chains/combine_docs_chain.ts#L196 if that arg is true. You can see how it's done in python here https://github.com/hwchase17/langchain/blob/master/langchain/chains/combine_documents/map_reduce.py#L187
The verbose argument we usually use for logging things to the console, rather than controlling what the chain returns, as in this case.
Any questions let me know!
Heya, just added a PR (#1080) to add this ability. Be cool if you could check it out and test it too.
Heya, just added a PR (#1080) to add this ability. Be cool if you could check it out and test it too.
Thanks justin -- this one got away from me but will pull and test this evening. Thanks.