fabricatio 0.1.0__tar.gz → 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. {fabricatio-0.1.0 → fabricatio-0.1.2}/.github/workflows/build-package.yaml +68 -58
  2. fabricatio-0.1.2/.github/workflows/ruff.yaml +20 -0
  3. {fabricatio-0.1.0 → fabricatio-0.1.2}/.gitignore +12 -11
  4. {fabricatio-0.1.0 → fabricatio-0.1.2}/.python-version +1 -1
  5. {fabricatio-0.1.0 → fabricatio-0.1.2}/PKG-INFO +84 -3
  6. fabricatio-0.1.2/README.md +76 -0
  7. fabricatio-0.1.2/examples/minor/hello_fabricatio.py +29 -0
  8. fabricatio-0.1.2/pyproject.toml +138 -0
  9. {fabricatio-0.1.0 → fabricatio-0.1.2}/src/fabricatio/__init__.py +24 -18
  10. fabricatio-0.1.2/src/fabricatio/config.py +200 -0
  11. {fabricatio-0.1.0 → fabricatio-0.1.2}/src/fabricatio/core.py +165 -148
  12. fabricatio-0.1.0/src/fabricatio/logger.py → fabricatio-0.1.2/src/fabricatio/journal.py +7 -2
  13. fabricatio-0.1.2/src/fabricatio/models/action.py +90 -0
  14. fabricatio-0.1.2/src/fabricatio/models/events.py +66 -0
  15. fabricatio-0.1.2/src/fabricatio/models/generic.py +466 -0
  16. fabricatio-0.1.2/src/fabricatio/models/role.py +50 -0
  17. fabricatio-0.1.2/src/fabricatio/models/task.py +224 -0
  18. {fabricatio-0.1.0 → fabricatio-0.1.2}/src/fabricatio/models/tool.py +101 -80
  19. {fabricatio-0.1.0 → fabricatio-0.1.2}/src/fabricatio/models/utils.py +10 -15
  20. fabricatio-0.1.2/src/fabricatio/parser.py +66 -0
  21. fabricatio-0.1.2/src/fabricatio/toolboxes/__init__.py +7 -0
  22. fabricatio-0.1.2/src/fabricatio/toolboxes/task.py +4 -0
  23. {fabricatio-0.1.0 → fabricatio-0.1.2}/tests/test_config.py +5 -3
  24. fabricatio-0.1.2/tests/test_core.py +94 -0
  25. fabricatio-0.1.2/tests/test_events.py +49 -0
  26. fabricatio-0.1.2/tests/test_models/test_action.py +58 -0
  27. {fabricatio-0.1.0 → fabricatio-0.1.2}/tests/test_models/test_generic.py +1 -1
  28. {fabricatio-0.1.0 → fabricatio-0.1.2}/tests/test_models/test_role.py +1 -1
  29. fabricatio-0.1.2/tests/test_models/test_tool.py +62 -0
  30. fabricatio-0.1.2/tests/test_parser.py +13 -0
  31. {fabricatio-0.1.0 → fabricatio-0.1.2}/uv.lock +1688 -1295
  32. fabricatio-0.1.0/.github/workflows/pre-commit.yaml +0 -25
  33. fabricatio-0.1.0/README.md +0 -0
  34. fabricatio-0.1.0/pyproject.toml +0 -67
  35. fabricatio-0.1.0/src/fabricatio/config.py +0 -122
  36. fabricatio-0.1.0/src/fabricatio/fs.py +0 -1
  37. fabricatio-0.1.0/src/fabricatio/models/action.py +0 -22
  38. fabricatio-0.1.0/src/fabricatio/models/events.py +0 -68
  39. fabricatio-0.1.0/src/fabricatio/models/generic.py +0 -310
  40. fabricatio-0.1.0/src/fabricatio/models/role.py +0 -14
  41. fabricatio-0.1.0/tests/test_core.py +0 -50
  42. fabricatio-0.1.0/tests/test_logger.py +0 -14
  43. fabricatio-0.1.0/tests/test_models/test_action.py +0 -25
  44. fabricatio-0.1.0/tests/test_models/test_tool.py +0 -30
  45. {fabricatio-0.1.0 → fabricatio-0.1.2}/LICENSE +0 -0
  46. {fabricatio-0.1.0 → fabricatio-0.1.2}/src/fabricatio/py.typed +0 -0
  47. {fabricatio-0.1.0 → fabricatio-0.1.2}/tests/__init__.py +0 -0
  48. {fabricatio-0.1.0 → fabricatio-0.1.2}/tests/conftest.py +0 -0
  49. {fabricatio-0.1.0 → fabricatio-0.1.2}/tests/test_models/test_events.py +0 -0
  50. {fabricatio-0.1.0 → fabricatio-0.1.2}/tests/test_models/test_utils.py +0 -0
