Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkbrnd committed Feb 18, 2025
1 parent 775f4f8 commit 38431e4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions libs/agno/agno/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,14 @@ def validate_exclusive_video(cls, data: Any):
def to_dict(self) -> Dict[str, Any]:
import base64

return {
response_dict = {
"content": base64.b64encode(self.content).decode("utf-8")
if isinstance(self.content, bytes)
else self.content,
"filepath": self.filepath,
"format": self.format,
}
return {k: v for k, v in response_dict.items() if v is not None}


class Audio(BaseModel):
Expand Down Expand Up @@ -113,13 +114,14 @@ def audio_url_content(self) -> Optional[bytes]:
def to_dict(self) -> Dict[str, Any]:
import base64

return {
response_dict = {
"content": base64.b64encode(self.content).decode("utf-8")
if isinstance(self.content, bytes)
else self.content,
"filepath": self.filepath,
"format": self.format,
}
return {k: v for k, v in response_dict.items() if v is not None}


class AudioOutput(BaseModel):
Expand All @@ -131,14 +133,15 @@ class AudioOutput(BaseModel):
def to_dict(self) -> Dict[str, Any]:
import base64

return {
response_dict = {
"id": self.id,
"content": base64.b64encode(self.content).decode("utf-8")
if isinstance(self.content, bytes)
else self.content,
"expires_at": self.expires_at,
"transcript": self.transcript,
}
return {k: v for k, v in response_dict.items() if v is not None}


class Image(BaseModel):
Expand Down Expand Up @@ -183,11 +186,12 @@ def validate_exclusive_image(cls, data: Any):
def to_dict(self) -> Dict[str, Any]:
import base64

return {
response_dict = {
"content": base64.b64encode(self.content).decode("utf-8")
if isinstance(self.content, bytes)
else self.content,
"filepath": self.filepath,
"url": self.url,
"detail": self.detail,
}
return {k: v for k, v in response_dict.items() if v is not None}

0 comments on commit 38431e4

Please sign in to comment.