Compare commits

..

4 Commits

Author SHA1 Message Date
Eduardo Chiarotti
54208c340b docs: change docs to address crewai run 2024-08-07 20:30:34 -03:00
Eduardo Chiarotti
5761d1a8ae feat: change pyprojet to run_Crew 2024-08-06 21:13:34 -03:00
Eduardo Chiarotti
3a3b19c792 feat: change command to run_crew 2024-08-06 21:11:49 -03:00
Eduardo Chiarotti
27874bac14 feat: add cli to run the crew 2024-08-06 20:22:35 -03:00
20 changed files with 62 additions and 15939 deletions

View File

@@ -1,35 +0,0 @@
---
name: Bug report
about: Create a report to help us improve CrewAI
title: "[BUG]"
labels: bug
assignees: ''
---
**Description**
Provide a clear and concise description of what the bug is.
**Steps to Reproduce**
Provide a step-by-step process to reproduce the behavior:
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots/Code snippets**
If applicable, add screenshots or code snippets to help explain your problem.
**Environment Details:**
- **Operating System**: [e.g., Ubuntu 20.04, macOS Catalina, Windows 10]
- **Python Version**: [e.g., 3.8, 3.9, 3.10]
- **crewAI Version**: [e.g., 0.30.11]
- **crewAI Tools Version**: [e.g., 0.2.6]
**Logs**
Include relevant logs or error messages if applicable.
**Possible Solution**
Have a solution in mind? Please suggest it here, or write "None".
**Additional context**
Add any other context about the problem here.

View File

@@ -1,21 +0,0 @@
---
name: Feature request
about: Suggest a Feature to improve CrewAI
title: "[FEAT]"
labels: feature-request, improvement
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
If possible attach the Issue related to it
**Describe the solution you'd like / Use-case**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

View File

@@ -1,26 +0,0 @@
name: Mark stale issues and pull requests
on:
schedule:
- cron: '10 12 * * *'
workflow_dispatch:
jobs:
stale:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v9
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-label: 'no-issue-activity'
stale-issue-message: 'This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.'
close-issue-message: 'This issue was closed because it has been stalled for 5 days with no activity.'
days-before-issue-stale: 30
days-before-issue-close: 5
stale-pr-label: 'no-pr-activity'
stale-pr-message: 'This PR is stale because it has been open for 45 days with no activity.'
days-before-pr-stale: 45
days-before-pr-close: -1

View File

