Sunday, 11 June 2023

How to get the selected path or tool with the output from a langchain Chain and/or agent?

I'm fairly new to langchain, and would appreciate any pointers on how to extract the selected Prompt or Tool (and other metadata)

that gets selected by a multichoice Chain (MultiPromptChain, MultiRetrievalQAChain) or by an Agent which is selecting a Tool.

i.e. in the console output, I wish to output the prompt or tool name in bold in my output:

Entering new MultiRetrievalQAChain chain... None: {'query': 'sky color'} Finished chain.

or

Entering new AgentExecutor chain... This is a math question that requires a calculation. Action: Calculator Action Input: √4 ... Final Answer: The square root of 4 is 2.0.

Is there any straightforward way to capture this so it can be reflected in the output as the source?



from How to get the selected path or tool with the output from a langchain Chain and/or agent?

No comments:

Post a Comment