diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..d0c3cbf --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..747ffb7 --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.https://www.sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "" goto help + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/docs/source/conf.py b/docs/source/conf.py new file mode 100644 index 0000000..5e3990d --- /dev/null +++ b/docs/source/conf.py @@ -0,0 +1,26 @@ +# Configuration file for the Sphinx documentation builder. +# +# For the full list of built-in configuration values, see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information + +project = "polymind" +copyright = "2024, TechTao" +author = "TechTao" + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration + +extensions = [] + +templates_path = ["_templates"] +exclude_patterns = [] + + +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output + +html_theme = "alabaster" +html_static_path = ["_static"] diff --git a/docs/source/index.rst b/docs/source/index.rst new file mode 100644 index 0000000..791e908 --- /dev/null +++ b/docs/source/index.rst @@ -0,0 +1,20 @@ +.. polymind documentation master file, created by + sphinx-quickstart on Tue Mar 19 21:51:36 2024. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to polymind's documentation! +==================================== + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/polymind/core/tool.py b/polymind/core/tool.py index 14bc0dd..57d077f 100644 --- a/polymind/core/tool.py +++ b/polymind/core/tool.py @@ -33,7 +33,16 @@ def __str__(self) -> str: @field_validator("type") def check_type(cls, v: str) -> str: allowed_simple_types = [ - "str", "int", "float", "bool", "ndarray", "np.ndarray", "pandas.DataFrame", "pd.DataFrame" + "str", + "int", + "float", + "bool", + "ndarray", + "np.ndarray", + "numpy.ndarray", + "pandas.DataFrame", + "pd.DataFrame", + "DataFrame", ] if v in allowed_simple_types: return v diff --git a/pyproject.toml b/pyproject.toml index 4f165b5..22c4365 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "polymind" -version = "0.0.21" # Update this version before publishing to PyPI +version = "0.0.22" # Update this version before publishing to PyPI description = "PolyMind is a customizable collaborative multi-agent framework for collective intelligence and distributed problem solving." authors = ["TechTao"] license = "MIT License" diff --git a/tests/polymind/core/test_tool.py b/tests/polymind/core/test_tool.py index 348d89d..778abbf 100644 --- a/tests/polymind/core/test_tool.py +++ b/tests/polymind/core/test_tool.py @@ -14,7 +14,21 @@ class TestParam: - @pytest.mark.parametrize("type_str", ["str", "int", "float"]) + @pytest.mark.parametrize( + "type_str", + [ + "str", + "int", + "float", + "bool", + "ndarray", + "np.ndarray", + "numpy.ndarray", + "DataFrame", + "pd.DataFrame", + "pandas.DataFrame", + ], + ) def test_valid_simple_types(self, type_str): """Test that Param accepts valid simple type strings.""" param = Param( @@ -32,6 +46,10 @@ def test_valid_simple_types(self, type_str): ("Dict[str, int]", "{'key': 123}"), ("List[int]", "[1, 2, 3]"), ("np.ndarray", "np.array([1, 2, 3])"), + ( + "pd.DataFrame", + "pd.DataFrame({'col1': [1, 2, 3], 'col2': ['a', 'b', 'c']})", + ), ], ) def test_valid_complex_types_with_example(self, type_str, example):