Skip to content

Commit

Permalink
OpenAI Realtime API - fixing unsupported style and double init bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
OvidijusParsiunas committed Jan 26, 2025
1 parent 8af8995 commit 1a95c94
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 7 additions & 3 deletions component/src/services/openAI/realtime/openAIRealtimeButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,23 @@ export class OpenAIRealtimeButton extends InputButton<Styles> {

public changeToActive() {
this.elementRef.replaceChildren(this._innerElements.active);
this.reapplyStateStyle('active', ['default']);
this.reapplyStateStyle('active', ['unavailable', 'default']);
this.isActive = true;
}

public changeToDefault() {
this.elementRef.replaceChildren(this._innerElements.default);
if (this._customStyles?.active) ButtonCSS.unsetAllCSS(this.elementRef, this._customStyles?.active);
this.reapplyStateStyle('default', ['active']);
if (this._customStyles?.unavailable) ButtonCSS.unsetAllCSS(this.elementRef, this._customStyles?.unavailable);
this.reapplyStateStyle('default', ['active', 'unavailable']);
this.isActive = false;
}

public changeToUnavailable() {
this.elementRef.replaceChildren(this._innerElements.unavailable);
this.reapplyStateStyle('unavailable', ['active']);
if (this._customStyles?.active) ButtonCSS.unsetAllCSS(this.elementRef, this._customStyles?.active);
if (this._customStyles?.default) ButtonCSS.unsetAllCSS(this.elementRef, this._customStyles?.default);
this.reapplyStateStyle('unavailable', ['default', 'active']);
this.isActive = false;
}
}
3 changes: 1 addition & 2 deletions component/src/services/openAI/realtime/openAIRealtimeIO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export class OpenAIRealtimeIO extends DirectServiceIO {
this._avatarEl = OpenAIRealtimeIO.createAvatar(this._avatarConfig);
this._containerEl = this.createContainer();
this._deepChat = deepChat;
this.setup();
}

private static getKey(deepChat: DeepChat) {
Expand Down Expand Up @@ -304,7 +303,7 @@ export class OpenAIRealtimeIO extends DirectServiceIO {
// Start the session using the Session Description Protocol (SDP)
const offer = await this._pc.createOffer();
await this._pc.setLocalDescription(offer);
const sdpResponse = await fetch(`https://api.openai.com/v1/realtime?model=${this.rawBody.model}`, {
const sdpResponse = await fetch('https://api.openai.com/v1/realtime', {
method: 'POST',
body: offer.sdp,
headers: {
Expand Down

0 comments on commit 1a95c94

Please sign in to comment.