@@ -1,58 +1,68 @@
1
- name: Build and Release
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
-
8
- jobs:
9
- check-and-release:
10
- runs-on: windows-latest
11
- steps:
12
- - name: Checkout repository
13
- uses: actions/checkout@v4
14
-
15
- - name: Install the latest version of uv
16
- uses: astral-sh/setup-uv@v5
17
- with:
18
- version: "latest"
19
-
20
- - name: Build
21
- run: |
22
- uv build
23
-
24
- - name: Get current version
25
- id: get_version
26
- run: |
27
- CURRENT_VERSION=$(grep '^version' pyproject.toml | cut -d '"' -f 2)
28
- echo "CURRENT_VERSION=v$CURRENT_VERSION" >> $GITHUB_OUTPUT
29
- shell: bash
30
- - name: Get latest tag
31
- uses: JinoArch/get-latest-tag@latest
32
- id: tag
33
-
34
- - name: Check if version has changed
35
- id: check_version_change
36
- run: |
37
- LATEST_TAG=${{ steps.tag.outputs.latestTag }}
38
- echo "Latest tag is $LATEST_TAG"
39
- echo "Current version is ${{ steps.get_version.outputs.CURRENT_VERSION }}"
40
- if [ "$LATEST_TAG" != "${{ steps.get_version.outputs.CURRENT_VERSION }}" ]; then
41
- echo "VERSION_CHANGED=true" >> $GITHUB_OUTPUT
42
- else
43
- echo "VERSION_CHANGED=false" >> $GITHUB_OUTPUT
44
- fi
45
- shell: bash
46
-
47
-
48
- - name: Create Release and upload assets
49
- if: ${{ steps.check_version_change.outputs.VERSION_CHANGED == 'true' }}
50
- id: create_release
51
- uses: softprops/action-gh-release@v2
52
- with:
53
- tag_name: ${{ steps.get_version.outputs.CURRENT_VERSION }}
54
- name: ${{ steps.get_version.outputs.CURRENT_VERSION }}
55
- files: |
56
- dist/*
57
- env:
58
- GITHUB_TOKEN: ${{ secrets.PAT }}
1
+ name: Build and Release
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+ branches:
9
+ - master
10
+
11
+ jobs:
12
+ check-and-release:
13
+ runs-on: windows-latest
14
+ steps:
15
+ - name: Checkout repository
16
+ uses: actions/checkout@v4
17
+
18
+ - name: Install the latest version of uv
19
+ uses: astral-sh/setup-uv@v5
20
+ with:
21
+ version: "latest"
22
+
23
+ - name: Build
24
+ run: |
25
+ uv build
26
+
27
+ - name: Get current version
28
+ id: get_version
29
+ run: |
30
+ CURRENT_VERSION=$(grep '^version' pyproject.toml | cut -d '"' -f 2)
31
+ echo "CURRENT_VERSION=v$CURRENT_VERSION" >> $GITHUB_OUTPUT
32
+ shell: bash
33
+ - name: Get latest tag
34
+ uses: JinoArch/get-latest-tag@latest
35
+ id: tag
36
+
37
+ - name: Check if version has changed
38
+ id: check_version_change
39
+ run: |
40
+ LATEST_TAG=${{ steps.tag.outputs.latestTag }}
41
+ echo "Latest tag is $LATEST_TAG"
42
+ echo "Current version is ${{ steps.get_version.outputs.CURRENT_VERSION }}"
43
+ if [ "$LATEST_TAG" != "${{ steps.get_version.outputs.CURRENT_VERSION }}" ]; then
44
+ echo "VERSION_CHANGED=true" >> $GITHUB_OUTPUT
45
+ else
46
+ echo "VERSION_CHANGED=false" >> $GITHUB_OUTPUT
47
+ fi
48
+ shell: bash
49
+
50
+
51
+ - name: Create Release and upload assets
52
+ if: ${{ steps.check_version_change.outputs.VERSION_CHANGED == 'true' }}
53
+ id: create_release
54
+ uses: softprops/action-gh-release@v2
55
+ with:
56
+ tag_name: ${{ steps.get_version.outputs.CURRENT_VERSION }}
57
+ name: ${{ steps.get_version.outputs.CURRENT_VERSION }}
58
+ files: |
59
+ dist/*
60
+ env:
61
+ GITHUB_TOKEN: ${{ secrets.PAT }}
62
+
63
+ - name: Upload to PyPI
64
+ if: ${{ steps.check_version_change.outputs.VERSION_CHANGED == 'true' }}
65
+ run: |
66
+ uv publish
67
+ env:
68
+ UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
@@ -0,0 +1,20 @@
1
+ name: Pre-commit checks
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - '**'
7
+ push:
8
+ branches:
9
+ - '**'
10
+
11
+ jobs:
12
+ ruff-linter:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - name: Checkout repository
16
+ uses: actions/checkout@v4
17
+ - name: Setup ruff
18
+ uses: astral-sh/ruff-action@v3
19
+ with:
20
+ github-token: ${{ secrets.PAT }}
@@ -1,11 +1,12 @@
1
- # Python-generated files
2
- __pycache__/
3
- *.py[oc]
4
- build/
5
- dist/
6
- wheels/
7
- *.egg-info
8
-
9
- # Virtual environments
10
- .venv
11
- .idea
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+ .idea
12
+ .env
@@ -1 +1 @@
1
- 3.12
1
+ 3.12
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fabricatio
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: A LLM multi-agent framework.
5
5
  Author-email: Whth <zettainspector@foxmail.com>
6
6
  License: MIT License
@@ -25,6 +25,7 @@ License: MIT License
25
25
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
26
  SOFTWARE.
27
27
  License-File: LICENSE
28
+ Keywords: agents,ai,llm,multi-agent
28
29
  Classifier: Framework :: AsyncIO
29
30
  Classifier: Framework :: Pydantic :: 2
30
31
  Classifier: License :: OSI Approved :: MIT License
@@ -36,11 +37,91 @@ Requires-Dist: aiohttp>=3.11.11
36
37
  Requires-Dist: aiomultiprocess>=0.9.1
37
38
  Requires-Dist: appdirs>=1.4.4
38
39
  Requires-Dist: asyncio>=3.4.3
40
+ Requires-Dist: gitpython>=3.1.44
39
41
  Requires-Dist: litellm>=1.60.0
40
42
  Requires-Dist: loguru>=0.7.3
43
+ Requires-Dist: orjson>=3.10.15
41
44
  Requires-Dist: pydantic-settings>=2.7.1
42
45
  Requires-Dist: pydantic>=2.10.6
43
46
  Requires-Dist: pymitter>=1.0.0
47
+ Requires-Dist: regex>=2024.11.6
44
48
  Requires-Dist: rich>=13.9.4
45
- Provides-Extra: cli
46
- Requires-Dist: typer>=0.15.1; extra == 'cli'
49
+ Requires-Dist: shutilwhich>=1.1.0
50
+ Description-Content-Type: text/markdown
51
+
52
+ ## Usage
53
+
54
+ ### Defining a Task
55
+
56
+ ```python
57
+ from fabricatio.models.task import Task
58
+
59
+ task = Task(name="say hello", goal="say hello", description="say hello to the world")
60
+ ```
61
+
62
+
63
+ ### Creating an Action
64
+
65
+ ```python
66
+ from fabricatio import Action, logger
67
+ from fabricatio.models.task import Task
68
+
69
+ class Talk(Action):
70
+ async def _execute(self, task_input: Task[str], **_) -> Any:
71
+ ret = "Hello fabricatio!"
72
+ logger.info("executing talk action")
73
+ return ret
74
+ ```
75
+
76
+
77
+ ### Assigning a Role
78
+
79
+ ```python
80
+ from fabricatio.models.role import Role
81
+ from fabricatio.models.action import WorkFlow
82
+
83
+ class TestWorkflow(WorkFlow):
84
+ pass
85
+
86
+ role = Role(name="Test Role", actions=[TestWorkflow()])
87
+ ```
88
+
89
+
90
+ ### Logging
91
+
92
+ Fabricatio uses Loguru for logging. You can configure the log level and file in the `config.py` file.
93
+
94
+ ```python
95
+ from fabricatio.config import DebugConfig
96
+
97
+ debug_config = DebugConfig(log_level="DEBUG", log_file="fabricatio.log")
98
+ ```
99
+
100
+
101
+ ## Configuration
102
+
103
+ Fabricatio uses Pydantic for configuration management. You can define your settings in the `config.py` file.
104
+
105
+ ```python
106
+ from fabricatio.config import Settings
107
+
108
+ settings = Settings(llm=LLMConfig(api_endpoint="https://api.example.com"))
109
+ ```
110
+
111
+
112
+ ## Testing
113
+
114
+ Fabricatio includes a set of tests to ensure the framework works as expected. You can run the tests using `pytest`.
115
+
116
+ ```bash
117
+ pytest
118
+ ```
119
+
120
+
121
+ ## Contributing
122
+
123
+ Contributions to Fabricatio are welcome! Please submit a pull request with your changes.
124
+
125
+ ## License
126
+
127
+ Fabricatio is licensed under the MIT License. See the [LICENSE](LICENSE) file for more information.
@@ -0,0 +1,76 @@
1
+ ## Usage
2
+
3
+ ### Defining a Task
4
+
5
+ ```python
6
+ from fabricatio.models.task import Task
7
+
8
+ task = Task(name="say hello", goal="say hello", description="say hello to the world")
9
+ ```
10
+
11
+
12
+ ### Creating an Action
13
+
14
+ ```python
15
+ from fabricatio import Action, logger
16
+ from fabricatio.models.task import Task
17
+
18
+ class Talk(Action):
19
+ async def _execute(self, task_input: Task[str], **_) -> Any:
20
+ ret = "Hello fabricatio!"
21
+ logger.info("executing talk action")
22
+ return ret
23
+ ```
24
+
25
+
26
+ ### Assigning a Role
27
+
28
+ ```python
29
+ from fabricatio.models.role import Role
30
+ from fabricatio.models.action import WorkFlow
31
+
32
+ class TestWorkflow(WorkFlow):
33
+ pass
34
+
35
+ role = Role(name="Test Role", actions=[TestWorkflow()])
36
+ ```
37
+
38
+
39
+ ### Logging
40
+
41
+ Fabricatio uses Loguru for logging. You can configure the log level and file in the `config.py` file.
42
+
43
+ ```python
44
+ from fabricatio.config import DebugConfig
45
+
46
+ debug_config = DebugConfig(log_level="DEBUG", log_file="fabricatio.log")
47
+ ```
48
+
49
+
50
+ ## Configuration
51
+
52
+ Fabricatio uses Pydantic for configuration management. You can define your settings in the `config.py` file.
53
+
54
+ ```python
55
+ from fabricatio.config import Settings
56
+
57
+ settings = Settings(llm=LLMConfig(api_endpoint="https://api.example.com"))
58
+ ```
59
+
60
+
61
+ ## Testing
62
+
63
+ Fabricatio includes a set of tests to ensure the framework works as expected. You can run the tests using `pytest`.
64
+
65
+ ```bash
66
+ pytest
67
+ ```
68
+
69
+
70
+ ## Contributing
71
+
72
+ Contributions to Fabricatio are welcome! Please submit a pull request with your changes.
73
+
74
+ ## License
75
+
76
+ Fabricatio is licensed under the MIT License. See the [LICENSE](LICENSE) file for more information.
@@ -0,0 +1,29 @@
1
+ import asyncio
2
+ from typing import Any
3
+
4
+ from fabricatio import Action, Role, Task, WorkFlow, logger
5
+
6
+ task = Task(name="say hello", goal="say hello", description="say hello to the world")
7
+
8
+
9
+ class Talk(Action):
10
+ """Action that says hello to the world."""
11
+
12
+ name: str = "talk"
13
+ output_key: str = "task_output"
14
+
15
+ async def _execute(self, task_input: Task[str], **_) -> Any:
16
+ ret = "Hello fabricatio!"
17
+ logger.info("executing talk action")
18
+ return ret
19
+
20
+
21
+ async def main() -> None:
22
+ """Main function."""
23
+ Role(name="talker", description="talker role", registry={task.pending_label: WorkFlow(name="talk", steps=(Talk,))})
24
+
25
+ logger.success(f"Result: {await task.delegate()}")
26
+
27
+
28
+ if __name__ == "__main__":
29
+ asyncio.run(main())
@@ -0,0 +1,138 @@
1
+ [project]
2
+ name = "fabricatio"
3
+ version = "0.1.2"
4
+ description = "A LLM multi-agent framework."
5
+ readme = "README.md"
6
+ license = { file = "LICENSE" }
7
+ authors = [
8
+ { name = "Whth", email = "zettainspector@foxmail.com" }
9
+ ]
10
+ classifiers = [
11
+ "License :: OSI Approved :: MIT License",
12
+ "Programming Language :: Python :: 3.12",
13
+ "Programming Language :: Python :: Implementation :: CPython",
14
+ "Framework :: AsyncIO",
15
+ "Framework :: Pydantic :: 2",
16
+ "Typing :: Typed",
17
+ ]
18
+ keywords = [
19
+ "ai",
20
+ "agents",
21
+ "multi-agent",
22
+ "llm",
23
+ ]
24
+ requires-python = ">=3.12"
25
+ dependencies = [
26
+ "aiohttp>=3.11.11",
27
+ "aiomultiprocess>=0.9.1",
28
+ "appdirs>=1.4.4",
29
+ "asyncio>=3.4.3",
30
+ "gitpython>=3.1.44",
31
+ "litellm>=1.60.0",
32
+ "loguru>=0.7.3",
33
+ "orjson>=3.10.15",
34
+ "pydantic>=2.10.6",
35
+ "pydantic-settings>=2.7.1",
36
+ "pymitter>=1.0.0",
37
+ "regex>=2024.11.6",
38
+ "rich>=13.9.4",
39
+ "shutilwhich>=1.1.0",
40
+ ]
41
+
42
+
43
+
44
+ [build-system]
45
+ requires = ["hatchling"]
46
+ build-backend = "hatchling.build"
47
+
48
+
49
+ [dependency-groups]
50
+ dev = [
51
+ "pytest>=8.3.4",
52
+ "pytest-asyncio>=0.25.3",
53
+ "pytest-cov>=6.0.0",
54
+ "pytest-env>=1.1.5",
55
+ "pytest-flake8>=1.3.0",
56
+ "pytest-mock>=3.14.0",
57
+ "pytest-rerunfailures>=15.0",
58
+ "pytest-xdist>=3.6.1",
59
+ "ruff>=0.9.4",
60
+ "uv>=0.5.29",
61
+ ]
62
+ cli = [
63
+ "typer>=0.15.1",
64
+ ]
65
+ rag = [
66
+ "faiss-cpu>=1.10.0",
67
+ "pymilvus>=2.5.4",
68
+ ]
69
+
70
+
71
+ [tool.ruff]
72
+ include = ["pyproject.toml", "src/fabricatio/*.py", "examples/*.py"]
73
+ line-length = 120
74
+ target-version = "py312"
75
+ [tool.ruff.format]
76
+ quote-style = "double" # Like Black, use double quotes for strings.
77
+
78
+ [tool.ruff.lint]
79
+ select = [
80
+ "F", # Pyflakes
81
+ "I", # isort
82
+ "N", # pep8-naming
83
+ "D", # pydocstyle
84
+ "W", # warnings
85
+ "ANN", # flake8-annotations
86
+ "ASYNC", # flake8-async
87
+ "S", # flake8-bandit
88
+ "BLE", # flake8-blind-except
89
+ "C90", # flake8-complexity
90
+ "B", # flake8-bugbear
91
+ "C4", # flake8-comprehensions
92
+ "T10", # flake8-debugger
93
+ "T20", # flake8-print
94
+ "PYI", # flake8-pyi
95
+ "PT", # flake8-pytest-style
96
+ "RET", # flake8-return
97
+ "SIM", # flake8-simplify
98
+ "TC", # flake8-type-checking
99
+ "PTH", # flake8-use-pathlib
100
+ "PLC", # convention
101
+ "PLE", # error
102
+ "PLR", # refactoring
103
+ "PLW", # warning
104
+ "RUF", # Ruff-specific rules
105
+ ]
106
+ ignore=[
107
+ "S101",
108
+ "ANN401",
109
+ "ANN003",
110
+ "D100",
111
+ "PYI063",
112
+ "ASYNC109"
113
+ ]
114
+ [tool.ruff.lint.pydocstyle]
115
+ convention = "google"
116
+ ignore-decorators = ["typing.overload"]
117
+ [tool.ruff.lint.pylint]
118
+ max-args = 15
119
+
120
+ [tool.pytest.ini_options]
121
+ addopts = "-ra -q"
122
+ testpaths = [
123
+ "tests",
124
+ ]
125
+
126
+
127
+ [[tool.uv.index]]
128
+ url = "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple"
129
+
130
+ [[tool.uv.index]]
131
+ url = "https://mirrors.huaweicloud.com/repository/pypi/simple"
132
+
133
+ [[tool.uv.index]]
134
+ url = "https://mirrors.aliyun.com/pypi/simple/"
135
+
136
+ [[tool.uv.index]]
137
+ url = "https://mirrors.bfsu.edu.cn/pypi/web/simple"
138
+ default = true
@@ -1,18 +1,24 @@
1
- from fabricatio.core import Env
2
- from fabricatio.logger import logger
3
- from fabricatio.models.action import Action, WorkFlow
4
- from fabricatio.models.events import Event
5
- from fabricatio.models.role import Role
6
- from fabricatio.models.tool import ToolBox
7
- from fabricatio.models.utils import Messages
8
-
9
- __all__ = [
10
- "Env",
11
- "logger",
12
- "Action",
13
- "Event",
14
- "Messages",
15
- "Role",
16
- "ToolBox",
17
- "WorkFlow",
18
- ]
1
+ """Fabricatio is a Python library for building llm app using event-based agent structure."""
2
+
3
+ from fabricatio.core import env
4
+ from fabricatio.journal import logger
5
+ from fabricatio.models.action import Action, WorkFlow
6
+ from fabricatio.models.events import Event
7
+ from fabricatio.models.role import Role
8
+ from fabricatio.models.task import Task
9
+ from fabricatio.models.tool import ToolBox
10
+ from fabricatio.models.utils import Messages
11
+ from fabricatio.parser import Capture
12
+
13
+ __all__ = [
14
+ "Action",
15
+ "Capture",
16
+ "Event",
17
+ "Messages",
18
+ "Role",
19
+ "Task",
20
+ "ToolBox",
21
+ "WorkFlow",
22
+ "env",
23
+ "logger",
24
+ ]