multiagent-init 0.1.0__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.
- multiagent_init-0.1.0/LICENSE +21 -0
- multiagent_init-0.1.0/PKG-INFO +147 -0
- multiagent_init-0.1.0/README.md +126 -0
- multiagent_init-0.1.0/pyproject.toml +37 -0
- multiagent_init-0.1.0/setup.cfg +4 -0
- multiagent_init-0.1.0/src/multiagent_init/__init__.py +1 -0
- multiagent_init-0.1.0/src/multiagent_init/cli.py +38 -0
- multiagent_init-0.1.0/src/multiagent_init/generator.py +315 -0
- multiagent_init-0.1.0/src/multiagent_init/templates_data.py +370 -0
- multiagent_init-0.1.0/src/multiagent_init/wizard.py +175 -0
- multiagent_init-0.1.0/src/multiagent_init.egg-info/PKG-INFO +147 -0
- multiagent_init-0.1.0/src/multiagent_init.egg-info/SOURCES.txt +16 -0
- multiagent_init-0.1.0/src/multiagent_init.egg-info/dependency_links.txt +1 -0
- multiagent_init-0.1.0/src/multiagent_init.egg-info/entry_points.txt +2 -0
- multiagent_init-0.1.0/src/multiagent_init.egg-info/requires.txt +1 -0
- multiagent_init-0.1.0/src/multiagent_init.egg-info/top_level.txt +1 -0
- multiagent_init-0.1.0/tests/test_generator.py +96 -0
- multiagent_init-0.1.0/tests/test_wizard.py +22 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mandavilli. Pavan sekhar
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: multiagent-init
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Interactive CLI for generating multi-agent AI project boilerplates.
|
|
5
|
+
Author-email: Pavan Sekhar Mandavilli <pavanmandavilli2004@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/Pavanmandavilli/multiagent-init
|
|
8
|
+
Project-URL: Repository, https://github.com/Pavanmandavilli/multiagent-init
|
|
9
|
+
Project-URL: Issues, https://github.com/Pavanmandavilli/multiagent-init/issues
|
|
10
|
+
Keywords: multi-agent,agents,ai,scaffolding,cli,generator
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Requires-Python: >=3.9
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: questionary<3.0.0,>=2.0.0
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
|
|
22
|
+
# 🚀 MultiAgent Init
|
|
23
|
+
|
|
24
|
+
Interactive CLI for generating a clean multi-agent AI project.
|
|
25
|
+
|
|
26
|
+
## Install
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install multiagent-init
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Run
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
multiagent-init
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Wizard
|
|
39
|
+
|
|
40
|
+
The CLI asks for:
|
|
41
|
+
|
|
42
|
+
1. Project name
|
|
43
|
+
2. Framework
|
|
44
|
+
3. Model provider
|
|
45
|
+
4. Number of agents
|
|
46
|
+
5. Default or custom agents
|
|
47
|
+
6. Optional tools
|
|
48
|
+
7. Optional tests
|
|
49
|
+
8. Optional Docker
|
|
50
|
+
|
|
51
|
+
### Example
|
|
52
|
+
|
|
53
|
+
```text
|
|
54
|
+
🚀 MultiAgent Init
|
|
55
|
+
|
|
56
|
+
? Project name: research-team
|
|
57
|
+
|
|
58
|
+
? Select a framework:
|
|
59
|
+
❯ Basic
|
|
60
|
+
LangGraph
|
|
61
|
+
CrewAI
|
|
62
|
+
AutoGen
|
|
63
|
+
|
|
64
|
+
? Select model provider:
|
|
65
|
+
❯ OpenAI
|
|
66
|
+
Anthropic
|
|
67
|
+
Google
|
|
68
|
+
|
|
69
|
+
? Number of agents:
|
|
70
|
+
❯ 3
|
|
71
|
+
2
|
|
72
|
+
4
|
|
73
|
+
5
|
|
74
|
+
Custom
|
|
75
|
+
|
|
76
|
+
? Agent configuration:
|
|
77
|
+
❯ Default agents
|
|
78
|
+
Custom agents
|
|
79
|
+
|
|
80
|
+
? Agent 1 name: Market Researcher
|
|
81
|
+
? Agent 2 name: Data Analyst
|
|
82
|
+
? Agent 3 name: Report Writer
|
|
83
|
+
|
|
84
|
+
? Include tools? Yes
|
|
85
|
+
? Include tests? Yes
|
|
86
|
+
? Include Docker? No
|
|
87
|
+
|
|
88
|
+
Creating project...
|
|
89
|
+
|
|
90
|
+
✓ Agents
|
|
91
|
+
✓ Workflow
|
|
92
|
+
✓ Tools
|
|
93
|
+
✓ Configuration
|
|
94
|
+
✓ Tests
|
|
95
|
+
✓ README
|
|
96
|
+
|
|
97
|
+
🎉 Done!
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Generated project
|
|
101
|
+
|
|
102
|
+
Custom agent names are converted into safe Python filenames and class names.
|
|
103
|
+
|
|
104
|
+
Example:
|
|
105
|
+
|
|
106
|
+
```text
|
|
107
|
+
Market Researcher → market_researcher.py → MarketResearcherAgent
|
|
108
|
+
Data Analyst → data_analyst.py → DataAnalystAgent
|
|
109
|
+
Report Writer → report_writer.py → ReportWriterAgent
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Development
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
python3 -m venv .venv
|
|
116
|
+
source .venv/bin/activate
|
|
117
|
+
python -m pip install -e .
|
|
118
|
+
python -m unittest discover -s tests -v
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Build:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
python -m pip install --upgrade build
|
|
125
|
+
python -m build
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Publish
|
|
129
|
+
|
|
130
|
+
TestPyPI:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
python -m pip install --upgrade twine
|
|
134
|
+
python -m twine upload --repository testpypi dist/*
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
PyPI:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
python -m twine upload dist/*
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
For CI/CD, configure PyPI Trusted Publishing with GitHub Actions.
|
|
144
|
+
|
|
145
|
+
## License
|
|
146
|
+
|
|
147
|
+
MIT
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# 🚀 MultiAgent Init
|
|
2
|
+
|
|
3
|
+
Interactive CLI for generating a clean multi-agent AI project.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install multiagent-init
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Run
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
multiagent-init
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Wizard
|
|
18
|
+
|
|
19
|
+
The CLI asks for:
|
|
20
|
+
|
|
21
|
+
1. Project name
|
|
22
|
+
2. Framework
|
|
23
|
+
3. Model provider
|
|
24
|
+
4. Number of agents
|
|
25
|
+
5. Default or custom agents
|
|
26
|
+
6. Optional tools
|
|
27
|
+
7. Optional tests
|
|
28
|
+
8. Optional Docker
|
|
29
|
+
|
|
30
|
+
### Example
|
|
31
|
+
|
|
32
|
+
```text
|
|
33
|
+
🚀 MultiAgent Init
|
|
34
|
+
|
|
35
|
+
? Project name: research-team
|
|
36
|
+
|
|
37
|
+
? Select a framework:
|
|
38
|
+
❯ Basic
|
|
39
|
+
LangGraph
|
|
40
|
+
CrewAI
|
|
41
|
+
AutoGen
|
|
42
|
+
|
|
43
|
+
? Select model provider:
|
|
44
|
+
❯ OpenAI
|
|
45
|
+
Anthropic
|
|
46
|
+
Google
|
|
47
|
+
|
|
48
|
+
? Number of agents:
|
|
49
|
+
❯ 3
|
|
50
|
+
2
|
|
51
|
+
4
|
|
52
|
+
5
|
|
53
|
+
Custom
|
|
54
|
+
|
|
55
|
+
? Agent configuration:
|
|
56
|
+
❯ Default agents
|
|
57
|
+
Custom agents
|
|
58
|
+
|
|
59
|
+
? Agent 1 name: Market Researcher
|
|
60
|
+
? Agent 2 name: Data Analyst
|
|
61
|
+
? Agent 3 name: Report Writer
|
|
62
|
+
|
|
63
|
+
? Include tools? Yes
|
|
64
|
+
? Include tests? Yes
|
|
65
|
+
? Include Docker? No
|
|
66
|
+
|
|
67
|
+
Creating project...
|
|
68
|
+
|
|
69
|
+
✓ Agents
|
|
70
|
+
✓ Workflow
|
|
71
|
+
✓ Tools
|
|
72
|
+
✓ Configuration
|
|
73
|
+
✓ Tests
|
|
74
|
+
✓ README
|
|
75
|
+
|
|
76
|
+
🎉 Done!
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Generated project
|
|
80
|
+
|
|
81
|
+
Custom agent names are converted into safe Python filenames and class names.
|
|
82
|
+
|
|
83
|
+
Example:
|
|
84
|
+
|
|
85
|
+
```text
|
|
86
|
+
Market Researcher → market_researcher.py → MarketResearcherAgent
|
|
87
|
+
Data Analyst → data_analyst.py → DataAnalystAgent
|
|
88
|
+
Report Writer → report_writer.py → ReportWriterAgent
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Development
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
python3 -m venv .venv
|
|
95
|
+
source .venv/bin/activate
|
|
96
|
+
python -m pip install -e .
|
|
97
|
+
python -m unittest discover -s tests -v
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Build:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
python -m pip install --upgrade build
|
|
104
|
+
python -m build
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Publish
|
|
108
|
+
|
|
109
|
+
TestPyPI:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
python -m pip install --upgrade twine
|
|
113
|
+
python -m twine upload --repository testpypi dist/*
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
PyPI:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
python -m twine upload dist/*
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
For CI/CD, configure PyPI Trusted Publishing with GitHub Actions.
|
|
123
|
+
|
|
124
|
+
## License
|
|
125
|
+
|
|
126
|
+
MIT
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "multiagent-init"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Interactive CLI for generating multi-agent AI project boilerplates."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
authors = [{name = "Pavan Sekhar Mandavilli", email = "pavanmandavilli2004@gmail.com"}]
|
|
13
|
+
keywords = ["multi-agent", "agents", "ai", "scaffolding", "cli", "generator"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3 :: Only"
|
|
20
|
+
]
|
|
21
|
+
dependencies = [
|
|
22
|
+
"questionary>=2.0.0,<3.0.0"
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[project.urls]
|
|
26
|
+
Homepage = "https://github.com/Pavanmandavilli/multiagent-init"
|
|
27
|
+
Repository = "https://github.com/Pavanmandavilli/multiagent-init"
|
|
28
|
+
Issues = "https://github.com/Pavanmandavilli/multiagent-init/issues"
|
|
29
|
+
|
|
30
|
+
[project.scripts]
|
|
31
|
+
multiagent-init = "multiagent_init.cli:main"
|
|
32
|
+
|
|
33
|
+
[tool.setuptools]
|
|
34
|
+
package-dir = {"" = "src"}
|
|
35
|
+
|
|
36
|
+
[tool.setuptools.packages.find]
|
|
37
|
+
where = ["src"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
from .generator import generate_project
|
|
6
|
+
from .wizard import run_wizard
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def main() -> int:
|
|
10
|
+
try:
|
|
11
|
+
config = run_wizard()
|
|
12
|
+
destination = generate_project(config)
|
|
13
|
+
|
|
14
|
+
print()
|
|
15
|
+
print("🎉 Done!")
|
|
16
|
+
print()
|
|
17
|
+
print("Next steps:")
|
|
18
|
+
print()
|
|
19
|
+
print(f" cd {destination.name}")
|
|
20
|
+
print(" python3 -m venv .venv")
|
|
21
|
+
print(" source .venv/bin/activate # macOS/Linux")
|
|
22
|
+
print(" pip install .")
|
|
23
|
+
print(" python main.py")
|
|
24
|
+
print()
|
|
25
|
+
|
|
26
|
+
return 0
|
|
27
|
+
|
|
28
|
+
except KeyboardInterrupt:
|
|
29
|
+
print("\n\nCancelled.")
|
|
30
|
+
return 130
|
|
31
|
+
|
|
32
|
+
except (ValueError, FileExistsError, OSError) as exc:
|
|
33
|
+
print(f"\nError: {exc}", file=sys.stderr)
|
|
34
|
+
return 1
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
if __name__ == "__main__":
|
|
38
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from .templates_data import (
|
|
7
|
+
AGENT_TEMPLATES,
|
|
8
|
+
CONFIG_TEMPLATE,
|
|
9
|
+
DOCKER_FILE,
|
|
10
|
+
FRAMEWORK_FILES,
|
|
11
|
+
ORCHESTRATOR_TEMPLATES,
|
|
12
|
+
PROVIDER_ENV_VARS,
|
|
13
|
+
TEST_TEMPLATE,
|
|
14
|
+
TOOL_FILE,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
DEFAULT_AGENT_CLASSES = {
|
|
18
|
+
"Researcher": "ResearcherAgent",
|
|
19
|
+
"Writer": "WriterAgent",
|
|
20
|
+
"Reviewer": "ReviewerAgent",
|
|
21
|
+
"Planner": "PlannerAgent",
|
|
22
|
+
"Executor": "ExecutorAgent",
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _safe_project_name(value: str) -> str:
|
|
27
|
+
value = value.strip()
|
|
28
|
+
|
|
29
|
+
if not value:
|
|
30
|
+
raise ValueError("project name cannot be empty")
|
|
31
|
+
|
|
32
|
+
if not re.fullmatch(r"[A-Za-z0-9][A-Za-z0-9_-]*", value):
|
|
33
|
+
raise ValueError("invalid project name")
|
|
34
|
+
|
|
35
|
+
return value
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _safe_package_name(project_name: str) -> str:
|
|
39
|
+
value = re.sub(r"[^A-Za-z0-9_]", "_", project_name).lower()
|
|
40
|
+
|
|
41
|
+
if value[0].isdigit():
|
|
42
|
+
value = f"_{value}"
|
|
43
|
+
|
|
44
|
+
return value
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def agent_to_module(name: str) -> str:
|
|
48
|
+
value = re.sub(r"[^A-Za-z0-9]+", "_", name.strip())
|
|
49
|
+
value = re.sub(r"_+", "_", value).strip("_").lower()
|
|
50
|
+
|
|
51
|
+
if not value:
|
|
52
|
+
value = "agent"
|
|
53
|
+
|
|
54
|
+
if value[0].isdigit():
|
|
55
|
+
value = f"agent_{value}"
|
|
56
|
+
|
|
57
|
+
return value
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def agent_to_class(name: str) -> str:
|
|
61
|
+
parts = re.findall(r"[A-Za-z0-9]+", name.strip())
|
|
62
|
+
|
|
63
|
+
if not parts:
|
|
64
|
+
return "Agent"
|
|
65
|
+
|
|
66
|
+
class_name = "".join(part.capitalize() for part in parts)
|
|
67
|
+
|
|
68
|
+
if class_name[0].isdigit():
|
|
69
|
+
class_name = f"Agent{class_name}"
|
|
70
|
+
|
|
71
|
+
return f"{class_name}Agent"
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _write(path: Path, content: str) -> None:
|
|
75
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
76
|
+
path.write_text(content, encoding="utf-8")
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def generate_project(config: dict) -> Path:
|
|
80
|
+
project_name = _safe_project_name(config["project_name"])
|
|
81
|
+
package_name = _safe_package_name(project_name)
|
|
82
|
+
destination = Path.cwd() / project_name
|
|
83
|
+
|
|
84
|
+
if destination.exists():
|
|
85
|
+
if not destination.is_dir():
|
|
86
|
+
raise FileExistsError(f"'{project_name}' already exists and is not a directory")
|
|
87
|
+
|
|
88
|
+
if any(destination.iterdir()):
|
|
89
|
+
raise FileExistsError(
|
|
90
|
+
f"directory '{project_name}' already exists and is not empty"
|
|
91
|
+
)
|
|
92
|
+
else:
|
|
93
|
+
destination.mkdir(parents=True)
|
|
94
|
+
|
|
95
|
+
package_dir = destination / "src" / package_name
|
|
96
|
+
|
|
97
|
+
framework_pyproject = FRAMEWORK_FILES[config["framework"]]
|
|
98
|
+
framework_pyproject = framework_pyproject.replace("{{PROJECT_NAME}}", project_name)
|
|
99
|
+
framework_pyproject = framework_pyproject.replace("{{PACKAGE_NAME}}", package_name)
|
|
100
|
+
|
|
101
|
+
_write(destination / "pyproject.toml", framework_pyproject)
|
|
102
|
+
|
|
103
|
+
_write(
|
|
104
|
+
destination / "README.md",
|
|
105
|
+
_render_readme(config, package_name),
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
provider_env_var = PROVIDER_ENV_VARS[config["provider"]]
|
|
109
|
+
|
|
110
|
+
_write(
|
|
111
|
+
destination / ".env",
|
|
112
|
+
f"MODEL_NAME=your-model\n{provider_env_var}=\n",
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
_write(
|
|
116
|
+
destination / ".gitignore",
|
|
117
|
+
"__pycache__/\n*.py[cod]\n.venv/\n.env\n.pytest_cache/\n",
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
_write(package_dir / "__init__.py", '"""Generated package."""\n')
|
|
121
|
+
|
|
122
|
+
config_content = CONFIG_TEMPLATE.replace("{{PROVIDER_ENV_VAR}}", provider_env_var)
|
|
123
|
+
config_content = config_content.replace("{{PROVIDER}}", config["provider"])
|
|
124
|
+
_write(package_dir / "config.py", config_content)
|
|
125
|
+
|
|
126
|
+
agent_template = AGENT_TEMPLATES.get(config["framework"], AGENT_TEMPLATES["basic"])
|
|
127
|
+
orchestrator_template = ORCHESTRATOR_TEMPLATES.get(
|
|
128
|
+
config["framework"], ORCHESTRATOR_TEMPLATES["basic"]
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
agent_files = []
|
|
132
|
+
|
|
133
|
+
for agent_name in config["agent_names"]:
|
|
134
|
+
module_name = agent_to_module(agent_name)
|
|
135
|
+
class_name = agent_to_class(agent_name)
|
|
136
|
+
|
|
137
|
+
agent_files.append(
|
|
138
|
+
{
|
|
139
|
+
"name": agent_name,
|
|
140
|
+
"module": module_name,
|
|
141
|
+
"class": class_name,
|
|
142
|
+
}
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
content = agent_template
|
|
146
|
+
content = content.replace("{{AGENT_NAME}}", agent_name)
|
|
147
|
+
content = content.replace("{{AGENT_CLASS}}", class_name)
|
|
148
|
+
|
|
149
|
+
_write(
|
|
150
|
+
package_dir / "agents" / f"{module_name}.py",
|
|
151
|
+
content,
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
_write(
|
|
155
|
+
package_dir / "agents" / "__init__.py",
|
|
156
|
+
'"""Generated agents."""\n',
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
imports = "\n".join(
|
|
160
|
+
f"from {package_name}.agents.{item['module']} import {item['class']}"
|
|
161
|
+
for item in agent_files
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
instances = ",\n ".join(
|
|
165
|
+
f"{item['class']}()"
|
|
166
|
+
for item in agent_files
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
main_content = f"""from __future__ import annotations
|
|
170
|
+
|
|
171
|
+
import logging
|
|
172
|
+
|
|
173
|
+
{imports}
|
|
174
|
+
|
|
175
|
+
from {package_name} import config
|
|
176
|
+
from {package_name}.workflow.orchestrator import Orchestrator
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def main() -> None:
|
|
180
|
+
logging.basicConfig(
|
|
181
|
+
level=logging.INFO,
|
|
182
|
+
format="%(asctime)s %(levelname)s %(name)s: %(message)s",
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
config.validate()
|
|
186
|
+
|
|
187
|
+
agents = [
|
|
188
|
+
{instances}
|
|
189
|
+
]
|
|
190
|
+
|
|
191
|
+
orchestrator = Orchestrator(agents)
|
|
192
|
+
|
|
193
|
+
result = orchestrator.run(
|
|
194
|
+
"Build a short report about multi-agent systems."
|
|
195
|
+
)
|
|
196
|
+
|
|
197
|
+
print("\\n=== Final result ===")
|
|
198
|
+
print(result)
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
if __name__ == "__main__":
|
|
202
|
+
main()
|
|
203
|
+
"""
|
|
204
|
+
|
|
205
|
+
_write(destination / "main.py", main_content)
|
|
206
|
+
|
|
207
|
+
_write(
|
|
208
|
+
package_dir / "workflow" / "__init__.py",
|
|
209
|
+
'"""Workflow and orchestration."""\n',
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
_write(
|
|
213
|
+
package_dir / "workflow" / "orchestrator.py",
|
|
214
|
+
orchestrator_template,
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
if config["include_tools"]:
|
|
218
|
+
_write(
|
|
219
|
+
package_dir / "tools" / "__init__.py",
|
|
220
|
+
'"""Tools available to agents."""\n',
|
|
221
|
+
)
|
|
222
|
+
_write(package_dir / "tools" / "web_search.py", TOOL_FILE)
|
|
223
|
+
|
|
224
|
+
if config["include_tests"]:
|
|
225
|
+
test_content = TEST_TEMPLATE.replace(
|
|
226
|
+
"{{TEST_IMPORTS}}",
|
|
227
|
+
"\n".join(
|
|
228
|
+
f"from {package_name}.agents.{item['module']} import {item['class']}"
|
|
229
|
+
for item in agent_files
|
|
230
|
+
),
|
|
231
|
+
)
|
|
232
|
+
|
|
233
|
+
assertions = "\n".join(
|
|
234
|
+
f' self.assertIn("{item["name"]}", {item["class"]}().run(task))'
|
|
235
|
+
for item in agent_files
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
test_content = test_content.replace("{{ASSERTIONS}}", assertions)
|
|
239
|
+
|
|
240
|
+
_write(
|
|
241
|
+
destination / "tests" / "test_agents.py",
|
|
242
|
+
test_content,
|
|
243
|
+
)
|
|
244
|
+
|
|
245
|
+
if config["include_docker"]:
|
|
246
|
+
docker_content = DOCKER_FILE.replace("{{PACKAGE_NAME}}", package_name)
|
|
247
|
+
_write(destination / "Dockerfile", docker_content)
|
|
248
|
+
|
|
249
|
+
print()
|
|
250
|
+
print("Creating project...")
|
|
251
|
+
print()
|
|
252
|
+
print("✓ Agents")
|
|
253
|
+
print("✓ Workflow")
|
|
254
|
+
|
|
255
|
+
if config["include_tools"]:
|
|
256
|
+
print("✓ Tools")
|
|
257
|
+
|
|
258
|
+
print("✓ Configuration")
|
|
259
|
+
|
|
260
|
+
if config["include_tests"]:
|
|
261
|
+
print("✓ Tests")
|
|
262
|
+
|
|
263
|
+
if config["include_docker"]:
|
|
264
|
+
print("✓ Docker")
|
|
265
|
+
|
|
266
|
+
print("✓ README")
|
|
267
|
+
|
|
268
|
+
return destination
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
def _render_readme(config: dict, package_name: str) -> str:
|
|
272
|
+
agents = "\n".join(
|
|
273
|
+
f"- `{name}`"
|
|
274
|
+
for name in config["agent_names"]
|
|
275
|
+
)
|
|
276
|
+
|
|
277
|
+
return f"""# {config["project_name"]}
|
|
278
|
+
|
|
279
|
+
Generated by **multiagent-init**.
|
|
280
|
+
|
|
281
|
+
## Configuration
|
|
282
|
+
|
|
283
|
+
- Framework: `{config["framework"]}`
|
|
284
|
+
- Model provider: `{config["provider"]}`
|
|
285
|
+
- Agent configuration: `{config["agent_mode"]}`
|
|
286
|
+
- Number of agents: `{config["agent_count"]}`
|
|
287
|
+
|
|
288
|
+
## Agents
|
|
289
|
+
|
|
290
|
+
{agents}
|
|
291
|
+
|
|
292
|
+
## Structure
|
|
293
|
+
|
|
294
|
+
```text
|
|
295
|
+
src/{package_name}/
|
|
296
|
+
agents/ Individual agents
|
|
297
|
+
workflow/ Orchestration
|
|
298
|
+
tools/ Optional tools
|
|
299
|
+
config.py Configuration
|
|
300
|
+
tests/ Optional tests
|
|
301
|
+
main.py Entry point (python main.py)
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
## Run
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
pip install .
|
|
308
|
+
python main.py
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
Set your provider's API key in `.env` before running - `config.validate()` fails
|
|
312
|
+
fast with a clear error if it's missing.
|
|
313
|
+
|
|
314
|
+
Replace the placeholder agent logic with your actual LLM/framework implementation.
|
|
315
|
+
"""
|