Skip to content

Commit 91ec1fc

Browse files
committed
fixes
1 parent 8ad777c commit 91ec1fc

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

articles/ai-services/openai/how-to/migration-javascript.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { DefaultAzureCredential } from "@azure/identity";
2828
const credential = new DefaultAzureCredential();
2929
```
3030

31-
Which is then passed to the second argument of the `OpenAIClient` and `AssistantsClient` client constructors.
31+
This object is then passed to the second argument of the `OpenAIClient` and `AssistantsClient` client constructors.
3232

3333
In order to authenticate the `AzureOpenAI` client, however, we need to use the `getBearerTokenProvider` function from the `@azure/identity` package. This function creates a token provider that `AzureOpenAI` uses internally to obtain tokens for each request. The token provider is created as follows:
3434

@@ -154,7 +154,6 @@ const result = await client.chat.completions.create({ model: '', messages, ... {
154154

155155
# [Azure OpenAI JavaScript (previous)](#tab/javascript-old)
156156

157-
Original code:
158157
```typescript
159158
const azureSearchEndpoint = "Your Azure Search resource endpoint";
160159
const azureSearchIndexName = "Your Azure Search index name";
@@ -301,7 +300,6 @@ The following example shows how to migrate the `createMessage` method call.
301300

302301
# [OpenAI JavaScript (new)](#tab/javascript-new)
303302

304-
Migration code:
305303
```typescript
306304
const threadResponse = await assistantsClient.beta.threads.messages.create(
307305
assistantThread.id,
@@ -314,7 +312,6 @@ const threadResponse = await assistantsClient.beta.threads.messages.create(
314312

315313
# [Azure OpenAI JavaScript (previous)](#tab/javascript-old)
316314

317-
Original code:
318315
```typescript
319316
const threadResponse = await assistantsClient.createMessage(
320317
assistantThread.id,
@@ -327,7 +324,7 @@ const threadResponse = await assistantsClient.createMessage(
327324

328325
Note that:
329326
- The `createMessage` method has been replaced with the `beta.threads.messages.create` method
330-
- The message specification has been moved from a parameter list to an options object
327+
- The message specification has been moved from a parameter list to an object
331328

332329
#### Runs
333330

@@ -337,7 +334,6 @@ To run an assistant on a thread, the `createRun` method is used to create a run
337334

338335
This code can be migrated and simplified by using the `createAndPoll` method which creates a run and polls it until it is in a terminal state.
339336

340-
Migration code:
341337
```typescript
342338
const runResponse = await assistantsClient.beta.threads.runs.createAndPoll(
343339
assistantThread.id,
@@ -350,7 +346,6 @@ const runResponse = await assistantsClient.beta.threads.runs.createAndPoll(
350346

351347
# [Azure OpenAI JavaScript (previous)](#tab/javascript-old)
352348

353-
Original code:
354349
```typescript
355350
let runResponse = await assistantsClient.createRun(assistantThread.id, {
356351
assistantId: assistantResponse.id,
@@ -452,7 +447,7 @@ Note that:
452447
453448
### Content filter
454449
455-
Content filter results is part of the chat completions response types in `OpenAIClient`. The following example shows how to access the content filter results.
450+
Content filter results are part of the chat completions response types in `OpenAIClient`. The following example shows how to access the content filter results.
456451
457452
# [OpenAI JavaScript (new)](#tab/javascript-new)
458453
@@ -563,6 +558,6 @@ The following table explores several type names from `@azure/openai` and shows t
563558
564559
`AzureOpenAI` connects to the Azure OpenAI service and can call all the operations available in the service. However, the types of the requests and responses are inherited from the `OpenAI` and are not yet updated to reflect the additional features supported exclusively by the Azure OpenAI service. TypeScript users will be required to cast to a more permissive type such as `Record<string, any>` to access those features. Examples in [the Migration examples](#migration-examples) section show how to do this.
565560
566-
# Next steps
561+
## Next steps
567562
568563
- [Azure OpenAI Assistants](../concepts/assistants.md)

0 commit comments

Comments
 (0)