From a179d2258582d47fa35e53463dc3da545555253a Mon Sep 17 00:00:00 2001 From: Deyaaeldeen Almahallawi Date: Sat, 16 Nov 2024 00:34:56 +0300 Subject: [PATCH] [OpenAI] Stable v2 (#31469) ### Packages impacted by this PR @azure/openai ### Issues associated with this PR N/A ### Describe the problem that is addressed by this PR Preparing for releasing v2.0 that targets API [v2024-10-21](https://github.com/Azure/azure-rest-api-specs/blob/main/specification/cognitiveservices/data-plane/AzureOpenAI/inference/stable/2024-10-21/inference.json). ### What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen? N/A ### Are there test cases added in this PR? _(If not, why?)_ N/A ### Provide a list of related PRs _(if any)_ N/A ### Command used to generate this PR:**_(Applicable only to SDK release request PRs)_ ### Checklists - [x] Added impacted package name to the issue description - [ ] Does this PR needs any fixes in the SDK Generator?** _(If so, create an Issue in the [Autorest/typescript](https://github.com/Azure/autorest.typescript) repository and link it here)_ - [x] Added a changelog (if necessary) --------- Co-authored-by: Krista Pratico --- sdk/openai/openai/CHANGELOG.md | 13 +- sdk/openai/openai/MIGRATION.md | 2 +- sdk/openai/openai/README.md | 6 +- sdk/openai/openai/package.json | 2 +- sdk/openai/openai/review/openai-types.api.md | 213 +--------- .../openai/samples-dev/audioTranscription.ts | 2 +- .../openai/samples-dev/audioTranslation.ts | 2 +- .../openai/samples-dev/chatCompletions.ts | 2 +- .../openai/samples-dev/codeInterpreter.ts | 2 + sdk/openai/openai/samples-dev/completions.ts | 2 +- sdk/openai/openai/samples-dev/embeddings.ts | 2 +- sdk/openai/openai/samples-dev/images.ts | 2 +- sdk/openai/openai/samples-dev/onYourData.ts | 2 +- .../samples-dev/streamChatCompletions.ts | 2 +- .../streamChatCompletionsWithContentFilter.ts | 2 +- .../openai/samples-dev/streamCompletions.ts | 2 +- sdk/openai/openai/samples-dev/textToSpeech.ts | 2 +- sdk/openai/openai/samples-dev/toolCall.ts | 2 +- .../samples/cookbook/embeddingLongInputs.js | 2 +- .../samples/cookbook/onYourData/index.js | 2 +- .../cookbook/simpleCompletionsPage/app.js | 2 +- .../cookbook/speechToSpeechChat/app.js | 2 +- .../v2-beta/javascript/audioTranscription.js | 2 +- .../v2-beta/javascript/audioTranslation.js | 2 +- .../samples/v2-beta/javascript/batch.js | 2 +- .../v2-beta/javascript/chatCompletions.js | 2 +- .../v2-beta/javascript/codeInterpreter.js | 2 + .../samples/v2-beta/javascript/completions.js | 2 +- .../samples/v2-beta/javascript/embeddings.js | 2 +- .../samples/v2-beta/javascript/images.js | 2 +- .../samples/v2-beta/javascript/onYourData.js | 2 +- .../javascript/streamChatCompletions.js | 2 +- .../streamChatCompletionsWithContentFilter.js | 2 +- .../v2-beta/javascript/streamCompletions.js | 2 +- .../v2-beta/javascript/textToSpeech.js | 2 +- .../samples/v2-beta/javascript/toolCall.js | 2 +- .../typescript/src/audioTranscription.ts | 2 +- .../typescript/src/audioTranslation.ts | 2 +- .../v2-beta/typescript/src/chatCompletions.ts | 2 +- .../v2-beta/typescript/src/codeInterpreter.ts | 2 + .../v2-beta/typescript/src/completions.ts | 2 +- .../v2-beta/typescript/src/embeddings.ts | 2 +- .../samples/v2-beta/typescript/src/images.ts | 2 +- .../v2-beta/typescript/src/onYourData.ts | 2 +- .../typescript/src/streamChatCompletions.ts | 2 +- .../streamChatCompletionsWithContentFilter.ts | 2 +- .../typescript/src/streamCompletions.ts | 2 +- .../v2-beta/typescript/src/textToSpeech.ts | 2 +- .../v2-beta/typescript/src/toolCall.ts | 2 +- .../openai/samples/v2/javascript/README.md | 90 +++++ .../v2/javascript/audioTranscription.js | 42 ++ .../samples/v2/javascript/audioTranslation.js | 42 ++ .../openai/samples/v2/javascript/batch.js | 64 +++ .../samples/v2/javascript/chatCompletions.js | 45 +++ .../samples/v2/javascript/codeInterpreter.js | 88 ++++ .../samples/v2/javascript/completions.js | 39 ++ .../samples/v2/javascript/embeddings.js | 40 ++ .../openai/samples/v2/javascript/images.js | 44 ++ .../samples/v2/javascript/onYourData.js | 66 +++ .../openai/samples/v2/javascript/package.json | 36 ++ .../openai/samples/v2/javascript/sample.env | 3 + .../v2/javascript/streamChatCompletions.js | 49 +++ .../streamChatCompletionsWithContentFilter.js | 72 ++++ .../v2/javascript/streamCompletions.js | 46 +++ .../samples/v2/javascript/textToSpeech.js | 51 +++ .../openai/samples/v2/javascript/toolCall.js | 65 +++ .../openai/samples/v2/typescript/README.md | 103 +++++ .../openai/samples/v2/typescript/package.json | 45 +++ .../openai/samples/v2/typescript/sample.env | 3 + .../v2/typescript/src/audioTranscription.ts | 40 ++ .../v2/typescript/src/audioTranslation.ts | 40 ++ .../openai/samples/v2/typescript/src/batch.ts | 62 +++ .../v2/typescript/src/chatCompletions.ts | 43 ++ .../v2/typescript/src/codeInterpreter.ts | 86 ++++ .../samples/v2/typescript/src/completions.ts | 37 ++ .../samples/v2/typescript/src/embeddings.ts | 38 ++ .../samples/v2/typescript/src/images.ts | 42 ++ .../samples/v2/typescript/src/onYourData.ts | 65 +++ .../typescript/src/streamChatCompletions.ts | 47 +++ .../streamChatCompletionsWithContentFilter.ts | 71 ++++ .../v2/typescript/src/streamCompletions.ts | 44 ++ .../samples/v2/typescript/src/textToSpeech.ts | 49 +++ .../samples/v2/typescript/src/toolCall.ts | 63 +++ .../samples/v2/typescript/tsconfig.json | 17 + sdk/openai/openai/src/types/models.ts | 379 +----------------- sdk/openai/openai/src/types/outputModels.ts | 102 +---- .../openai/test/public/utils/asserts.ts | 17 - sdk/openai/openai/test/public/utils/utils.ts | 2 +- 88 files changed, 1866 insertions(+), 735 deletions(-) create mode 100644 sdk/openai/openai/samples/v2/javascript/README.md create mode 100644 sdk/openai/openai/samples/v2/javascript/audioTranscription.js create mode 100644 sdk/openai/openai/samples/v2/javascript/audioTranslation.js create mode 100644 sdk/openai/openai/samples/v2/javascript/batch.js create mode 100644 sdk/openai/openai/samples/v2/javascript/chatCompletions.js create mode 100644 sdk/openai/openai/samples/v2/javascript/codeInterpreter.js create mode 100644 sdk/openai/openai/samples/v2/javascript/completions.js create mode 100644 sdk/openai/openai/samples/v2/javascript/embeddings.js create mode 100644 sdk/openai/openai/samples/v2/javascript/images.js create mode 100644 sdk/openai/openai/samples/v2/javascript/onYourData.js create mode 100644 sdk/openai/openai/samples/v2/javascript/package.json create mode 100644 sdk/openai/openai/samples/v2/javascript/sample.env create mode 100644 sdk/openai/openai/samples/v2/javascript/streamChatCompletions.js create mode 100644 sdk/openai/openai/samples/v2/javascript/streamChatCompletionsWithContentFilter.js create mode 100644 sdk/openai/openai/samples/v2/javascript/streamCompletions.js create mode 100644 sdk/openai/openai/samples/v2/javascript/textToSpeech.js create mode 100644 sdk/openai/openai/samples/v2/javascript/toolCall.js create mode 100644 sdk/openai/openai/samples/v2/typescript/README.md create mode 100644 sdk/openai/openai/samples/v2/typescript/package.json create mode 100644 sdk/openai/openai/samples/v2/typescript/sample.env create mode 100644 sdk/openai/openai/samples/v2/typescript/src/audioTranscription.ts create mode 100644 sdk/openai/openai/samples/v2/typescript/src/audioTranslation.ts create mode 100644 sdk/openai/openai/samples/v2/typescript/src/batch.ts create mode 100644 sdk/openai/openai/samples/v2/typescript/src/chatCompletions.ts create mode 100644 sdk/openai/openai/samples/v2/typescript/src/codeInterpreter.ts create mode 100644 sdk/openai/openai/samples/v2/typescript/src/completions.ts create mode 100644 sdk/openai/openai/samples/v2/typescript/src/embeddings.ts create mode 100644 sdk/openai/openai/samples/v2/typescript/src/images.ts create mode 100644 sdk/openai/openai/samples/v2/typescript/src/onYourData.ts create mode 100644 sdk/openai/openai/samples/v2/typescript/src/streamChatCompletions.ts create mode 100644 sdk/openai/openai/samples/v2/typescript/src/streamChatCompletionsWithContentFilter.ts create mode 100644 sdk/openai/openai/samples/v2/typescript/src/streamCompletions.ts create mode 100644 sdk/openai/openai/samples/v2/typescript/src/textToSpeech.ts create mode 100644 sdk/openai/openai/samples/v2/typescript/src/toolCall.ts create mode 100644 sdk/openai/openai/samples/v2/typescript/tsconfig.json diff --git a/sdk/openai/openai/CHANGELOG.md b/sdk/openai/openai/CHANGELOG.md index d4743fb88548..de6b40d7f4ad 100644 --- a/sdk/openai/openai/CHANGELOG.md +++ b/sdk/openai/openai/CHANGELOG.md @@ -1,14 +1,17 @@ # Release History -## 2.0.0-beta.4 (Unreleased) +## 2.0.0 (2024-11-18) -### Features Added +This release marks the first stable library version for `@azure/openai` and it exposes Azure-exclusive features supported in the latest Azure OpenAI Service stable `api-version` label of `2024-10-21`. -### Breaking Changes +The following features are supported in this release: -### Bugs Fixed +- Azure OpenAI On Your Data which enables you to run advanced AI models, without needing to train or fine-tune models, on your own enterprise data located in an Azure Search index or in an vector store in Azure Cosmos DB. +- Azure OpenAI content filtering which detects and prevents the output of harmful content. -### Other Changes +### Breaking Changes + +- Models related to features still in preview have been removed. ## 2.0.0-beta.3 (2024-11-05) diff --git a/sdk/openai/openai/MIGRATION.md b/sdk/openai/openai/MIGRATION.md index ca649e3b5abd..100dae5d1790 100644 --- a/sdk/openai/openai/MIGRATION.md +++ b/sdk/openai/openai/MIGRATION.md @@ -69,7 +69,7 @@ Migrated code: ```typescript import { AzureOpenAI } from "openai"; const deployment = "Your Azure OpenAI deployment"; -const apiVersion = "2024-08-01-preview"; +const apiVersion = "2024-10-21"; const options = { azureADTokenProvider, deployment, apiVersion } const client = new AzureOpenAI(options); ``` diff --git a/sdk/openai/openai/README.md b/sdk/openai/openai/README.md index 634082839cbe..05cfd6a129a2 100644 --- a/sdk/openai/openai/README.md +++ b/sdk/openai/openai/README.md @@ -60,7 +60,7 @@ There are several ways to authenticate with the Azure OpenAI service and the rec import { AzureOpenAI } from "openai"; const deployment = "Your deployment name"; - const apiVersion = "2024-08-01-preview"; + const apiVersion = "2024-10-21"; const client = new AzureOpenAI({ azureADTokenProvider, deployment, apiVersion }); ``` @@ -126,7 +126,7 @@ export async function main() { const scope = "https://cognitiveservices.azure.com/.default"; const azureADTokenProvider = getBearerTokenProvider(new DefaultAzureCredential(), scope); const deployment = "gpt-4-1106-preview"; - const apiVersion = "2024-08-01-preview"; + const apiVersion = "2024-10-21"; const client = new AzureOpenAI({ azureADTokenProvider, deployment, apiVersion }); const events = await client.chat.completions.create({ stream: true, @@ -182,7 +182,7 @@ async function main() { const scope = "https://cognitiveservices.azure.com/.default"; const azureADTokenProvider = getBearerTokenProvider(new DefaultAzureCredential(), scope); const deployment = "gpt-35-turbo"; - const apiVersion = "2024-08-01-preview"; + const apiVersion = "2024-10-21"; const client = new AzureOpenAI({ azureADTokenProvider, deployment, apiVersion }); const events = await client.chat.completions.create({ messages: [ diff --git a/sdk/openai/openai/package.json b/sdk/openai/openai/package.json index f682166d413d..0267b733d47c 100644 --- a/sdk/openai/openai/package.json +++ b/sdk/openai/openai/package.json @@ -1,6 +1,6 @@ { "name": "@azure/openai", - "version": "2.0.0-beta.4", + "version": "2.0.0", "description": "A companion library to openai for Azure OpenAI.", "sdk-type": "client", "main": "./dist/commonjs/index.js", diff --git a/sdk/openai/openai/review/openai-types.api.md b/sdk/openai/openai/review/openai-types.api.md index 97d4c125ba63..bbdd64f0639a 100644 --- a/sdk/openai/openai/review/openai-types.api.md +++ b/sdk/openai/openai/review/openai-types.api.md @@ -15,23 +15,13 @@ import type { CompletionCreateParamsStreaming } from 'openai/resources/index'; import type { ErrorModel } from '@azure-rest/core-client'; // @public -export type AzureChatExtensionConfiguration = AzureChatExtensionConfigurationParent | AzureSearchChatExtensionConfiguration | AzureCosmosDBChatExtensionConfiguration | ElasticsearchChatExtensionConfiguration | PineconeChatExtensionConfiguration | MongoDBChatExtensionConfiguration; +export type AzureChatExtensionConfiguration = AzureChatExtensionConfigurationParent | AzureSearchChatExtensionConfiguration | AzureCosmosDBChatExtensionConfiguration; // @public export interface AzureChatExtensionConfigurationParent { type: string; } -// @public -export interface AzureChatExtensionDataSourceResponseCitation { - chunk_id?: string; - content: string; - filepath?: string; - rerank_score?: number; - title?: string; - url?: string; -} - // @public export interface AzureChatExtensionDataSourceResponseCitationOutput { chunk_id?: string; @@ -41,20 +31,8 @@ export interface AzureChatExtensionDataSourceResponseCitationOutput { url?: string; } -// @public -export interface AzureChatExtensionRetrievedDocument extends AzureChatExtensionDataSourceResponseCitation { - data_source_index: number; - filter_reason?: AzureChatExtensionRetrieveDocumentFilterReason; - original_search_score?: number; - search_queries: string[]; -} - -// @public -export type AzureChatExtensionRetrieveDocumentFilterReason = "score" | "rerank"; - // @public export interface AzureChatExtensionsMessageContextOutput { - all_retrieved_documents?: Array; citations?: Array; intent?: string; } @@ -67,17 +45,13 @@ export interface AzureCosmosDBChatExtensionConfiguration extends AzureChatExtens // @public export interface AzureCosmosDBChatExtensionParameters { - allow_partial_result?: boolean; - authentication?: OnYourDataAuthenticationOptions; + authentication: OnYourDataAuthenticationOptions; container_name: string; database_name: string; embedding_dependency: OnYourDataVectorizationSource; fields_mapping: AzureCosmosDBFieldMappingOptions; in_scope?: boolean; - include_contexts?: OnYourDataContextProperty[]; index_name: string; - max_search_queries?: number; - role_information?: string; strictness?: number; top_n_documents?: number; } @@ -100,18 +74,14 @@ export interface AzureSearchChatExtensionConfiguration extends AzureChatExtensio // @public export interface AzureSearchChatExtensionParameters { - allow_partial_result?: boolean; - authentication?: OnYourDataAuthenticationOptions; + authentication: OnYourDataAuthenticationOptions; embedding_dependency?: OnYourDataVectorizationSource; endpoint: string; fields_mapping?: AzureSearchIndexFieldMappingOptions; filter?: string; in_scope?: boolean; - include_contexts?: OnYourDataContextProperty[]; index_name: string; - max_search_queries?: number; query_type?: string; - role_information?: string; semantic_configuration?: string; strictness?: number; top_n_documents?: number; @@ -122,7 +92,6 @@ export interface AzureSearchIndexFieldMappingOptions { content_fields?: string[]; content_fields_separator?: string; filepath_field?: string; - image_vector_fields?: string[]; title_field?: string; url_field?: string; vector_fields?: string[]; @@ -144,12 +113,6 @@ export { CompletionCreateParamsNonStreaming } export { CompletionCreateParamsStreaming } -// @public -export interface ContentFilterBlocklistIdResultOutput { - filtered: boolean; - id: string; -} - // @public export interface ContentFilterCitedDetectionResultOutput { detected: boolean; @@ -158,12 +121,6 @@ export interface ContentFilterCitedDetectionResultOutput { URL?: string; } -// @public -export interface ContentFilterDetailedResults { - details: ContentFilterBlocklistIdResultOutput[]; - filtered: boolean; -} - // @public export interface ContentFilterDetectionResultOutput { detected: boolean; @@ -172,10 +129,8 @@ export interface ContentFilterDetectionResultOutput { // @public export interface ContentFilterResultDetailsForPromptOutput { - custom_blocklists?: ContentFilterDetailedResults; error?: ErrorModel; hate?: ContentFilterResultOutput; - indirect_attack?: ContentFilterDetectionResultOutput; jailbreak?: ContentFilterDetectionResultOutput; profanity?: ContentFilterDetectionResultOutput; self_harm?: ContentFilterResultOutput; @@ -191,7 +146,6 @@ export interface ContentFilterResultOutput { // @public export interface ContentFilterResultsForChoiceOutput { - custom_blocklists?: ContentFilterDetailedResults; error?: ErrorModel; hate?: ContentFilterResultOutput; profanity?: ContentFilterDetectionResultOutput; @@ -208,39 +162,6 @@ export interface ContentFilterResultsForPromptOutput { prompt_index: number; } -// @public -export interface ElasticsearchChatExtensionConfiguration extends AzureChatExtensionConfigurationParent { - parameters: ElasticsearchChatExtensionParameters; - type: "elasticsearch"; -} - -// @public -export interface ElasticsearchChatExtensionParameters { - allow_partial_result?: boolean; - authentication?: OnYourDataAuthenticationOptions; - embedding_dependency?: OnYourDataVectorizationSource; - endpoint: string; - fields_mapping?: ElasticsearchIndexFieldMappingOptions; - in_scope?: boolean; - include_contexts?: OnYourDataContextProperty[]; - index_name: string; - max_search_queries?: number; - query_type?: string; - role_information?: string; - strictness?: number; - top_n_documents?: number; -} - -// @public -export interface ElasticsearchIndexFieldMappingOptions { - content_fields?: string[]; - content_fields_separator?: string; - filepath_field?: string; - title_field?: string; - url_field?: string; - vector_fields?: string[]; -} - // @public export interface ImageGenerationContentFilterResults { hate?: ContentFilterResultOutput; @@ -251,7 +172,6 @@ export interface ImageGenerationContentFilterResults { // @public export interface ImageGenerationPromptFilterResults { - custom_blocklists?: ContentFilterDetailedResults; hate?: ContentFilterResultOutput; jailbreak?: ContentFilterDetectionResultOutput; profanity?: ContentFilterDetectionResultOutput; @@ -260,47 +180,6 @@ export interface ImageGenerationPromptFilterResults { violence?: ContentFilterResultOutput; } -// @public -export interface MongoDBChatExtensionConfiguration extends AzureChatExtensionConfigurationParent { - parameters: MongoDBChatExtensionParameters; - type: "mongo_db"; -} - -// @public -export interface MongoDBChatExtensionParameters { - allow_partial_result?: boolean; - app_name: string; - authentication?: OnYourDataUsernameAndPasswordAuthenticationOptions; - collection_name: string; - database_name: string; - embedding_dependency: OnYourDataEndpointVectorizationSource | OnYourDataDeploymentNameVectorizationSource; - endpoint: string; - fields_mapping: MongoDBFieldMappingOptions; - in_scope?: boolean; - include_contexts?: OnYourDataContextProperty[]; - index_name: string; - max_search_queries?: number; - role_information?: string; - strictness?: number; - top_n_documents?: number; -} - -// @public -export interface MongoDBFieldMappingOptions { - content_fields: string[]; - content_fields_separator?: string; - filepath_field?: string; - title_field?: string; - url_field?: string; - vector_fields: string[]; -} - -// @public -export interface OnYourDataAccessTokenAuthenticationOptions extends OnYourDataAuthenticationOptionsParent { - access_token: string; - type: "access_token"; -} - // @public export interface OnYourDataApiKeyAuthenticationOptions extends OnYourDataAuthenticationOptionsParent { key: string; @@ -308,7 +187,7 @@ export interface OnYourDataApiKeyAuthenticationOptions extends OnYourDataAuthent } // @public -export type OnYourDataAuthenticationOptions = OnYourDataAuthenticationOptionsParent | OnYourDataApiKeyAuthenticationOptions | OnYourDataConnectionStringAuthenticationOptions | OnYourDataKeyAndKeyIdAuthenticationOptions | OnYourDataEncodedApiKeyAuthenticationOptions | OnYourDataAccessTokenAuthenticationOptions | OnYourDataSystemAssignedManagedIdentityAuthenticationOptions | OnYourDataUserAssignedManagedIdentityAuthenticationOptions; +export type OnYourDataAuthenticationOptions = OnYourDataAuthenticationOptionsParent | OnYourDataApiKeyAuthenticationOptions | OnYourDataConnectionStringAuthenticationOptions | OnYourDataSystemAssignedManagedIdentityAuthenticationOptions | OnYourDataUserAssignedManagedIdentityAuthenticationOptions; // @public export interface OnYourDataAuthenticationOptionsParent { @@ -324,41 +203,16 @@ export interface OnYourDataConnectionStringAuthenticationOptions extends OnYourD // @public export interface OnYourDataDeploymentNameVectorizationSource extends OnYourDataVectorizationSourceParent { deployment_name: string; - dimensions?: number; type: "deployment_name"; } -// @public -export interface OnYourDataEncodedApiKeyAuthenticationOptions extends OnYourDataAuthenticationOptionsParent { - encoded_api_key: string; - type: "encoded_api_key"; -} - // @public export interface OnYourDataEndpointVectorizationSource extends OnYourDataVectorizationSourceParent { - authentication: OnYourDataVectorSearchAuthenticationOptions; + authentication: OnYourDataApiKeyAuthenticationOptions; endpoint: string; type: "endpoint"; } -// @public -export interface OnYourDataIntegratedVectorizationSource extends OnYourDataVectorizationSourceParent { - type: "integrated"; -} - -// @public -export interface OnYourDataKeyAndKeyIdAuthenticationOptions extends OnYourDataAuthenticationOptionsParent { - key: string; - key_id: string; - type: "key_and_key_id"; -} - -// @public -export interface OnYourDataModelIdVectorizationSource extends OnYourDataVectorizationSourceParent { - model_id: string; - type: "model_id"; -} - // @public export interface OnYourDataSystemAssignedManagedIdentityAuthenticationOptions extends OnYourDataAuthenticationOptionsParent { type: "system_assigned_managed_identity"; @@ -371,68 +225,13 @@ export interface OnYourDataUserAssignedManagedIdentityAuthenticationOptions exte } // @public -export interface OnYourDataUsernameAndPasswordAuthenticationOptions extends OnYourDataAuthenticationOptionsParent { - password: string; - type: "username_and_password"; - username: string; -} - -// @public -export type OnYourDataVectorizationSource = OnYourDataVectorizationSourceParent | OnYourDataEndpointVectorizationSource | OnYourDataDeploymentNameVectorizationSource | OnYourDataModelIdVectorizationSource | OnYourDataIntegratedVectorizationSource; +export type OnYourDataVectorizationSource = OnYourDataVectorizationSourceParent | OnYourDataEndpointVectorizationSource | OnYourDataDeploymentNameVectorizationSource; // @public export interface OnYourDataVectorizationSourceParent { type: string; } -// @public -export interface OnYourDataVectorSearchAccessTokenAuthenticationOptions extends OnYourDataVectorSearchAuthenticationOptions { - access_token: string; - type: "access_token"; -} - -// @public -export interface OnYourDataVectorSearchApiKeyAuthenticationOptions extends OnYourDataVectorSearchAuthenticationOptions { - key: string; - type: "api_key"; -} - -// @public -export interface OnYourDataVectorSearchAuthenticationOptions { - type: string; -} - -// @public -export interface PineconeChatExtensionConfiguration extends AzureChatExtensionConfigurationParent { - parameters: PineconeChatExtensionParameters; - type: "pinecone"; -} - -// @public -export interface PineconeChatExtensionParameters { - allow_partial_result?: boolean; - authentication?: OnYourDataAuthenticationOptions; - embedding_dependency: OnYourDataVectorizationSource; - environment: string; - fields_mapping: PineconeFieldMappingOptions; - in_scope?: boolean; - include_contexts?: OnYourDataContextProperty[]; - index_name: string; - max_search_queries?: number; - role_information?: string; - strictness?: number; - top_n_documents?: number; -} - -// @public -export interface PineconeFieldMappingOptions { - content_fields: string[]; - content_fields_separator?: string; - filepath_field?: string; - title_field?: string; - url_field?: string; -} - // (No @packageDocumentation comment for this package) ``` diff --git a/sdk/openai/openai/samples-dev/audioTranscription.ts b/sdk/openai/openai/samples-dev/audioTranscription.ts index dedeb09abd03..c1d37133663f 100644 --- a/sdk/openai/openai/samples-dev/audioTranscription.ts +++ b/sdk/openai/openai/samples-dev/audioTranscription.ts @@ -26,7 +26,7 @@ export async function main() { const scope = "https://cognitiveservices.azure.com/.default"; const azureADTokenProvider = getBearerTokenProvider(new DefaultAzureCredential(), scope); const deployment = "whisper-deployment"; - const apiVersion = "2024-08-01-preview"; + const apiVersion = "2024-10-21"; const client = new AzureOpenAI({ azureADTokenProvider, deployment, apiVersion }); const result = await client.audio.transcriptions.create({ model: "", diff --git a/sdk/openai/openai/samples-dev/audioTranslation.ts b/sdk/openai/openai/samples-dev/audioTranslation.ts index bb3d7d55c4cc..f7cec9d71e81 100644 --- a/sdk/openai/openai/samples-dev/audioTranslation.ts +++ b/sdk/openai/openai/samples-dev/audioTranslation.ts @@ -26,7 +26,7 @@ export async function main() { const scope = "https://cognitiveservices.azure.com/.default"; const azureADTokenProvider = getBearerTokenProvider(new DefaultAzureCredential(), scope); const deployment = "whisper-deployment"; - const apiVersion = "2024-08-01-preview"; + const apiVersion = "2024-10-21"; const client = new AzureOpenAI({ azureADTokenProvider, deployment, apiVersion }); const result = await client.audio.translations.create({ model: "", diff --git a/sdk/openai/openai/samples-dev/chatCompletions.ts b/sdk/openai/openai/samples-dev/chatCompletions.ts index eaef1ab8ca16..0df4c493ab74 100644 --- a/sdk/openai/openai/samples-dev/chatCompletions.ts +++ b/sdk/openai/openai/samples-dev/chatCompletions.ts @@ -22,7 +22,7 @@ export async function main() { const scope = "https://cognitiveservices.azure.com/.default"; const azureADTokenProvider = getBearerTokenProvider(new DefaultAzureCredential(), scope); const deployment = "gpt-35-turbo"; - const apiVersion = "2024-08-01-preview"; + const apiVersion = "2024-10-21"; const client = new AzureOpenAI({ azureADTokenProvider, deployment, apiVersion }); const result = await client.chat.completions.create({ messages: [ diff --git a/sdk/openai/openai/samples-dev/codeInterpreter.ts b/sdk/openai/openai/samples-dev/codeInterpreter.ts index f30e5666a628..86bdb616ccf4 100644 --- a/sdk/openai/openai/samples-dev/codeInterpreter.ts +++ b/sdk/openai/openai/samples-dev/codeInterpreter.ts @@ -13,6 +13,7 @@ import { AzureOpenAI } from "openai"; import { getBearerTokenProvider, DefaultAzureCredential } from "@azure/identity"; export async function main() { + const apiVersion = "2024-09-01-preview"; // Create AzureOpenAI client with Microsoft Entra ID const credential = new DefaultAzureCredential(); const scope = "https://cognitiveservices.azure.com/.default"; @@ -20,6 +21,7 @@ export async function main() { const client = new AzureOpenAI({ azureADTokenProvider, + apiVersion, }); // Create an assistant using code interpreter tool diff --git a/sdk/openai/openai/samples-dev/completions.ts b/sdk/openai/openai/samples-dev/completions.ts index cba606857110..3f39b4935194 100644 --- a/sdk/openai/openai/samples-dev/completions.ts +++ b/sdk/openai/openai/samples-dev/completions.ts @@ -24,7 +24,7 @@ export async function main() { const scope = "https://cognitiveservices.azure.com/.default"; const azureADTokenProvider = getBearerTokenProvider(new DefaultAzureCredential(), scope); const deployment = "text-davinci-003"; - const apiVersion = "2024-08-01-preview"; + const apiVersion = "2024-10-21"; const client = new AzureOpenAI({ azureADTokenProvider, deployment, apiVersion }); const result = await client.completions.create({ prompt, model: "", max_tokens: 128 }); diff --git a/sdk/openai/openai/samples-dev/embeddings.ts b/sdk/openai/openai/samples-dev/embeddings.ts index 9baa1bdc32a2..8fe0fc267f60 100644 --- a/sdk/openai/openai/samples-dev/embeddings.ts +++ b/sdk/openai/openai/samples-dev/embeddings.ts @@ -24,7 +24,7 @@ export async function main() { const scope = "https://cognitiveservices.azure.com/.default"; const azureADTokenProvider = getBearerTokenProvider(new DefaultAzureCredential(), scope); - const apiVersion = "2024-08-01-preview"; + const apiVersion = "2024-10-21"; const deployment = "text-embedding-3-large"; const client = new AzureOpenAI({ azureADTokenProvider, deployment, apiVersion }); const embeddings = await client.embeddings.create({ input, model: "" }); diff --git a/sdk/openai/openai/samples-dev/images.ts b/sdk/openai/openai/samples-dev/images.ts index 24d7df0a9210..ae5456263b66 100644 --- a/sdk/openai/openai/samples-dev/images.ts +++ b/sdk/openai/openai/samples-dev/images.ts @@ -29,7 +29,7 @@ export async function main() { const scope = "https://cognitiveservices.azure.com/.default"; const azureADTokenProvider = getBearerTokenProvider(new DefaultAzureCredential(), scope); const deployment = "dall-e-3"; - const apiVersion = "2024-08-01-preview"; + const apiVersion = "2024-10-21"; const client = new AzureOpenAI({ azureADTokenProvider, deployment, apiVersion }); const results = await client.images.generate({ prompt, model: "", n, size }); diff --git a/sdk/openai/openai/samples-dev/onYourData.ts b/sdk/openai/openai/samples-dev/onYourData.ts index ad539cb13fcb..9985b2785498 100644 --- a/sdk/openai/openai/samples-dev/onYourData.ts +++ b/sdk/openai/openai/samples-dev/onYourData.ts @@ -27,7 +27,7 @@ export async function main() { const scope = "https://cognitiveservices.azure.com/.default"; const azureADTokenProvider = getBearerTokenProvider(new DefaultAzureCredential(), scope); const deployment = "gpt-4-1106-preview"; - const apiVersion = "2024-08-01-preview"; + const apiVersion = "2024-10-21"; const client = new AzureOpenAI({ azureADTokenProvider, deployment, apiVersion }); const events = await client.chat.completions.create({ stream: true, diff --git a/sdk/openai/openai/samples-dev/streamChatCompletions.ts b/sdk/openai/openai/samples-dev/streamChatCompletions.ts index e8b9f1ec1b8c..2405e193b306 100644 --- a/sdk/openai/openai/samples-dev/streamChatCompletions.ts +++ b/sdk/openai/openai/samples-dev/streamChatCompletions.ts @@ -22,7 +22,7 @@ export async function main() { const scope = "https://cognitiveservices.azure.com/.default"; const azureADTokenProvider = getBearerTokenProvider(new DefaultAzureCredential(), scope); const deployment = "gpt-35-turbo"; - const apiVersion = "2024-08-01-preview"; + const apiVersion = "2024-10-21"; const client = new AzureOpenAI({ azureADTokenProvider, deployment, apiVersion }); const events = await client.chat.completions.create({ messages: [ diff --git a/sdk/openai/openai/samples-dev/streamChatCompletionsWithContentFilter.ts b/sdk/openai/openai/samples-dev/streamChatCompletionsWithContentFilter.ts index 51706ffc7c88..f95786f8546a 100644 --- a/sdk/openai/openai/samples-dev/streamChatCompletionsWithContentFilter.ts +++ b/sdk/openai/openai/samples-dev/streamChatCompletionsWithContentFilter.ts @@ -23,7 +23,7 @@ export async function main() { const scope = "https://cognitiveservices.azure.com/.default"; const azureADTokenProvider = getBearerTokenProvider(new DefaultAzureCredential(), scope); const deployment = "gpt-35-turbo"; - const apiVersion = "2024-08-01-preview"; + const apiVersion = "2024-10-21"; const client = new AzureOpenAI({ azureADTokenProvider, deployment, apiVersion }); const events = await client.chat.completions.create({ messages: [ diff --git a/sdk/openai/openai/samples-dev/streamCompletions.ts b/sdk/openai/openai/samples-dev/streamCompletions.ts index 5e6f5556224c..aec0cceeccdb 100644 --- a/sdk/openai/openai/samples-dev/streamCompletions.ts +++ b/sdk/openai/openai/samples-dev/streamCompletions.ts @@ -24,7 +24,7 @@ export async function main() { const scope = "https://cognitiveservices.azure.com/.default"; const azureADTokenProvider = getBearerTokenProvider(new DefaultAzureCredential(), scope); const deployment = "text-davinci-003"; - const apiVersion = "2024-08-01-preview"; + const apiVersion = "2024-10-21"; const client = new AzureOpenAI({ azureADTokenProvider, deployment, apiVersion }); const events = await client.completions.create({ prompt, diff --git a/sdk/openai/openai/samples-dev/textToSpeech.ts b/sdk/openai/openai/samples-dev/textToSpeech.ts index cacb74e3d18e..8d3a457243ba 100644 --- a/sdk/openai/openai/samples-dev/textToSpeech.ts +++ b/sdk/openai/openai/samples-dev/textToSpeech.ts @@ -24,7 +24,7 @@ const speechFilePath = process.env["SPEECH_FILE_PATH"] || " { endpoint: process.env.AZURE_OPENAI_ENDPOINT, deployment: process.env.AZURE_OPENAI_DEPLOYMENT, azureADTokenProvider, - apiVersion: "2024-08-01-preview", + apiVersion: "2024-10-21", }); const prompt = req.body.prompt; diff --git a/sdk/openai/openai/samples/cookbook/speechToSpeechChat/app.js b/sdk/openai/openai/samples/cookbook/speechToSpeechChat/app.js index 623519a17dcd..42134108b02f 100644 --- a/sdk/openai/openai/samples/cookbook/speechToSpeechChat/app.js +++ b/sdk/openai/openai/samples/cookbook/speechToSpeechChat/app.js @@ -24,7 +24,7 @@ const openAI = new AzureOpenAI({ endpoint: process.env.AZURE_OPENAI_ENDPOINT, deployment: process.env.AZURE_OPENAI_DEPLOYMENT, azureADTokenProvider, - apiVersion: "2024-08-01-preview", + apiVersion: "2024-10-21", }); app.get("/api/auth", async (req, res) => { diff --git a/sdk/openai/openai/samples/v2-beta/javascript/audioTranscription.js b/sdk/openai/openai/samples/v2-beta/javascript/audioTranscription.js index 481f7da6ac53..9798eff100cd 100644 --- a/sdk/openai/openai/samples/v2-beta/javascript/audioTranscription.js +++ b/sdk/openai/openai/samples/v2-beta/javascript/audioTranscription.js @@ -25,7 +25,7 @@ async function main() { const scope = "https://cognitiveservices.azure.com/.default"; const azureADTokenProvider = getBearerTokenProvider(new DefaultAzureCredential(), scope); const deployment = "whisper-deployment"; - const apiVersion = "2024-08-01-preview"; + const apiVersion = "2024-09-01-preview"; const client = new AzureOpenAI({ azureADTokenProvider, deployment, apiVersion }); const result = await client.audio.transcriptions.create({ model: "", diff --git a/sdk/openai/openai/samples/v2-beta/javascript/audioTranslation.js b/sdk/openai/openai/samples/v2-beta/javascript/audioTranslation.js index 0c4ee0de2669..e1fee6e0c943 100644 --- a/sdk/openai/openai/samples/v2-beta/javascript/audioTranslation.js +++ b/sdk/openai/openai/samples/v2-beta/javascript/audioTranslation.js @@ -25,7 +25,7 @@ async function main() { const scope = "https://cognitiveservices.azure.com/.default"; const azureADTokenProvider = getBearerTokenProvider(new DefaultAzureCredential(), scope); const deployment = "whisper-deployment"; - const apiVersion = "2024-08-01-preview"; + const apiVersion = "2024-09-01-preview"; const client = new AzureOpenAI({ azureADTokenProvider, deployment, apiVersion }); const result = await client.audio.translations.create({ model: "", diff --git a/sdk/openai/openai/samples/v2-beta/javascript/batch.js b/sdk/openai/openai/samples/v2-beta/javascript/batch.js index 037a3e5f68c7..0baa0fb84022 100644 --- a/sdk/openai/openai/samples/v2-beta/javascript/batch.js +++ b/sdk/openai/openai/samples/v2-beta/javascript/batch.js @@ -21,7 +21,7 @@ async function main() { const scope = "https://cognitiveservices.azure.com/.default"; const azureADTokenProvider = getBearerTokenProvider(new DefaultAzureCredential(), scope); const deployment = "gpt-4-turbo"; - const apiVersion = "2024-08-01-preview"; + const apiVersion = "2024-09-01-preview"; const client = new AzureOpenAI({ azureADTokenProvider, deployment, apiVersion }); const batchContent = `{ "custom_id": "request-1", "method": "POST", "url": "/v1/chat/completions", "body": { "model": "${deployment}", "messages": [{ "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is 2+2?" }] } }`; diff --git a/sdk/openai/openai/samples/v2-beta/javascript/chatCompletions.js b/sdk/openai/openai/samples/v2-beta/javascript/chatCompletions.js index 800924d1c6b4..ff32989249d8 100644 --- a/sdk/openai/openai/samples/v2-beta/javascript/chatCompletions.js +++ b/sdk/openai/openai/samples/v2-beta/javascript/chatCompletions.js @@ -21,7 +21,7 @@ async function main() { const scope = "https://cognitiveservices.azure.com/.default"; const azureADTokenProvider = getBearerTokenProvider(new DefaultAzureCredential(), scope); const deployment = "gpt-35-turbo"; - const apiVersion = "2024-08-01-preview"; + const apiVersion = "2024-09-01-preview"; const client = new AzureOpenAI({ azureADTokenProvider, deployment, apiVersion }); const result = await client.chat.completions.create({ messages: [ diff --git a/sdk/openai/openai/samples/v2-beta/javascript/codeInterpreter.js b/sdk/openai/openai/samples/v2-beta/javascript/codeInterpreter.js index 07e314694572..22d582be10bd 100644 --- a/sdk/openai/openai/samples/v2-beta/javascript/codeInterpreter.js +++ b/sdk/openai/openai/samples/v2-beta/javascript/codeInterpreter.js @@ -12,6 +12,7 @@ const { AzureOpenAI } = require("openai"); const { getBearerTokenProvider, DefaultAzureCredential } = require("@azure/identity"); async function main() { + const apiVersion = "2024-09-01-preview"; // Create AzureOpenAI client with Microsoft Entra ID const credential = new DefaultAzureCredential(); const scope = "https://cognitiveservices.azure.com/.default"; @@ -19,6 +20,7 @@ async function main() { const client = new AzureOpenAI({ azureADTokenProvider, + apiVersion, }); // Create an assistant using code interpreter tool diff --git a/sdk/openai/openai/samples/v2-beta/javascript/completions.js b/sdk/openai/openai/samples/v2-beta/javascript/completions.js index 8e5c1230466e..83c64fd3e567 100644 --- a/sdk/openai/openai/samples/v2-beta/javascript/completions.js +++ b/sdk/openai/openai/samples/v2-beta/javascript/completions.js @@ -23,7 +23,7 @@ async function main() { const scope = "https://cognitiveservices.azure.com/.default"; const azureADTokenProvider = getBearerTokenProvider(new DefaultAzureCredential(), scope); const deployment = "text-davinci-003"; - const apiVersion = "2024-08-01-preview"; + const apiVersion = "2024-09-01-preview"; const client = new AzureOpenAI({ azureADTokenProvider, deployment, apiVersion }); const result = await client.completions.create({ prompt, model: "", max_tokens: 128 }); diff --git a/sdk/openai/openai/samples/v2-beta/javascript/embeddings.js b/sdk/openai/openai/samples/v2-beta/javascript/embeddings.js index 40cebb710c6f..9338070e8078 100644 --- a/sdk/openai/openai/samples/v2-beta/javascript/embeddings.js +++ b/sdk/openai/openai/samples/v2-beta/javascript/embeddings.js @@ -23,7 +23,7 @@ async function main() { const scope = "https://cognitiveservices.azure.com/.default"; const azureADTokenProvider = getBearerTokenProvider(new DefaultAzureCredential(), scope); - const apiVersion = "2024-08-01-preview"; + const apiVersion = "2024-09-01-preview"; const deployment = "text-embedding-3-large"; const client = new AzureOpenAI({ azureADTokenProvider, deployment, apiVersion }); const embeddings = await client.embeddings.create({ input, model: "" }); diff --git a/sdk/openai/openai/samples/v2-beta/javascript/images.js b/sdk/openai/openai/samples/v2-beta/javascript/images.js index 2e7bfa49fb4d..4ad30ba2bbd1 100644 --- a/sdk/openai/openai/samples/v2-beta/javascript/images.js +++ b/sdk/openai/openai/samples/v2-beta/javascript/images.js @@ -28,7 +28,7 @@ async function main() { const scope = "https://cognitiveservices.azure.com/.default"; const azureADTokenProvider = getBearerTokenProvider(new DefaultAzureCredential(), scope); const deployment = "dall-e-3"; - const apiVersion = "2024-08-01-preview"; + const apiVersion = "2024-09-01-preview"; const client = new AzureOpenAI({ azureADTokenProvider, deployment, apiVersion }); const results = await client.images.generate({ prompt, model: "", n, size }); diff --git a/sdk/openai/openai/samples/v2-beta/javascript/onYourData.js b/sdk/openai/openai/samples/v2-beta/javascript/onYourData.js index 8e9687f77e94..a2e2eea6a0cc 100644 --- a/sdk/openai/openai/samples/v2-beta/javascript/onYourData.js +++ b/sdk/openai/openai/samples/v2-beta/javascript/onYourData.js @@ -25,7 +25,7 @@ async function main() { const scope = "https://cognitiveservices.azure.com/.default"; const azureADTokenProvider = getBearerTokenProvider(new DefaultAzureCredential(), scope); const deployment = "gpt-4-1106-preview"; - const apiVersion = "2024-08-01-preview"; + const apiVersion = "2024-09-01-preview"; const client = new AzureOpenAI({ azureADTokenProvider, deployment, apiVersion }); const events = await client.chat.completions.create({ stream: true, diff --git a/sdk/openai/openai/samples/v2-beta/javascript/streamChatCompletions.js b/sdk/openai/openai/samples/v2-beta/javascript/streamChatCompletions.js index c87be9711494..63ded82e7bbc 100644 --- a/sdk/openai/openai/samples/v2-beta/javascript/streamChatCompletions.js +++ b/sdk/openai/openai/samples/v2-beta/javascript/streamChatCompletions.js @@ -21,7 +21,7 @@ async function main() { const scope = "https://cognitiveservices.azure.com/.default"; const azureADTokenProvider = getBearerTokenProvider(new DefaultAzureCredential(), scope); const deployment = "gpt-35-turbo"; - const apiVersion = "2024-08-01-preview"; + const apiVersion = "2024-09-01-preview"; const client = new AzureOpenAI({ azureADTokenProvider, deployment, apiVersion }); const events = await client.chat.completions.create({ messages: [ diff --git a/sdk/openai/openai/samples/v2-beta/javascript/streamChatCompletionsWithContentFilter.js b/sdk/openai/openai/samples/v2-beta/javascript/streamChatCompletionsWithContentFilter.js index ab4de3809d2a..a59f6c5a8aa6 100644 --- a/sdk/openai/openai/samples/v2-beta/javascript/streamChatCompletionsWithContentFilter.js +++ b/sdk/openai/openai/samples/v2-beta/javascript/streamChatCompletionsWithContentFilter.js @@ -21,7 +21,7 @@ async function main() { const scope = "https://cognitiveservices.azure.com/.default"; const azureADTokenProvider = getBearerTokenProvider(new DefaultAzureCredential(), scope); const deployment = "gpt-35-turbo"; - const apiVersion = "2024-08-01-preview"; + const apiVersion = "2024-09-01-preview"; const client = new AzureOpenAI({ azureADTokenProvider, deployment, apiVersion }); const events = await client.chat.completions.create({ messages: [ diff --git a/sdk/openai/openai/samples/v2-beta/javascript/streamCompletions.js b/sdk/openai/openai/samples/v2-beta/javascript/streamCompletions.js index 61b913d63ac7..75e00730f3db 100644 --- a/sdk/openai/openai/samples/v2-beta/javascript/streamCompletions.js +++ b/sdk/openai/openai/samples/v2-beta/javascript/streamCompletions.js @@ -23,7 +23,7 @@ async function main() { const scope = "https://cognitiveservices.azure.com/.default"; const azureADTokenProvider = getBearerTokenProvider(new DefaultAzureCredential(), scope); const deployment = "text-davinci-003"; - const apiVersion = "2024-08-01-preview"; + const apiVersion = "2024-09-01-preview"; const client = new AzureOpenAI({ azureADTokenProvider, deployment, apiVersion }); const events = await client.completions.create({ prompt, diff --git a/sdk/openai/openai/samples/v2-beta/javascript/textToSpeech.js b/sdk/openai/openai/samples/v2-beta/javascript/textToSpeech.js index c8970c6f5dea..1db1695da8b4 100644 --- a/sdk/openai/openai/samples/v2-beta/javascript/textToSpeech.js +++ b/sdk/openai/openai/samples/v2-beta/javascript/textToSpeech.js @@ -23,7 +23,7 @@ const speechFilePath = process.env["SPEECH_FILE_PATH"] || ""; + +async function main() { + console.log("== Transcribe Audio Sample =="); + + const scope = "https://cognitiveservices.azure.com/.default"; + const azureADTokenProvider = getBearerTokenProvider(new DefaultAzureCredential(), scope); + const deployment = "whisper-deployment"; + const apiVersion = "2024-10-21"; + const client = new AzureOpenAI({ azureADTokenProvider, deployment, apiVersion }); + const result = await client.audio.transcriptions.create({ + model: "", + file: createReadStream(audioFilePath), + }); + + console.log(`Transcription: ${result.text}`); +} + +main().catch((err) => { + console.error("The sample encountered an error:", err); +}); + +module.exports = { main }; diff --git a/sdk/openai/openai/samples/v2/javascript/audioTranslation.js b/sdk/openai/openai/samples/v2/javascript/audioTranslation.js new file mode 100644 index 000000000000..1ae3c71656b0 --- /dev/null +++ b/sdk/openai/openai/samples/v2/javascript/audioTranslation.js @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** + * Demonstrates how to translate the content of an audio file. + * + * @summary audio translation. + */ + +const { AzureOpenAI } = require("openai"); +const { DefaultAzureCredential, getBearerTokenProvider } = require("@azure/identity"); +const { createReadStream } = require("fs"); + +// Set AZURE_OPENAI_ENDPOINT to the endpoint of your +// OpenAI resource. You can find this in the Azure portal. +// Load the .env file if it exists +require("dotenv/config"); + +// You will need to set these environment variables or edit the following values +const audioFilePath = process.env["AUDIO_FILE_PATH"] || "