Skip to content

Commit 4033c6a

Browse files
committed
address feedback
1 parent 878679e commit 4033c6a

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/beta/realtime/websocket.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ export class OpenAIRealtimeWebSocket extends OpenAIRealtimeEmitter {
5454
throw new Error(
5555
[
5656
'Cannot open Realtime WebSocket with a function-based apiKey.',
57-
'Use the factory so the key is resolved before connecting:',
58-
'- OpenAIRealtimeWebSocket.create(client, { model })',
57+
'Use the .create() method so that the key is resolved before connecting:',
58+
'await OpenAIRealtimeWebSocket.create(client, { model })',
5959
].join('\n'),
6060
);
6161
}
@@ -116,9 +116,9 @@ export class OpenAIRealtimeWebSocket extends OpenAIRealtimeEmitter {
116116
client: Pick<AzureOpenAI, '_callApiKey' | 'apiVersion' | 'apiKey' | 'baseURL' | 'deploymentName'>,
117117
options: { deploymentName?: string; dangerouslyAllowBrowser?: boolean } = {},
118118
): Promise<OpenAIRealtimeWebSocket> {
119-
const isToken = await client._callApiKey();
119+
const isApiKeyProvider = await client._callApiKey();
120120
function onURL(url: URL) {
121-
if (isToken) {
121+
if (isApiKeyProvider) {
122122
url.searchParams.set('Authorization', `Bearer ${client.apiKey}`);
123123
} else {
124124
url.searchParams.set('api-key', client.apiKey);
@@ -134,7 +134,7 @@ export class OpenAIRealtimeWebSocket extends OpenAIRealtimeEmitter {
134134
model: deploymentName,
135135
onURL,
136136
...(dangerouslyAllowBrowser ? { dangerouslyAllowBrowser } : {}),
137-
__resolvedApiKey: isToken,
137+
__resolvedApiKey: isApiKeyProvider,
138138
},
139139
client,
140140
);

src/beta/realtime/ws.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
2222
throw new Error(
2323
[
2424
'Cannot open Realtime WebSocket with a function-based apiKey.',
25-
'Use the factory so the key is resolved just before connecting:',
26-
'- OpenAIRealtimeWS.create(client, { model })',
25+
'Use the .create() method so that the key is resolved before connecting:',
26+
'await OpenAIRealtimeWS.create(client, { model })',
2727
].join('\n'),
2828
);
2929
}
@@ -75,7 +75,7 @@ export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
7575
client: Pick<AzureOpenAI, '_callApiKey' | 'apiVersion' | 'apiKey' | 'baseURL' | 'deploymentName'>,
7676
props: { deploymentName?: string; options?: WS.ClientOptions | undefined } = {},
7777
): Promise<OpenAIRealtimeWS> {
78-
const isToken = await client._callApiKey();
78+
const isApiKeyProvider = await client._callApiKey();
7979
const deploymentName = props.deploymentName ?? client.deploymentName;
8080
if (!deploymentName) {
8181
throw new Error('No deployment name provided');
@@ -87,10 +87,10 @@ export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
8787
...props.options,
8888
headers: {
8989
...props.options?.headers,
90-
...(isToken ? {} : { 'api-key': client.apiKey }),
90+
...(isApiKeyProvider ? {} : { 'api-key': client.apiKey }),
9191
},
9292
},
93-
__resolvedApiKey: isToken,
93+
__resolvedApiKey: isApiKeyProvider,
9494
},
9595
client,
9696
);

0 commit comments

Comments
 (0)