Add in Eduardo feedback. Still need to add in more commentary describing the design decisions for pipeline

This commit is contained in:
Brandon Hancock
2024-07-29 12:20:18 -04:00
parent d9e60c8b57
commit cb2276dc7d
4 changed files with 19 additions and 13 deletions

View File

@@ -199,9 +199,7 @@ class Agent(BaseAgent):
"tools": self.agent_executor.tools_description,
}
)["output"]
print("Result when things went well:", result)
except Exception as e:
print("FAILED TO EXECUTE TASK", e)
self._times_executed += 1
if self._times_executed > self.max_retry_limit:
raise e
@@ -217,7 +215,6 @@ class Agent(BaseAgent):
if tool_result.get("result_as_answer", False):
result = tool_result["result"]
print("RESULT TO RETURN", result)
return result
def format_log_to_str(

View File

@@ -96,7 +96,7 @@ class Crew(BaseModel):
default_factory=TaskOutputStorageHandler
)
name: Optional[str] = Field(default="")
name: Optional[str] = Field(default=None)
cache: bool = Field(default=True)
model_config = ConfigDict(arbitrary_types_allowed=True)
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.",
)
output_log_file: Optional[str] = Field(
default="",
default=None,
description="output_log_file",
)
planning: Optional[bool] = Field(

View File

@@ -170,12 +170,23 @@ class Pipeline(BaseModel):
def _format_traces(
self, traces: List[List[Union[str, Dict[str, Any]]]]
) -> List[List[Trace]]:
formatted_traces: List[Trace] = []
for trace in traces[:-1]:
formatted_traces.append(trace[0] if len(trace) == 1 else trace)
formatted_traces: List[Trace] = self._format_single_trace(traces[:-1])
return self._format_multiple_traces(formatted_traces, traces[-1])
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]] = []
final_trace = traces[-1]
if len(final_trace) == 1:
formatted_traces.append(final_trace[0])
traces_to_return.append(formatted_traces)
@@ -184,7 +195,6 @@ class Pipeline(BaseModel):
copied_traces = formatted_traces.copy()
copied_traces.append(trace)
traces_to_return.append(copied_traces)
return traces_to_return
def _format_crew_outputs(

View File

@@ -50,6 +50,7 @@ class Task(BaseModel):
tools_errors: int = 0
delegations: int = 0
i18n: I18N = I18N()
name: Optional[str] = Field(default=None)
prompt_context: Optional[str] = None
description: str = Field(description="Description of the actual task.")
expected_output: str = Field(
@@ -254,9 +255,7 @@ class Task(BaseModel):
content = (
json_output
if json_output
else pydantic_output.model_dump_json()
if pydantic_output
else result
else pydantic_output.model_dump_json() if pydantic_output else result
)
self._save_file(content)