fabricatio 0.1.0__tar.gz → 0.1.1__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.1}/.github/workflows/build-package.yaml +68 -58
  2. fabricatio-0.1.1/.github/workflows/ruff.yaml +20 -0
  3. {fabricatio-0.1.0 → fabricatio-0.1.1}/.gitignore +10 -10
  4. {fabricatio-0.1.0 → fabricatio-0.1.1}/.python-version +1 -1
  5. {fabricatio-0.1.0 → fabricatio-0.1.1}/PKG-INFO +83 -3
  6. fabricatio-0.1.1/README.md +76 -0
  7. fabricatio-0.1.1/examples/minor/hello_fabricatio.py +29 -0
  8. fabricatio-0.1.1/pyproject.toml +137 -0
  9. {fabricatio-0.1.0 → fabricatio-0.1.1}/src/fabricatio/__init__.py +24 -18
  10. fabricatio-0.1.1/src/fabricatio/config.py +196 -0
  11. {fabricatio-0.1.0 → fabricatio-0.1.1}/src/fabricatio/core.py +165 -148
  12. fabricatio-0.1.0/src/fabricatio/logger.py → fabricatio-0.1.1/src/fabricatio/journal.py +7 -2
  13. fabricatio-0.1.1/src/fabricatio/models/action.py +90 -0
  14. fabricatio-0.1.1/src/fabricatio/models/events.py +66 -0
  15. fabricatio-0.1.1/src/fabricatio/models/generic.py +399 -0
  16. fabricatio-0.1.1/src/fabricatio/models/role.py +29 -0
  17. fabricatio-0.1.1/src/fabricatio/models/task.py +220 -0
  18. {fabricatio-0.1.0 → fabricatio-0.1.1}/src/fabricatio/models/tool.py +101 -80
  19. {fabricatio-0.1.0 → fabricatio-0.1.1}/src/fabricatio/models/utils.py +10 -15
  20. fabricatio-0.1.1/src/fabricatio/parser.py +63 -0
  21. fabricatio-0.1.1/src/fabricatio/toolboxes/__init__.py +7 -0
  22. fabricatio-0.1.1/src/fabricatio/toolboxes/task.py +4 -0
  23. {fabricatio-0.1.0 → fabricatio-0.1.1}/tests/test_config.py +5 -3
  24. fabricatio-0.1.1/tests/test_core.py +94 -0
  25. fabricatio-0.1.1/tests/test_events.py +49 -0
  26. fabricatio-0.1.1/tests/test_models/test_action.py +53 -0
  27. {fabricatio-0.1.0 → fabricatio-0.1.1}/tests/test_models/test_generic.py +1 -1
  28. {fabricatio-0.1.0 → fabricatio-0.1.1}/tests/test_models/test_role.py +1 -1
  29. fabricatio-0.1.1/tests/test_models/test_tool.py +62 -0
  30. fabricatio-0.1.1/tests/test_parser.py +12 -0
  31. {fabricatio-0.1.0 → fabricatio-0.1.1}/uv.lock +1652 -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.1}/LICENSE +0 -0
  46. {fabricatio-0.1.0 → fabricatio-0.1.1}/src/fabricatio/py.typed +0 -0
  47. {fabricatio-0.1.0 → fabricatio-0.1.1}/tests/__init__.py +0 -0
  48. {fabricatio-0.1.0 → fabricatio-0.1.1}/tests/conftest.py +0 -0
  49. {fabricatio-0.1.0 → fabricatio-0.1.1}/tests/test_models/test_events.py +0 -0
  50. {fabricatio-0.1.0 → fabricatio-0.1.1}/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,11 @@
1
- # Python-generated files
2
- __pycache__/
3
- *.py[oc]
4
- build/
5
- dist/
6
- wheels/
7
- *.egg-info
8
-
9
- # Virtual environments
10
- .venv
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
11
  .idea
@@ -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.1
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,90 @@ 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
41
43
  Requires-Dist: pydantic-settings>=2.7.1
42
44
  Requires-Dist: pydantic>=2.10.6
43
45
  Requires-Dist: pymitter>=1.0.0
46
+ Requires-Dist: regex>=2024.11.6
44
47
  Requires-Dist: rich>=13.9.4
