From 65f85af242c5a23386595f5c2215e2981674c2c6 Mon Sep 17 00:00:00 2001 From: Zander Chase <130414180+vowelparrot@users.noreply.github.com> Date: Wed, 10 May 2023 01:08:01 -0700 Subject: [PATCH] Improve math chain error msg (#4415) --- langchain/chains/llm_math/base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/langchain/chains/llm_math/base.py b/langchain/chains/llm_math/base.py index 1037658d60..b737b57f3f 100644 --- a/langchain/chains/llm_math/base.py +++ b/langchain/chains/llm_math/base.py @@ -84,7 +84,10 @@ class LLMMathChain(Chain): ) ) except Exception as e: - raise ValueError(f"{e}. Please try again with a valid numerical expression") + raise ValueError( + f'LLMMathChain._evaluate("{expression}") raised error: {e}.' + " Please try again with a valid numerical expression" + ) # Remove any leading and trailing brackets from the output return re.sub(r"^\[|\]$", "", output)