Skip to content

Commit

Permalink
oai-realtime: log response errors (#819)
Browse files Browse the repository at this point in the history
  • Loading branch information
theomonnom authored Oct 1, 2024
1 parent d0a244e commit ab77d42
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/serious-melons-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-plugins-openai": patch
---

oai-realtime: log response errors
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,30 @@ def _handle_response_done(self, response_done: api_proto.ServerEvent.ResponseDon

response.status = response_data["status"]
response.status_details = response_data.get("status_details")

if response.status == "failed":
assert response.status_details is not None

error = response.status_details.get("error")
code: str | None = None
message: str | None = None
if error is not None:
code = error.get("code")
message = error.get("message")

logger.error(
"response generation failed",
extra={"code": code, "error": message, **self.logging_extra()},
)
elif response.status == "incomplete":
assert response.status_details is not None
reason = response.status_details.get("reason")

logger.warning(
"response generation incomplete",
extra={"reason": reason, **self.logging_extra()},
)

self.emit("response_done", response)

def _get_content(self, ptr: _ContentPtr) -> RealtimeContent:
Expand Down

0 comments on commit ab77d42

Please sign in to comment.