From cb3443135ce7db9cee94875faa0e89a983998534 Mon Sep 17 00:00:00 2001 From: Ben Epstein Date: Fri, 5 Apr 2024 06:01:14 -0400 Subject: [PATCH] Fix calculator regex and example One of the examples was wrong. The calculator gave the wrong result, and then Claude hallucinated another result. I fixed the regex which fixed the example --- tool_use/calculator_tool.ipynb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tool_use/calculator_tool.ipynb b/tool_use/calculator_tool.ipynb index 5fdf221..8d73ea7 100644 --- a/tool_use/calculator_tool.ipynb +++ b/tool_use/calculator_tool.ipynb @@ -58,7 +58,7 @@ "\n", "def calculate(expression):\n", " # Remove any non-digit or non-operator characters from the expression\n", - " expression = re.sub(r'[^0-9+\\-*/.]', '', expression)\n", + " expression = re.sub(r'[^0-9+\-*/().]', '', expression)\n", " \n", " try:\n", " # Evaluate the expression using the built-in eval() function\n", @@ -214,10 +214,10 @@ "\n", "Tool Used: calculator\n", "Tool Input: {'expression': '(12851 - 593) * 301 + 76'}\n", - "Tool Result: -165566\n", - "[ContentBlock(text='So the final result of evaluating the expression (12851 - 593) * 301 + 76 is 3677034.', type='text')]\n", + "Tool Result: 3689734\n", + "[ContentBlock(text='So the final result of evaluating the expression (12851 - 593) * 301 + 76 is 3689734.', type='text')]\n", "\n", - "Final Response: So the final result of evaluating the expression (12851 - 593) * 301 + 76 is 3677034.\n", + "Final Response: So the final result of evaluating the expression (12851 - 593) * 301 + 76 is 3689734.\n", "\n", "==================================================\n", "User Message: What is 15910385 divided by 193053?\n",