45
- Provides-Extra: cli
46
- Requires-Dist: typer>=0.15.1; extra == 'cli'
48
+ Requires-Dist: shutilwhich>=1.1.0
49
+ Description-Content-Type: text/markdown
50
+
51
+ ## Usage
52
+
53
+ ### Defining a Task
54
+
55
+ ```python
56
+ from fabricatio.models.task import Task
57
+
58
+ task = Task(name="say hello", goal="say hello", description="say hello to the world")
59
+ ```
60
+
61
+
62
+ ### Creating an Action
63
+
64
+ ```python
65
+ from fabricatio import Action, logger
66
+ from fabricatio.models.task import Task
67
+
68
+ class Talk(Action):
69
+ async def _execute(self, task_input: Task[str], **_) -> Any:
70
+ ret = "Hello fabricatio!"
71
+ logger.info("executing talk action")
72
+ return ret
73
+ ```
74
+
75
+
76
+ ### Assigning a Role
77
+
78
+ ```python
79
+ from fabricatio.models.role import Role
80
+ from fabricatio.models.action import WorkFlow
81
+
82
+ class TestWorkflow(WorkFlow):
83
+ pass
84
+
85
+ role = Role(name="Test Role", actions=[TestWorkflow()])
86
+ ```
87
+
88
+
89
+ ### Logging
90
+
91
+ Fabricatio uses Loguru for logging. You can configure the log level and file in the `config.py` file.
92
+
93
+ ```python
94
+ from fabricatio.config import DebugConfig
95
+
96
+ debug_config = DebugConfig(log_level="DEBUG", log_file="fabricatio.log")
97
+ ```
98
+
99
+
100
+ ## Configuration
101
+
102
+ Fabricatio uses Pydantic for configuration management. You can define your settings in the `config.py` file.
103
+
104
+ ```python
105
+ from fabricatio.config import Settings
106
+
107
+ settings = Settings(llm=LLMConfig(api_endpoint="https://api.example.com"))
108
+ ```
109
+
110
+
111
+ ## Testing
112
+
113
+ Fabricatio includes a set of tests to ensure the framework works as expected. You can run the tests using `pytest`.
114
+
115
+ ```bash
116
+ pytest
117
+ ```
118
+
119
+
120
+ ## Contributing
121
+
122
+ Contributions to Fabricatio are welcome! Please submit a pull request with your changes.
123
+
124
+ ## License
125
+
126
+ 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,137 @@
1
+ [project]
2
+ name = "fabricatio"
3
+ version = "0.1.1"
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
+ "pydantic>=2.10.6",
34
+ "pydantic-settings>=2.7.1",
35
+ "pymitter>=1.0.0",
36
+ "regex>=2024.11.6",
37
+ "rich>=13.9.4",
38
+ "shutilwhich>=1.1.0",
39
+ ]
40
+
41
+
42
+
43
+ [build-system]
44
+ requires = ["hatchling"]
45
+ build-backend = "hatchling.build"
46
+
47
+
48
+ [dependency-groups]
49
+ dev = [
50
+ "pytest>=8.3.4",
51
+ "pytest-asyncio>=0.25.3",
52
+ "pytest-cov>=6.0.0",
53
+ "pytest-env>=1.1.5",
54
+ "pytest-flake8>=1.3.0",
55
+ "pytest-mock>=3.14.0",
56
+ "pytest-rerunfailures>=15.0",
57
+ "pytest-xdist>=3.6.1",
58
+ "ruff>=0.9.4",
59
+ "uv>=0.5.29",
60
+ ]
61
+ cli = [
62
+ "typer>=0.15.1",
63
+ ]
64
+ rag = [
65
+ "faiss-cpu>=1.10.0",
66
+ "pymilvus>=2.5.4",
67
+ ]
68
+
69
+
70
+ [tool.ruff]
71
+ include = ["pyproject.toml", "src/fabricatio/*.py", "examples/*.py"]
72
+ line-length = 120
73
+ target-version = "py312"
74
+ [tool.ruff.format]
75
+ quote-style = "double" # Like Black, use double quotes for strings.
76
+
77
+ [tool.ruff.lint]
78
+ select = [
79
+ "F", # Pyflakes
80
+ "I", # isort
81
+ "N", # pep8-naming
82
+ "D", # pydocstyle
83
+ "W", # warnings
84
+ "ANN", # flake8-annotations
85
+ "ASYNC", # flake8-async
86
+ "S", # flake8-bandit
87
+ "BLE", # flake8-blind-except
88
+ "C90", # flake8-complexity
89
+ "B", # flake8-bugbear
90
+ "C4", # flake8-comprehensions
91
+ "T10", # flake8-debugger
92
+ "T20", # flake8-print
93
+ "PYI", # flake8-pyi
94
+ "PT", # flake8-pytest-style
95
+ "RET", # flake8-return
96
+ "SIM", # flake8-simplify
97
+ "TC", # flake8-type-checking
98
+ "PTH", # flake8-use-pathlib
99
+ "PLC", # convention
100
+ "PLE", # error
101
+ "PLR", # refactoring
102
+ "PLW", # warning
103
+ "RUF", # Ruff-specific rules
104
+ ]
105
+ ignore=[
106
+ "S101",
107
+ "ANN401",
108
+ "ANN003",
109
+ "D100",
110
+ "PYI063",
111
+ "ASYNC109"
112
+ ]
113
+ [tool.ruff.lint.pydocstyle]
114
+ convention = "google"
115
+ ignore-decorators = ["typing.overload"]
116
+ [tool.ruff.lint.pylint]
117
+ max-args = 15
118
+
119
+ [tool.pytest.ini_options]
120
+ addopts = "-ra -q"
121
+ testpaths = [
122
+ "tests",
123
+ ]
124
+
125
+
126
+ [[tool.uv.index]]
127
+ url = "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple"
128
+
129
+ [[tool.uv.index]]
130
+ url = "https://mirrors.huaweicloud.com/repository/pypi/simple"
131
+
132
+ [[tool.uv.index]]
133
+ url = "https://mirrors.aliyun.com/pypi/simple/"
134
+
135
+ [[tool.uv.index]]
136
+ url = "https://mirrors.bfsu.edu.cn/pypi/web/simple"
137
+ 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
+ ]