diff --git a/literalai/my_types.py b/literalai/my_types.py index 6f0e06f..8197e16 100644 --- a/literalai/my_types.py +++ b/literalai/my_types.py @@ -139,8 +139,7 @@ def from_dict( raise ValueError(f"Unknown generation type: {type}") def to_dict(self): - return { - "id": self.id, + _dict = { "promptId": self.prompt_id, "provider": self.provider, "model": self.model, @@ -156,6 +155,9 @@ def to_dict(self): "tokenThroughputInSeconds": self.token_throughput_in_s, "duration": self.duration, } + if self.id: + _dict["id"] = self.id + return _dict @dataclass(repr=False)