🔧 fix(base.py): add exception handling when formatting intermediate steps to prevent crashes and log the exception

This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-07-08 11:43:01 -03:00
commit 6c17949d21

View file

@ -39,7 +39,11 @@ async def get_result_and_steps(langchain_object, inputs: Union[dict, str], **kwa
if isinstance(output, dict)
else output
)
thought = format_actions(intermediate_steps) if intermediate_steps else ""
try:
thought = format_actions(intermediate_steps) if intermediate_steps else ""
except Exception as exc:
logger.exception(exc)
thought = ""
except Exception as exc:
logger.exception(exc)
raise ValueError(f"Error: {str(exc)}") from exc