@@ -126,7 +126,7 @@ task2 = Task(
crew = Crew(
agents=[researcher, writer],
tasks=[task1, task2],
verbose=True,
verbose=2, # You can set it to 1 or 2 to different logging levels
process = Process.sequential
)

View File

@@ -134,7 +134,7 @@ Once a crew has been executed, its output can be accessed through the `output` a
crew = Crew(
agents=[research_agent, writer_agent],
tasks=[research_task, write_article_task],
verbose=True
verbose=2
)
crew_output = crew.kickoff()

View File

@@ -90,7 +90,7 @@ task = Task(
crew = Crew(
agents=[research_agent],
tasks=[task],
verbose=True
verbose=2
)
result = crew.kickoff()
@@ -142,7 +142,7 @@ task = Task(
crew = Crew(
agents=[research_agent],
tasks=[task],
verbose=True
verbose=2
)
result = crew.kickoff()
@@ -264,7 +264,7 @@ task1 = Task(
crew = Crew(
agents=[research_agent],
tasks=[task1, task2, task3],
verbose=True
verbose=2
)
result = crew.kickoff()

View File

@@ -84,7 +84,7 @@ write = Task(
crew = Crew(
agents=[researcher, writer],
tasks=[research, write],
verbose=True
verbose=2
)
# Execute tasks

View File

@@ -79,7 +79,7 @@ task3 = Task(
crew = Crew(
agents=[data_fetcher_agent, data_processor_agent, summary_generator_agent],
tasks=[task1, conditional_task, task3],
verbose=True,
verbose=2,
)
result = crew.kickoff()

View File

@@ -81,7 +81,7 @@ task2 = Task(
crew = Crew(
agents=[researcher, writer],
tasks=[task1, task2],
verbose=True,
verbose=2,
memory=True,
)

View File

@@ -74,7 +74,7 @@ task = Task(description="""what is 3 + 5""",
crew = Crew(
agents=[general_agent],
tasks=[task],
verbose=True
verbose=2
)
result = crew.kickoff()

View File

@@ -158,7 +158,7 @@ class BaseAgent(ABC, BaseModel):
@model_validator(mode="after")
def set_private_attrs(self):
"""Set private attributes."""
self._logger = Logger(verbose=self.verbose)
self._logger = Logger(self.verbose)
if self.max_rpm and not self._rpm_controller:
self._rpm_controller = RPMController(
max_rpm=self.max_rpm, logger=self._logger

View File

@@ -51,7 +51,7 @@ class CrewAgentExecutor(AgentExecutor, CrewAgentExecutorMixin):
system_template: Optional[str] = None
prompt_template: Optional[str] = None
response_template: Optional[str] = None
_logger: Logger = Logger()
_logger: Logger = Logger(verbose_level=2)
_fit_context_window_strategy: Optional[Literal["summarize"]] = "summarize"
def _call(

View File

@@ -48,6 +48,6 @@ class {{crew_name}}Crew():
agents=self.agents, # Automatically created by the @agent decorator
tasks=self.tasks, # Automatically created by the @task decorator
process=Process.sequential,
verbose=True,
verbose=2,
# process=Process.hierarchical, # In case you wanna use that instead https://docs.crewai.com/how-to/Hierarchical/
)

View File

@@ -102,7 +102,7 @@ class Crew(BaseModel):
tasks: List[Task] = Field(default_factory=list)
agents: List[BaseAgent] = Field(default_factory=list)
process: Process = Field(default=Process.sequential)
verbose: bool = Field(default=False)
verbose: Union[int, bool] = Field(default=0)
memory: bool = Field(
default=False,
description="Whether the crew should use memory to store memories of it's execution",
@@ -196,7 +196,7 @@ class Crew(BaseModel):
def set_private_attrs(self) -> "Crew":
"""Set private attributes."""
self._cache_handler = CacheHandler()
self._logger = Logger(verbose=self.verbose)
self._logger = Logger(self.verbose)
if self.output_log_file:
self._file_handler = FileHandler(self.output_log_file)
self._rpm_controller = RPMController(max_rpm=self.max_rpm, logger=self._logger)

View File

@@ -6,11 +6,15 @@ from crewai.utilities.printer import Printer
class Logger:
_printer = Printer()
def __init__(self, verbose=False):
self.verbose = verbose
def __init__(self, verbose_level=0):
verbose_level = (
2 if isinstance(verbose_level, bool) and verbose_level else verbose_level
)
self.verbose_level = verbose_level
def log(self, level, message, color="bold_green"):
if self.verbose:
level_map = {"debug": 1, "info": 2}
if self.verbose_level and level_map.get(level, 0) <= self.verbose_level:
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
self._printer.print(
f"[{timestamp}][{level.upper()}]: {message}", color=color

View File

@@ -470,7 +470,7 @@ def test_agent_respect_the_max_rpm_set_over_crew_rpm(capsys):
agent=agent,
)
crew = Crew(agents=[agent], tasks=[task], max_rpm=1, verbose=True)
crew = Crew(agents=[agent], tasks=[task], max_rpm=1, verbose=2)
with patch.object(RPMController, "_wait_for_next_minute") as moveon:
moveon.return_value = True
@@ -522,7 +522,7 @@ def test_agent_without_max_rpm_respet_crew_rpm(capsys):
),
]
crew = Crew(agents=[agent1, agent2], tasks=tasks, max_rpm=1, verbose=True)
crew = Crew(agents=[agent1, agent2], tasks=tasks, max_rpm=1, verbose=2)
with patch.object(RPMController, "_wait_for_next_minute") as moveon:
moveon.return_value = True
@@ -563,7 +563,7 @@ def test_agent_error_on_parsing_tool(capsys):
crew = Crew(
agents=[agent1],
tasks=tasks,
verbose=True,
verbose=2,
function_calling_llm=ChatOpenAI(model="gpt-4-0125-preview"),
)
@@ -602,7 +602,7 @@ def test_agent_remembers_output_format_after_using_tools_too_many_times():
)
]
crew = Crew(agents=[agent1], tasks=tasks, verbose=True)
crew = Crew(agents=[agent1], tasks=tasks, verbose=2)
with patch.object(ToolUsage, "_remember_format") as remember_format:
crew.kickoff()

File diff suppressed because it is too large Load Diff

View File

@@ -449,13 +449,45 @@ def test_crew_verbose_output(capsys):
assert expected_string in captured.out
# Now test with verbose set to False
crew.verbose = False
crew._logger = Logger(verbose=False)
crew._logger = Logger(verbose_level=False)
crew.kickoff()
captured = capsys.readouterr()
assert captured.out == ""
@pytest.mark.vcr(filter_headers=["authorization"])
def test_crew_verbose_levels_output(capsys):
tasks = [
Task(
description="Write about AI advancements.",
expected_output="A 4 paragraph article about AI.",
agent=researcher,
)
]
crew = Crew(agents=[researcher], tasks=tasks, process=Process.sequential, verbose=1)
crew.kickoff()
captured = capsys.readouterr()
expected_strings = ["Working Agent: Researcher", "[Researcher] Task output:"]
for expected_string in expected_strings:
assert expected_string in captured.out
# Now test with verbose set to 2
crew._logger = Logger(verbose_level=2)
crew.kickoff()
captured = capsys.readouterr()
expected_strings = [
"Working Agent: Researcher",
"Starting Task: Write about AI advancements.",
"[Researcher] Task output:",
]
for expected_string in expected_strings:
assert expected_string in captured.out
@pytest.mark.vcr(filter_headers=["authorization"])
def test_cache_hitting_between_agents():
from unittest.mock import call, patch
@@ -529,7 +561,7 @@ def test_api_calls_throttling(capsys):
agent=agent,
)
crew = Crew(agents=[agent], tasks=[task], max_rpm=2, verbose=True)
crew = Crew(agents=[agent], tasks=[task], max_rpm=2, verbose=2)
with patch.object(RPMController, "_wait_for_next_minute") as moveon:
moveon.return_value = True
@@ -590,7 +622,7 @@ def test_agents_rpm_is_never_set_if_crew_max_RPM_is_not_set():
agent=agent,
)
Crew(agents=[agent], tasks=[task], verbose=True)
Crew(agents=[agent], tasks=[task], verbose=2)
assert agent._rpm_controller is None
@@ -2536,49 +2568,3 @@ def test_crew_testing_function(mock_kickoff, crew_evaluator):
mock.call().print_crew_evaluation_result(),
]
)
@pytest.mark.vcr(filter_headers=["authorization"])
def test_hierarchical_verbose_manager_agent():
from langchain_openai import ChatOpenAI
task = Task(
description="Come up with a list of 5 interesting ideas to explore for an article, then write one amazing paragraph highlight for each idea that showcases how good an article about this topic could be. Return the list of ideas with their paragraph and your notes.",
expected_output="5 bullet points with a paragraph for each idea.",
)
crew = Crew(
agents=[researcher, writer],
tasks=[task],
process=Process.hierarchical,
manager_llm=ChatOpenAI(temperature=0, model="gpt-4o"),
verbose=True,
)
crew.kickoff()
assert crew.manager_agent is not None
assert crew.manager_agent.verbose
@pytest.mark.vcr(filter_headers=["authorization"])
def test_hierarchical_verbose_false_manager_agent():
from langchain_openai import ChatOpenAI
task = Task(
description="Come up with a list of 5 interesting ideas to explore for an article, then write one amazing paragraph highlight for each idea that showcases how good an article about this topic could be. Return the list of ideas with their paragraph and your notes.",
expected_output="5 bullet points with a paragraph for each idea.",
)
crew = Crew(
agents=[researcher, writer],
tasks=[task],
process=Process.hierarchical,
manager_llm=ChatOpenAI(temperature=0, model="gpt-4o"),
verbose=False,
)
crew.kickoff()
assert crew.manager_agent is not None
assert not crew.manager_agent.verbose

View File

@@ -434,7 +434,7 @@ def test_output_pydantic_to_another_task():
agent=scorer,
)
crew = Crew(agents=[scorer], tasks=[task1, task2], verbose=True)
crew = Crew(agents=[scorer], tasks=[task1, task2], verbose=2)
result = crew.kickoff()
pydantic_result = result.pydantic
assert isinstance(