mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-11 00:58:30 +00:00
Add in Eduardo feedback. Still need to add in more commentary describing the design decisions for pipeline
This commit is contained in:
@@ -199,9 +199,7 @@ class Agent(BaseAgent):
|
|||||||
"tools": self.agent_executor.tools_description,
|
"tools": self.agent_executor.tools_description,
|
||||||
}
|
}
|
||||||
)["output"]
|
)["output"]
|
||||||
print("Result when things went well:", result)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("FAILED TO EXECUTE TASK", e)
|
|
||||||
self._times_executed += 1
|
self._times_executed += 1
|
||||||
if self._times_executed > self.max_retry_limit:
|
if self._times_executed > self.max_retry_limit:
|
||||||
raise e
|
raise e
|
||||||
@@ -217,7 +215,6 @@ class Agent(BaseAgent):
|
|||||||
if tool_result.get("result_as_answer", False):
|
if tool_result.get("result_as_answer", False):
|
||||||
result = tool_result["result"]
|
result = tool_result["result"]
|
||||||
|
|
||||||
print("RESULT TO RETURN", result)
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def format_log_to_str(
|
def format_log_to_str(
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ class Crew(BaseModel):
|
|||||||
default_factory=TaskOutputStorageHandler
|
default_factory=TaskOutputStorageHandler
|
||||||
)
|
)
|
||||||
|
|
||||||
name: Optional[str] = Field(default="")
|
name: Optional[str] = Field(default=None)
|
||||||
cache: bool = Field(default=True)
|
cache: bool = Field(default=True)
|
||||||
model_config = ConfigDict(arbitrary_types_allowed=True)
|
model_config = ConfigDict(arbitrary_types_allowed=True)
|
||||||
tasks: List[Task] = Field(default_factory=list)
|
tasks: List[Task] = Field(default_factory=list)
|
||||||
@@ -148,7 +148,7 @@ class Crew(BaseModel):
|
|||||||
description="Path to the prompt json file to be used for the crew.",
|
description="Path to the prompt json file to be used for the crew.",
|
||||||
)
|
)
|
||||||
output_log_file: Optional[str] = Field(
|
output_log_file: Optional[str] = Field(
|
||||||
default="",
|
default=None,
|
||||||
description="output_log_file",
|
description="output_log_file",
|
||||||
)
|
)
|
||||||
planning: Optional[bool] = Field(
|
planning: Optional[bool] = Field(
|
||||||
|
|||||||
@@ -170,12 +170,23 @@ class Pipeline(BaseModel):
|
|||||||
def _format_traces(
|
def _format_traces(
|
||||||
self, traces: List[List[Union[str, Dict[str, Any]]]]
|
self, traces: List[List[Union[str, Dict[str, Any]]]]
|
||||||
) -> List[List[Trace]]:
|
) -> List[List[Trace]]:
|
||||||
formatted_traces: List[Trace] = []
|
formatted_traces: List[Trace] = self._format_single_trace(traces[:-1])
|
||||||
for trace in traces[:-1]:
|
return self._format_multiple_traces(formatted_traces, traces[-1])
|
||||||
formatted_traces.append(trace[0] if len(trace) == 1 else trace)
|
|
||||||
|
|
||||||
|
def _format_single_trace(
|
||||||
|
self, traces: List[List[Union[str, Dict[str, Any]]]]
|
||||||
|
) -> List[Trace]:
|
||||||
|
formatted_traces: List[Trace] = []
|
||||||
|
for trace in traces:
|
||||||
|
formatted_traces.append(trace[0] if len(trace) == 1 else trace)
|
||||||
|
return formatted_traces
|
||||||
|
|
||||||
|
def _format_multiple_traces(
|
||||||
|
self,
|
||||||
|
formatted_traces: List[Trace],
|
||||||
|
final_trace: List[Union[str, Dict[str, Any]]],
|
||||||
|
) -> List[List[Trace]]:
|
||||||
traces_to_return: List[List[Trace]] = []
|
traces_to_return: List[List[Trace]] = []
|
||||||
final_trace = traces[-1]
|
|
||||||
if len(final_trace) == 1:
|
if len(final_trace) == 1:
|
||||||
formatted_traces.append(final_trace[0])
|
formatted_traces.append(final_trace[0])
|
||||||
traces_to_return.append(formatted_traces)
|
traces_to_return.append(formatted_traces)
|
||||||
@@ -184,7 +195,6 @@ class Pipeline(BaseModel):
|
|||||||
copied_traces = formatted_traces.copy()
|
copied_traces = formatted_traces.copy()
|
||||||
copied_traces.append(trace)
|
copied_traces.append(trace)
|
||||||
traces_to_return.append(copied_traces)
|
traces_to_return.append(copied_traces)
|
||||||
|
|
||||||
return traces_to_return
|
return traces_to_return
|
||||||
|
|
||||||
def _format_crew_outputs(
|
def _format_crew_outputs(
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ class Task(BaseModel):
|
|||||||
tools_errors: int = 0
|
tools_errors: int = 0
|
||||||
delegations: int = 0
|
delegations: int = 0
|
||||||
i18n: I18N = I18N()
|
i18n: I18N = I18N()
|
||||||
|
name: Optional[str] = Field(default=None)
|
||||||
prompt_context: Optional[str] = None
|
prompt_context: Optional[str] = None
|
||||||
description: str = Field(description="Description of the actual task.")
|
description: str = Field(description="Description of the actual task.")
|
||||||
expected_output: str = Field(
|
expected_output: str = Field(
|
||||||
@@ -254,9 +255,7 @@ class Task(BaseModel):
|
|||||||
content = (
|
content = (
|
||||||
json_output
|
json_output
|
||||||
if json_output
|
if json_output
|
||||||
else pydantic_output.model_dump_json()
|
else pydantic_output.model_dump_json() if pydantic_output else result
|
||||||
if pydantic_output
|
|
||||||
else result
|
|
||||||
)
|
)
|
||||||
self._save_file(content)
|
self._save_file(content)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user