Improve math chain error msg (#4415)

This commit is contained in:
Zander Chase 2023-05-10 01:08:01 -07:00 committed by GitHub
parent f6c97e6af4
commit 65f85af242
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)