mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-28 01:28:14 +00:00
* WIP. Procedure appears to be working well. Working on mocking properly for tests * All tests are passing now * rshift working * Add back in Gui's tool_usage fix * WIP * Going to start refactoring for pipeline_output * Update terminology * new pipeline flow with traces and usage metrics working. need to add more tests and make sure PipelineOutput behaves likew CrewOutput * Fix pipelineoutput to look more like crewoutput and taskoutput * Implemented additional tests for pipeline. One test is failing. Need team support * Update docs for pipeline * Update pipeline to properly process input and ouput dictionary * Update Pipeline docs * Add back in commentary at top of pipeline file * Starting to work on router * Drop router for now. will add in separately * In the middle of fixing router. A ton of circular dependencies. Moving over to a new design. * WIP. * Fix circular dependencies and updated PipelineRouter * Add in Eduardo feedback. Still need to add in more commentary describing the design decisions for pipeline * Add developer notes to explain what is going on in pipelines. * Add doc strings * Fix missing rag datatype * WIP. Converting usage metrics from a dict to an object * Fix tests that were checking usage metrics * Drop todo * Fix 1 type error in pipeline * Update pipeline to use UsageMetric * Add missing doc string * WIP. * Change names * Rename variables based on joaos feedback * Fix critical circular dependency issues. Now needing to fix trace issue. * Tests working now! * Add more tests which showed underlying issue with traces * Fix tests * Remove overly complicated test * Add router example to docs * Clean up end of docs * Clean up docs * Working on creating Crew templates and pipeline templates * WIP. * WIP * Fix poetry install from templates * WIP * Restructure * changes for lorenze * more todos * WIP: create pipelines cli working * wrapped up router * ignore mypy src on templates * ignored signature of copy * fix all verbose * rm print statements * brought back correct folders * fixes missing folders and then rm print statements * fixed tests * fixed broken test * fixed type checker * fixed type ignore * ignore types for templates * needed * revert * exclude only required * rm type errors on templates * rm excluding type checks for template files on github action * fixed missing quotes --------- Co-authored-by: Brandon Hancock <brandon@brandonhancock.io>
62 lines
2.0 KiB
Python
62 lines
2.0 KiB
Python
import json
|
|
import uuid
|
|
from typing import Any, Dict, List, Optional, Union
|
|
|
|
from pydantic import UUID4, BaseModel, Field
|
|
|
|
from crewai.crews.crew_output import CrewOutput
|
|
from crewai.types.usage_metrics import UsageMetrics
|
|
|
|
|
|
class PipelineKickoffResult(BaseModel):
|
|
"""Class that represents the result of a pipeline run."""
|
|
|
|
id: UUID4 = Field(
|
|
default_factory=uuid.uuid4,
|
|
frozen=True,
|
|
description="Unique identifier for the object, not set by user.",
|
|
)
|
|
raw: str = Field(description="Raw output of the pipeline run", default="")
|
|
pydantic: Any = Field(
|
|
description="Pydantic output of the pipeline run", default=None
|
|
)
|
|
json_dict: Union[Dict[str, Any], None] = Field(
|
|
description="JSON dict output of the pipeline run", default={}
|
|
)
|
|
|
|
token_usage: Dict[str, UsageMetrics] = Field(
|
|
description="Token usage for each crew in the run"
|
|
)
|
|
trace: List[Any] = Field(
|
|
description="Trace of the journey of inputs through the run"
|
|
)
|
|
crews_outputs: List[CrewOutput] = Field(
|
|
description="Output from each crew in the run",
|
|
default=[],
|
|
)
|
|
|
|
@property
|
|
def json(self) -> Optional[str]:
|
|
if self.crews_outputs[-1].tasks_output[-1].output_format != "json":
|
|
raise ValueError(
|
|
"No JSON output found in the final task of the final crew. Please make sure to set the output_json property in the final task in your crew."
|
|
)
|
|
|
|
return json.dumps(self.json_dict)
|
|
|
|
def to_dict(self) -> Dict[str, Any]:
|
|
"""Convert json_output and pydantic_output to a dictionary."""
|
|
output_dict = {}
|
|
if self.json_dict:
|
|
output_dict.update(self.json_dict)
|
|
elif self.pydantic:
|
|
output_dict.update(self.pydantic.model_dump())
|
|
return output_dict
|
|
|
|
def __str__(self):
|
|
if self.pydantic:
|
|
return str(self.pydantic)
|
|
if self.json_dict:
|
|
return str(self.json_dict)
|
|
return self.raw
|