You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- The `createMessage` method has been replaced with the `beta.threads.messages.create` method
314
330
- The message specification has been moved from a parameter list to an options object
315
331
316
332
#### Runs
317
333
318
334
To run an assistant on a thread, the `createRun` method is used to create a run and then a loop is used to poll the run status until it is in a terminal state. The following example shows how to migrate the run creation and polling.
319
335
336
+
# [OpenAI JavaScript (new)](#tab/javascript-new)
337
+
338
+
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.
- The `createRun` method has been replaced with the `beta.threads.runs.create` and `createAndPoll` methods
352
375
- The `createAndPoll` method is used to create a run and poll it until it is in a terminal state
353
376
354
377
#### Processing Run results
355
378
356
-
Without paging, results had to be accessed manually page by page using the `data` property of the response object. For instance, accessing the first page can be done as follows:
379
+
# [OpenAI JavaScript (new)](#tab/javascript-new)
380
+
381
+
Pages can be looped through by using the `forawait` loop.
357
382
358
-
Original code:
359
383
```typescript
360
-
for (construnMessageDatumofrunMessages.data) {
384
+
forawait(construnMessageDatumofrunMessages) {
361
385
for (constitemof runMessageDatum.content) {
362
386
...
363
387
}
364
388
}
365
389
```
366
390
367
-
Pages can be looped through by using the `forawait` loop.
Without paging, results had to be accessed manually page by page using the `data` property of the response object. For instance, accessing the first page can be done as follows:
368
394
369
-
Migration code:
370
395
```typescript
371
-
forawait(construnMessageDatumofrunMessages) {
396
+
for (construnMessageDatumofrunMessages.data) {
372
397
for (constitemof runMessageDatum.content) {
373
398
...
374
399
}
375
400
}
376
401
```
377
402
403
+
---
404
+
405
+
378
406
### Embeddings
379
407
380
408
The following example shows how to migrate the `getEmbeddings` method call.
- The `getEmbeddings` method has been replaced with the `embeddings.create` method
394
426
- The `input` parameter is now passed in the options object with the `input` property
395
427
- The `deploymentName` parameter has been removed. The `deploymentName` parameter is not needed if the client was created with the `deployment` option. If the client was not created with the `deployment` option, the `model` property in the option object should be set with the deployment name
@@ -398,17 +430,22 @@ Notice that:
398
430
399
431
The following example shows how to migrate the `getImages` method call.
- The `getImages` method has been replaced with the `images.generate` method
413
450
- The `prompt` parameter is now passed in the options object with the `prompt` property
414
451
- The `deploymentName` parameter has been removed. The `deploymentName` parameter is not needed if the client was created with the `deployment` option. If the client was not created with the `deployment` option, the `model` property in the option object should be set with the deployment name
@@ -417,51 +454,55 @@ Notice that:
417
454
418
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.
However `AzureOpenAI` does not have a direct equivalent to the `contentFilterResults` property in the `ChatCompletion.Choice` interface. The content filter results can be accessed by casting the `results` object to `any` and accessing the `content_filter_results` property.
However `AzureOpenAI` does not have a direct equivalent to the `contentFilterResults` property in the `ChatCompletion.Choice` interface. The content filter results can be accessed by casting the `results` object to `any` and accessing the `content_filter_results` property.
495
+
496
+
---
497
+
498
+
Note that:
457
499
- camel case properties have been replaced with snake case properties
458
500
- A cast to `any` is used to access the `content_filter_results` property because it is not part of the `ChatCompletion.Choice` interface, see the [Azure types](#azure-types) section for more information
459
501
460
502
## Comparing Types
461
503
462
504
The following table explores several type names from `@azure/openai` and shows their nearest `openai` equivalent. The names differences illustrate several of the above-mentioned changes. This table provides an overview, and more detail and code samples are provided in the following sections.
463
505
464
-
<!-- prettier-ignore -->
465
506
| Old Type Name | Nearest New Type | Symbol Type | Change description |
| `OpenAIClient` | `AzureOpenAI` | Class | This class replaces the former and has no methods in common with it. See the section on `AzureOpenAI` below. |
@@ -520,4 +561,8 @@ The following table explores several type names from `@azure/openai` and shows t
520
561
521
562
## Azure types
522
563
523
-
`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.
564
+
`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.
0 commit comments