livekit / agents-js

Build realtime multimodal AI agents with Node.js
https://docs.livekit.io/agents
Apache License 2.0
113 stars 12 forks source link

feat(openai): introducing `KnownRealtimeResponse` #104

Open jjangga0214 opened 1 week ago

jjangga0214 commented 1 week ago

Hi!

Type inference is not made smartly when using the type RealtimeResponse.

Let's take this snippet as a usage.

https://github.com/livekit-examples/realtime-playground/blob/989a7cb0edb517e4915e21305a041fa7da2aac37/agent/playground_agent.ts#L172-L209

스크린샷 2024-10-09 오후 3 14 35

For example, when response.status === "incomplete", response.statusDetails.reason should be asserted to 'turn_detected' | 'client_cancelled' | string;. But as you can see, it's not.

The error message is like this.

스크린샷 2024-10-09 오후 3 14 55

The same applies to other statuses such as "failed".

This PR exports new types including KnownRealtimeResponse, which resolves the issue.

changeset-bot[bot] commented 1 week ago

⚠️ No Changeset found

Latest commit: d0e04d153cf082ee7b5aefa878e813031488d8b9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

CLAassistant commented 1 week ago

CLA assistant check
All committers have signed the CLA.