Skip to content

Commit f9df2ca

Browse files
authored
Merge pull request #31 from pipecat-ai/mb/serializer-deprecation-warnings
Fix deprecation warnings from the frame serializer
2 parents b894473 + adbb160 commit f9df2ca

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

changelog/31.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fixed deprecation warnings being emitted for every frame sent to Whisker. Deprecated frame fields, such as `StartFrame.audio_in_sample_rate` and its siblings, warn when read, and the serializer read each dataclass field twice while walking every frame. It now reads the raw instance state instead, so no warning is emitted.

pipecat/src/pipecat_whisker/sink.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,11 @@ def whisker_obj_serializer(obj: Any) -> Any:
166166
Returns:
167167
A JSON-shaped representation of the input.
168168
"""
169-
if is_dataclass(obj):
170-
return {
171-
f.name: whisker_obj_serializer(getattr(obj, f.name))
172-
for f in fields(obj)
173-
if getattr(obj, f.name) is not None
174-
}
169+
if is_dataclass(obj) and not isinstance(obj, type):
170+
# Read the raw instance state: a field can intercept reads to warn that
171+
# it is deprecated, and this walks every field of every frame.
172+
values = {f.name: object.__getattribute__(obj, f.name) for f in fields(obj)}
173+
return {k: whisker_obj_serializer(v) for k, v in values.items() if v is not None}
175174
elif isinstance(obj, (list, tuple, set)):
176175
return [whisker_obj_serializer(v) for v in obj if v is not None]
177176
elif isinstance(obj, dict):

ui/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.vercel
2+
.env*

0 commit comments

Comments
 (0)