Compare commits

...

9 Commits

Author SHA1 Message Date
GabeKoga
59a5f51fd7 remove extra folder 2024-03-22 18:55:17 -03:00
GabeKoga
375946c15a Fixed: use absolute import, run main as app 2024-03-19 18:15:35 -03:00
João Moura
637bd885cf adding auto flake 2024-03-11 23:27:19 -03:00
João Moura
337afe228f cutting new version with proper imports 2024-03-11 23:27:04 -03:00
João Moura
4541835487 adding autoflake 2024-03-11 22:56:14 -03:00
João Moura
04d9603449 cutting new version 2024-03-11 22:55:56 -03:00
João Moura
671a8d0180 preparring new version that autoloads env 2024-03-11 22:19:47 -03:00
João Moura
3950878690 preparring to cut new version 2024-03-11 19:54:27 -03:00
João Moura
eaac627600 updating CLI template and guaranteeing tasks order 2024-03-11 19:53:34 -03:00
8 changed files with 30 additions and 21 deletions

View File

@@ -1,6 +1,6 @@
[tool.poetry]
name = "crewai"
version = "0.22.0"
version = "0.22.5"
description = "Cutting-edge framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks."
authors = ["Joao Moura <joao@crewai.com>"]
readme = "README.md"
@@ -26,6 +26,7 @@ instructor = "^0.5.2"
regex = "^2023.12.25"
crewai-tools = { version = "^0.0.15", optional = true }
click = "^8.1.7"
python-dotenv = "1.0.0"
[tool.poetry.extras]
tools = ["crewai-tools"]

View File

@@ -15,9 +15,8 @@ def create_crew(name):
os.mkdir(folder_name)
os.mkdir(folder_name + "/tests")
os.mkdir(folder_name + "/src")
os.mkdir(folder_name + f"/src/{folder_name}")
os.mkdir(folder_name + f"/src/{folder_name}/tools")
os.mkdir(folder_name + f"/src/{folder_name}/config")
os.mkdir(folder_name + "/src/tools")
os.mkdir(folder_name + "/src/config")
with open(folder_name + "/.env", "w") as file:
file.write("OPENAI_API_KEY=YOUR_API_KEY")
else:
@@ -47,17 +46,17 @@ def create_crew(name):
for file_name in src_template_files:
src_file = templates_dir / file_name
dst_file = Path(folder_name) / "src" / folder_name / file_name
dst_file = Path(folder_name) / "src" / file_name
copy_template(src_file, dst_file, name, class_name, folder_name)
for file_name in tools_template_files:
src_file = templates_dir / file_name
dst_file = Path(folder_name) / "src" / folder_name / file_name
dst_file = Path(folder_name) / "src" / file_name
copy_template(src_file, dst_file, name, class_name, folder_name)
for file_name in config_template_files:
src_file = templates_dir / file_name
dst_file = Path(folder_name) / "src" / folder_name / file_name
dst_file = Path(folder_name) / "src" / file_name
copy_template(src_file, dst_file, name, class_name, folder_name)
click.secho(f"Crew {name} created successfully!", fg="green", bold=True)

View File

@@ -1,7 +1,8 @@
from crewai import Agent, Crew, Process, Task
from crewai.project import CrewBase, agent, crew, task
from .tools.custom_tool import MyCustomTool
# Uncomment the following line to use an example of a custom tool
# from {{folder_name}}.tools.custom_tool import MyCustomTool
# Check our tools documentations for more information on how to use them
# from crewai_tools import SerperDevTool
@@ -16,7 +17,7 @@ class {{crew_name}}Crew():
def researcher(self) -> Agent:
return Agent(
config=self.agents_config['researcher'],
# tools=[MyCustomTool()], # Example of custom tool
# tools=[MyCustomTool()], # Example of custom tool, loaded on the beginning of file
verbose=True
)

View File

@@ -1,8 +1,13 @@
#!/usr/bin/env python
from .crew import {{crew_name}}Crew
from crew import {{crew_name}}Crew
def run():
# Replace with your inputs, it will automatically interpolate any tasks and agents information
inputs = {'topic': 'AI LLMs'}
{{crew_name}}Crew().crew().kickoff(inputs=inputs)
inputs = {
'topic': 'AI LLMs'
}
{{crew_name}}Crew().crew().kickoff(inputs=inputs)
if __name__ == "__main__":
run()

View File

@@ -6,7 +6,7 @@ authors = ["Your Name <you@example.com>"]
[tool.poetry.dependencies]
python = ">=3.10,<=3.13"
crewai = {extras = ["tools"], version = "^0.22.0"}
crewai = {extras = ["tools"], version = "^0.22.2"}
[tool.poetry.scripts]
{{folder_name}} = "{{folder_name}}.main:run"

View File

@@ -1,6 +1,3 @@
# For this make sure to install the tools package
# pip install 'crewai[tools]'
from crewai_tools import BaseTool

View File

@@ -1,5 +1,9 @@
tasks_order = []
def task(func):
func.is_task = True
tasks_order.append(func.__name__)
return func
@@ -13,11 +17,11 @@ def crew(func):
instantiated_tasks = []
instantiated_agents = []
# Instantiate tasks and collect their associated agents
agent_roles = set()
for attr_name in dir(self):
possible_task = getattr(self, attr_name)
if callable(possible_task) and hasattr(possible_task, "is_task"):
# Iterate over tasks_order to maintain the defined order
for task_name in tasks_order:
possible_task = getattr(self, task_name)
if callable(possible_task):
task_instance = possible_task()
instantiated_tasks.append(task_instance)
if hasattr(task_instance, "agent"):
@@ -38,7 +42,6 @@ def crew(func):
self.agents = instantiated_agents
self.tasks = instantiated_tasks
# Now call the original crew method
return func(self, *args, **kwargs)
return wrapper

View File

@@ -3,6 +3,9 @@ import os
from pathlib import Path
import yaml
from dotenv import load_dotenv
load_dotenv()
def CrewBase(cls):