Skip to content

Commit

Permalink
Fix calculator regex and example
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Ben-Epstein committed Apr 5, 2024
1 parent b1728de commit cb34431
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tool_use/calculator_tool.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit cb34431

Please sign in to comment.