Skip to content

Commit 02bb496

Browse files
authored
fix(serializer): NaN handling (#1107)
1 parent f71b904 commit 02bb496

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

langfuse/serializer.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""@private"""
22

33
import enum
4+
import math
45
from asyncio import Queue
56
from collections.abc import Sequence
67
from dataclasses import asdict, is_dataclass
@@ -54,6 +55,9 @@ def default(self, obj: Any):
5455
if np is not None and isinstance(obj, np.generic):
5556
return obj.item()
5657

58+
if isinstance(obj, float) and math.isnan(obj):
59+
return None
60+
5761
if isinstance(obj, (Exception, KeyboardInterrupt)):
5862
return f"{type(obj).__name__}: {str(obj)}"
5963

0 commit comments

Comments
 (0)