langchain[patch]: update llm_router.py (#18865)

Issue : _call method of LLMRouterChain uses predict_and_parse, which is
slated for deprecation.

Description : Instead of using predict_and_parse, this replaces it with
individual predict and parse functions.
This commit is contained in:
Roshan Santhosh 2024-03-11 22:30:07 -07:00 committed by GitHub
parent 18de77cc8c
commit acf1ecc081
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -56,9 +56,11 @@ class LLMRouterChain(RouterChain):
) -> Dict[str, Any]: ) -> Dict[str, Any]:
_run_manager = run_manager or CallbackManagerForChainRun.get_noop_manager() _run_manager = run_manager or CallbackManagerForChainRun.get_noop_manager()
callbacks = _run_manager.get_child() callbacks = _run_manager.get_child()
prediction = self.llm_chain.predict(callbacks=callbacks, **inputs)
output = cast( output = cast(
Dict[str, Any], Dict[str, Any],
self.llm_chain.predict_and_parse(callbacks=callbacks, **inputs), self.llm_chain.prompt.output_parser.parse(prediction),
) )
return output return output