Skip to content

Emit errors from open ai realtime model #1968

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

Shubhrakanti
Copy link
Contributor

No description provided.

Copy link
Contributor

github-actions bot commented Apr 11, 2025

✅ Changeset File Detected

The following changeset entries were found:

  • patch - livekit-agents
  • patch - livekit-plugins-openai

Change description:
Emit errors from open ai realtime model (#1968)

type: Literal["realtime_model_error"] = "realtime_model_error"
timestamp: float
label: str
error: any = Field(..., exclude=True)
Copy link
Contributor Author

@Shubhrakanti Shubhrakanti Apr 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to wrap this with our own Error class (similar to APIError). Just not a lot of structure in the errors from the different web socket events in the realtime models.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can still use APIError. There is the message field, I think it's OK

@Shubhrakanti Shubhrakanti requested a review from theomonnom April 11, 2025 06:35
@Shubhrakanti Shubhrakanti marked this pull request as draft April 11, 2025 06:35
type: Literal["realtime_model_error"] = "realtime_model_error"
timestamp: float
label: str
error: any = Field(..., exclude=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can still use APIError. There is the message field, I think it's OK

@@ -318,7 +319,17 @@ async def _recv_task() -> None:
msg = await ws_conn.receive()
if msg.type == aiohttp.WSMsgType.CLOSED:
if not closing:
raise Exception("OpenAI S2S connection closed unexpectedly")
error = Exception("OpenAI S2S connection closed unexpectedly")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be APIConnectionError here?

type="realtime_model_error",
timestamp=time.time(),
label=self._realtime_model._label,
error=event.error,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's be consistent and give an Exception here, let's use APIError?
we may not have all the details, but I think it's fine for now

@Shubhrakanti Shubhrakanti marked this pull request as ready for review April 16, 2025 08:01
@Shubhrakanti Shubhrakanti changed the title Emit errors from realtime models Emit errors from open ai realtime model Apr 16, 2025
@Shubhrakanti Shubhrakanti requested a review from theomonnom April 16, 2025 08:18
@@ -16,6 +17,7 @@

from livekit import rtc
from livekit.agents import io, llm, utils
from livekit.agents._exceptions import APIConnectionError, APIError
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from livekit.agents._exceptions import APIConnectionError, APIError
from livekit.agents import APIConnectionError, APIError

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants