From a90a5ca8cc238d3ee68b784af3e31423816a0373 Mon Sep 17 00:00:00 2001 From: sdreyer Date: Thu, 19 Dec 2024 11:21:19 -0800 Subject: [PATCH 1/4] Math Update --- toolkits/math/LICENSE | 21 ++++++++++ toolkits/math/Makefile | 53 ++++++++++++++++++++++++++ toolkits/math/evals/eval_math_tools.py | 13 +++---- toolkits/math/pyproject.toml | 28 +++++++++++++- 4 files changed, 106 insertions(+), 9 deletions(-) create mode 100644 toolkits/math/LICENSE create mode 100644 toolkits/math/Makefile diff --git a/toolkits/math/LICENSE b/toolkits/math/LICENSE new file mode 100644 index 00000000..76cd1385 --- /dev/null +++ b/toolkits/math/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024, Arcade AI + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/toolkits/math/Makefile b/toolkits/math/Makefile new file mode 100644 index 00000000..12f56af7 --- /dev/null +++ b/toolkits/math/Makefile @@ -0,0 +1,53 @@ +.PHONY: help + +help: + @echo "🛠️ math Commands:\n" + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + +.PHONY: install +install: ## Install the poetry environment and install the pre-commit hooks + @echo "📦 Checking if Poetry is installed" + @if ! command -v poetry &> /dev/null; then \ + echo "📦 Installing Poetry with pip"; \ + pip install poetry; \ + else \ + echo "📦 Poetry is already installed"; \ + fi + @echo "🚀 Installing package in development mode with all extras" + poetry install --all-extras + +.PHONY: build +build: clean-build ## Build wheel file using poetry + @echo "🚀 Creating wheel file" + poetry build + +.PHONY: clean-build +clean-build: ## clean build artifacts + @echo "🗑️ Cleaning dist directory" + rm -rf dist + +.PHONY: test +test: ## Test the code with pytest + @echo "🚀 Testing code: Running pytest" + @poetry run pytest -W ignore -v --cov --cov-config=pyproject.toml --cov-report=xml + +.PHONY: coverage +coverage: ## Generate coverage report + @echo "coverage report" + coverage report + @echo "Generating coverage report" + coverage html + +.PHONY: bump-version +bump-version: ## Bump the version in the pyproject.toml file + @echo "🚀 Bumping version in pyproject.toml" + poetry version patch + +.PHONY: check +check: ## Run code quality tools. + @echo "🚀 Checking Poetry lock file consistency with 'pyproject.toml': Running poetry check --lock" + @poetry check --lock + @echo "🚀 Linting code: Running pre-commit" + @poetry run pre-commit run -a + @echo "🚀 Static type checking: Running mypy" + @poetry run mypy --config-file=pyproject.toml diff --git a/toolkits/math/evals/eval_math_tools.py b/toolkits/math/evals/eval_math_tools.py index 6c6038a3..4c9e4ab1 100644 --- a/toolkits/math/evals/eval_math_tools.py +++ b/toolkits/math/evals/eval_math_tools.py @@ -6,7 +6,6 @@ BinaryCritic, EvalRubric, EvalSuite, - ExpectedToolCall, tool_eval, ) @@ -34,9 +33,9 @@ def math_eval_suite(): name="Add two large numbers", user_message="Add 12345 and 987654321", expected_tool_calls=[ - ExpectedToolCall( - func=add, - args={ + ( + add, + { "a": 12345, "b": 987654321, }, @@ -53,9 +52,9 @@ def math_eval_suite(): name="Take the square root of a large number", user_message="What is the square root of 3224990521?", expected_tool_calls=[ - ExpectedToolCall( - func=sqrt, - args={ + ( + sqrt, + { "a": 3224990521, }, ) diff --git a/toolkits/math/pyproject.toml b/toolkits/math/pyproject.toml index 1407c37f..6f845361 100644 --- a/toolkits/math/pyproject.toml +++ b/toolkits/math/pyproject.toml @@ -1,17 +1,41 @@ [tool.poetry] name = "arcade_math" -version = "0.1.0" +version = "0.1.7" description = "Math toolkit for Arcade" authors = ["Arcade AI "] - [tool.poetry.dependencies] python = "^3.10" arcade-ai = "0.1.*" [tool.poetry.dev-dependencies] pytest = "^8.3.0" +pytest-cov = "^4.0.0" +pytest-asyncio = "^0.24.0" +pytest-mock = "^3.11.1" +mypy = "^1.5.1" +pre-commit = "^3.4.0" +tox = "^4.11.1" +ruff = "^0.7.4" [build-system] requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" + +[tool.mypy] +files = ["arcade_math/**/*.py"] +python_version = "3.10" +disallow_untyped_defs = "True" +disallow_any_unimported = "True" +no_implicit_optional = "True" +check_untyped_defs = "True" +warn_return_any = "True" +warn_unused_ignores = "True" +show_error_codes = "True" +ignore_missing_imports = "True" + +[tool.pytest.ini_options] +testpaths = ["tests"] + +[tool.coverage.report] +skip_empty = true From 1d7567c8c67241ba1fdb2b3262386ef922904dc0 Mon Sep 17 00:00:00 2001 From: sdreyer Date: Thu, 19 Dec 2024 11:25:48 -0800 Subject: [PATCH 2/4] Revert eval changes --- toolkits/math/evals/eval_math_tools.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/toolkits/math/evals/eval_math_tools.py b/toolkits/math/evals/eval_math_tools.py index 4c9e4ab1..6c6038a3 100644 --- a/toolkits/math/evals/eval_math_tools.py +++ b/toolkits/math/evals/eval_math_tools.py @@ -6,6 +6,7 @@ BinaryCritic, EvalRubric, EvalSuite, + ExpectedToolCall, tool_eval, ) @@ -33,9 +34,9 @@ def math_eval_suite(): name="Add two large numbers", user_message="Add 12345 and 987654321", expected_tool_calls=[ - ( - add, - { + ExpectedToolCall( + func=add, + args={ "a": 12345, "b": 987654321, }, @@ -52,9 +53,9 @@ def math_eval_suite(): name="Take the square root of a large number", user_message="What is the square root of 3224990521?", expected_tool_calls=[ - ( - sqrt, - { + ExpectedToolCall( + func=sqrt, + args={ "a": 3224990521, }, ) From b74dc13fd68c47b423cc810b51db9427f6ba7ada Mon Sep 17 00:00:00 2001 From: sdreyer Date: Thu, 19 Dec 2024 11:31:25 -0800 Subject: [PATCH 3/4] Remove lock flag --- toolkits/math/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolkits/math/Makefile b/toolkits/math/Makefile index 12f56af7..07f60b11 100644 --- a/toolkits/math/Makefile +++ b/toolkits/math/Makefile @@ -46,7 +46,7 @@ bump-version: ## Bump the version in the pyproject.toml file .PHONY: check check: ## Run code quality tools. @echo "🚀 Checking Poetry lock file consistency with 'pyproject.toml': Running poetry check --lock" - @poetry check --lock + @poetry check @echo "🚀 Linting code: Running pre-commit" @poetry run pre-commit run -a @echo "🚀 Static type checking: Running mypy" From cf24e3334e2f4bfa83a1fa9e4ec059edff1a5648 Mon Sep 17 00:00:00 2001 From: sdreyer Date: Thu, 19 Dec 2024 11:33:35 -0800 Subject: [PATCH 4/4] Fix echo --- toolkits/math/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolkits/math/Makefile b/toolkits/math/Makefile index 07f60b11..4fb67549 100644 --- a/toolkits/math/Makefile +++ b/toolkits/math/Makefile @@ -45,7 +45,7 @@ bump-version: ## Bump the version in the pyproject.toml file .PHONY: check check: ## Run code quality tools. - @echo "🚀 Checking Poetry lock file consistency with 'pyproject.toml': Running poetry check --lock" + @echo "🚀 Checking Poetry lock file consistency with 'pyproject.toml': Running poetry check" @poetry check @echo "🚀 Linting code: Running pre-commit" @poetry run pre-commit run -a