Skip to content

Commit

Permalink
Enhance log storage to support more data types
Browse files Browse the repository at this point in the history
  • Loading branch information
MottoX committed Oct 29, 2024
1 parent 26afee9 commit c52cb78
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/crewai/memory/storage/kickoff_task_outputs_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def add(
task.expected_output,
json.dumps(output, cls=CrewJSONEncoder),
task_index,
json.dumps(inputs),
json.dumps(inputs, cls=CrewJSONEncoder),
was_replayed,
),
)
Expand Down
3 changes: 2 additions & 1 deletion src/crewai/utilities/crew_json_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
import json
from uuid import UUID
from pydantic import BaseModel
from decimal import Decimal


class CrewJSONEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, BaseModel):
return self._handle_pydantic_model(obj)
elif isinstance(obj, UUID):
elif isinstance(obj, UUID) or isinstance(obj, Decimal):
return str(obj)

elif isinstance(obj, datetime) or isinstance(obj, date):
Expand Down

0 comments on commit c52cb78

Please sign in to comment.