Skip to content

Commit

Permalink
Merge pull request #812 from zzz-heygen/zzz/fix_serializer_backward_c…
Browse files Browse the repository at this point in the history
…ompat

fix: make ProtobufFrameSerializer backwards compatible
  • Loading branch information
aconchillo authored Dec 10, 2024
2 parents 9ac34ac + d6b3a50 commit 6ba2dea
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/pipecat/serializers/protobuf.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,25 +90,25 @@ def deserialize(self, data: str | bytes) -> Frame | None:
args_dict[field.name] = getattr(args, field.name)

# Remove special fields if needed
id = getattr(args, "id")
name = getattr(args, "name")
pts = getattr(args, "pts")
if not id:
id = getattr(args, "id", None)
name = getattr(args, "name", None)
pts = getattr(args, "pts", None)
if not id and "id" in args_dict:
del args_dict["id"]
if not name:
if not name and "name" in args_dict:
del args_dict["name"]
if not pts:
if not pts and "pts" in args_dict:
del args_dict["pts"]

# Create the instance
instance = class_name(**args_dict)

# Set special fields
if id:
setattr(instance, "id", getattr(args, "id"))
setattr(instance, "id", getattr(args, "id", None))
if name:
setattr(instance, "name", getattr(args, "name"))
setattr(instance, "name", getattr(args, "name", None))
if pts:
setattr(instance, "pts", getattr(args, "pts"))
setattr(instance, "pts", getattr(args, "pts", None))

return instance

0 comments on commit 6ba2dea

Please sign in to comment.