Restructure

This commit is contained in:
Brandon Hancock
2024-08-02 11:28:51 -04:00
parent 43e37444f3
commit 4660fb057b
18 changed files with 155 additions and 108 deletions

View File

@@ -21,7 +21,6 @@ def create_pipeline(name, router=False):
(project_root / "src" / folder_name).mkdir(parents=True)
(project_root / "src" / folder_name / "crews").mkdir(parents=True)
(project_root / "src" / folder_name / "tools").mkdir(parents=True)
(project_root / "src" / folder_name / "config").mkdir(parents=True)
(project_root / "tests").mkdir(exist_ok=True)
# Create .env file
@@ -35,12 +34,8 @@ def create_pipeline(name, router=False):
# List of template files to copy
root_template_files = [".gitignore", "pyproject.toml", "README.md"]
src_template_files = ["__init__.py", "main.py", "pipeline.py"]
tools_template_files = ["tools/custom_tool.py", "tools/__init__.py"]
config_template_files = ["config/agents.yaml", "config/tasks.yaml"]
crew_template_files = ["crews/research_crew.py", "crews/write_x_crew.py"]
if router:
crew_template_files.append("crews/write_linkedin_crew.py")
tools_template_files = ["tools/__init__.py", "tools/custom_tool.py"]
crew_folders = ["research_crew", "write_x_crew", "write_linkedin_crew"]
def process_file(src_file, dst_file):
with open(src_file, "r") as file:
@@ -66,16 +61,22 @@ def create_pipeline(name, router=False):
dst_file = project_root / "src" / folder_name / file_name
process_file(src_file, dst_file)
# Copy tools and config files
for file_name in tools_template_files + config_template_files:
# Copy tools files
for file_name in tools_template_files:
src_file = templates_dir / file_name
dst_file = project_root / "src" / folder_name / file_name
shutil.copy(src_file, dst_file)
# Copy and process crew files
for file_name in crew_template_files:
src_file = templates_dir / file_name
dst_file = project_root / "src" / folder_name / file_name
process_file(src_file, dst_file)
# Copy crew folders
for crew_folder in crew_folders:
src_crew_folder = templates_dir / "crews" / crew_folder
dst_crew_folder = project_root / "src" / folder_name / "crews" / crew_folder
if src_crew_folder.exists():
shutil.copytree(src_crew_folder, dst_crew_folder)
else:
click.secho(
f"Warning: Crew folder {crew_folder} not found in template.",
fg="yellow",
)
click.secho(f"Pipeline {name} created successfully!", fg="green", bold=True)