From 639a174f968c443d896c978e449d1238febba61d Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 9 Nov 2023 08:14:19 +0000 Subject: [PATCH] CodeGen from PR 26636 in Azure/azure-rest-api-specs [TypeSpec] Upgrade to 0.50.0 (#26636) --- sdk/openai/ci.yml | 2 + sdk/openai/openai/CHANGELOG.md | 87 +-- sdk/openai/openai/api-extractor.json | 25 +- sdk/openai/openai/package.json | 2 +- .../sources/generated/src/OpenAIClient.ts | 119 +++- .../generated/src/api/OpenAIContext.ts | 6 +- .../openai/sources/generated/src/api/index.ts | 6 +- .../sources/generated/src/api/operations.ts | 674 +++++++++++++----- .../openai/sources/generated/src/index.ts | 25 +- .../sources/generated/src/models/index.ts | 25 +- .../sources/generated/src/models/models.ts | 448 +++++++++++- .../sources/generated/src/models/options.ts | 295 +------- .../generated/src/rest/clientDefinitions.ts | 82 ++- .../generated/src/rest/isUnexpected.ts | 43 +- .../sources/generated/src/rest/models.ts | 96 ++- .../generated/src/rest/openAIClient.ts | 20 +- .../generated/src/rest/outputModels.ts | 156 +++- .../sources/generated/src/rest/parameters.ts | 54 +- .../generated/src/rest/pollingHelper.ts | 14 - .../sources/generated/src/rest/responses.ts | 97 ++- sdk/openai/openai/tsconfig.json | 24 +- sdk/openai/openai/tsp-location.yaml | 6 +- 22 files changed, 1585 insertions(+), 721 deletions(-) diff --git a/sdk/openai/ci.yml b/sdk/openai/ci.yml index 6748bc75bb45..a3a9f94129f9 100644 --- a/sdk/openai/ci.yml +++ b/sdk/openai/ci.yml @@ -16,6 +16,8 @@ pr: - feature/* - release/* - hotfix/* + exclude: + - feature/v4 paths: include: - sdk/openai/ diff --git a/sdk/openai/openai/CHANGELOG.md b/sdk/openai/openai/CHANGELOG.md index e553906658b7..06cf76c594c5 100644 --- a/sdk/openai/openai/CHANGELOG.md +++ b/sdk/openai/openai/CHANGELOG.md @@ -1,86 +1,3 @@ -# Release History +## 1.0.0-beta.8 (2023-11-09) -## 1.0.0-beta.8 (Unreleased) - -### Features Added - -### Breaking Changes - -### Bugs Fixed - -### Other Changes - -## 1.0.0-beta.7 (2023-10-25) - -### Bugs Fixed - -- Support Cloudflare workers by only setting the available fields in the `Request` class for the Fetch API. -- Wait before stop listening to the abort signal until after the response stream has been drained to allow for aborting prolonged responses. - -### Other Changes - -- NodeJS v18 is now the minimum version supported. Check out the [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule) for more information on NodeJS support timelines. And check out the [Microsoft Support Policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md#microsoft-support-policy) for more information on Microsoft support timelines. - -## 1.0.0-beta.6 (2023-09-21) - -### Features Added - -- Introduces speech to text and translation capabilities for a wide variety of audio file formats. - - Adds `getAudioTranscription` and `getAudioTranslation` methods for transcribing and translating audio files. The result can be either a simple JSON structure with just a `text` field or a more detailed JSON structure containing the text alongside additional information. In addition, VTT (Web Video Text Tracks), SRT (SubRip Text), and plain text formats are also supported. The type of the result depends on the `format` parameter if specified, otherwise, a simple JSON output is assumed. The methods could take as input an optional text prompt to guide the model's style or continue a previous audio segment. The language of the prompt should match that of the audio file. - - The available model at the time of this release supports the following list of audio file formats: m4a, mp3, wav, ogg, flac, webm, mp4, mpga, mpeg, and oga. - -### Bugs Fixed - -- Returns `usage` information when available. -- Fixes a bug where errors weren't properly being thrown from the streaming methods. -- Returns `error` information in `ContentFilterResults` when available. -- Fixes parsing of `functionCall` in `ChatMessage` objects. - -## 1.0.0-beta.5 (2023-08-25) - -### Features Added - -- (Azure OpenAI specific) Chat completions with your own data is now supported, see [Azure OpenAI's quickstart guide](https://learn.microsoft.com/azure/ai-services/openai/use-your-data-quickstart?tabs=command-line&pivots=programming-language-studio) for details. - - A list of AzureExtensionChatConfiguration may be populated on `ChatCompletionsOptions` via its `azureExtensionOption.extensions` property. These configurations include a type together with a JSON Schema representation of its parameters. The type is used to determine which extension to use when generating chat completions. See the `bringYourOwnData.js` sample for an example of how to use this feature. -- Functions for chat completions are now supported: see [OpenAI's blog post on the topic](https://openai.com/blog/function-calling-and-other-api-updates) for much more detail. - - A list of `FunctionDefinition` objects may be populated on `ChatCompletionsOptions` via its `functions` property. These definitions include a name and description together with a serialized JSON Schema representation of its parameters. - - **NOTE**: Chat Functions requires a minimum of the `-0613` model versions for `gpt-4` and `gpt-3.5-turbo`/`gpt-35-turbo`. Please ensure you're using these later model versions, as Functions are not supported with older model revisions. For Azure OpenAI, you can update a deployment's model version or create a new model deployment with an updated version via the Azure AI Studio interface, also accessible through Azure Portal. -- (Azure OpenAI specific) Completions and Chat Completions responses now include embedded content filter annotations for prompts and responses - -### Breaking Changes - -- Remove `beginAzureBatchImageGeneration` and `getAzureBatchImageGenerationOperationStatus` methods. -- `getImages` has been updated to return the image URLs/payloads directly, rather than requiring the user to call `getAzureBatchImageGenerationOperationStatus` to retrieve them. - -## 1.0.0-beta.4 (2023-08-09) - -### Features Added - -- Exporting individual capabilities as separate functions to be used in code-size-concious applications. For example, streaming completions can be imported individually as follows: - -```js -import { listCompletions, createOpenAI } from "@azure/openai/api"; -const client = createOpenAI(endpoint, new AzureKeyCredential(azureApiKey)); -const events = listCompletions(client, prompt, deploymentId, { maxTokens: 128 }); -``` - -### Bugs Fixed - -- Fix a bug where server-sent events were not being parsed correctly. - -## 1.0.0-beta.3 (2023-07-13) - -### Features Added - -- Added support for batch image generation via `beginAzureBatchImageGeneration` and `getAzureBatchImageGenerationOperationStatus`. -- Added GetImages convenience API for above, as well as supporting ImageGenerationOptions and ImageGenerationResponse aliases. - -## 1.0.0-beta.2 (2023-06-06) - -### Bugs Fixed - -- Fix a bug where the customer-passed options for credentials were overwritten by the defaults values. - -## 1.0.0-beta.1 (2023-05-22) - -- This is the initial beta release for Azure OpenAI inference capabilities, including completions, chat completions, and embeddings. + - Initial Release diff --git a/sdk/openai/openai/api-extractor.json b/sdk/openai/openai/api-extractor.json index 789a58770674..503203dcc456 100644 --- a/sdk/openai/openai/api-extractor.json +++ b/sdk/openai/openai/api-extractor.json @@ -1,18 +1,31 @@ { "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", "mainEntryPointFilePath": "./types/src/index.d.ts", - "docModel": { "enabled": true }, - "apiReport": { "enabled": true, "reportFolder": "./review" }, + "docModel": { + "enabled": true + }, + "apiReport": { + "enabled": true, + "reportFolder": "./review" + }, "dtsRollup": { "enabled": true, "untrimmedFilePath": "", "publicTrimmedFilePath": "./types/openai.d.ts" }, "messages": { - "tsdocMessageReporting": { "default": { "logLevel": "none" } }, + "tsdocMessageReporting": { + "default": { + "logLevel": "none" + } + }, "extractorMessageReporting": { - "ae-missing-release-tag": { "logLevel": "none" }, - "ae-unresolved-link": { "logLevel": "none" } + "ae-missing-release-tag": { + "logLevel": "none" + }, + "ae-unresolved-link": { + "logLevel": "none" + } } } -} +} \ No newline at end of file diff --git a/sdk/openai/openai/package.json b/sdk/openai/openai/package.json index ec70d2e41c65..aaf284dbcc86 100644 --- a/sdk/openai/openai/package.json +++ b/sdk/openai/openai/package.json @@ -156,4 +156,4 @@ "Azure Cognitive Services instance": "https://learn.microsoft.com/azure/cognitive-services/openai/how-to/create-resource" } } -} +} \ No newline at end of file diff --git a/sdk/openai/openai/sources/generated/src/OpenAIClient.ts b/sdk/openai/openai/sources/generated/src/OpenAIClient.ts index 5f30dea02ed4..b32b415d38d0 100644 --- a/sdk/openai/openai/sources/generated/src/OpenAIClient.ts +++ b/sdk/openai/openai/sources/generated/src/OpenAIClient.ts @@ -2,37 +2,55 @@ // Licensed under the MIT license. import { TokenCredential, KeyCredential } from "@azure/core-auth"; +import { Pipeline } from "@azure/core-rest-pipeline"; import { - Embeddings, + AudioTranscriptionOptions, + AudioTranscription, + AudioTranslationOptions, + AudioTranslation, + CompletionsOptions, Completions, - ChatMessage, + ChatCompletionsOptions, ChatCompletions, BatchImageGenerationOperationResponse, + ImageGenerationOptions, + EmbeddingsOptions, + Embeddings, } from "./models/models.js"; import { - GetEmbeddingsOptions, + GetAudioTranscriptionAsPlainTextOptions, + GetAudioTranscriptionAsResponseObjectOptions, + GetAudioTranslationAsPlainTextOptions, + GetAudioTranslationAsResponseObjectOptions, GetCompletionsOptions, GetChatCompletionsOptions, GetChatCompletionsWithAzureExtensionsOptions, GetAzureBatchImageGenerationOperationStatusOptions, BeginAzureBatchImageGenerationOptions, + GetEmbeddingsOptions, } from "./models/options.js"; import { createOpenAI, OpenAIClientOptions, OpenAIContext, - getEmbeddings, + getAudioTranscriptionAsPlainText, + getAudioTranscriptionAsResponseObject, + getAudioTranslationAsPlainText, + getAudioTranslationAsResponseObject, getCompletions, getChatCompletions, getChatCompletionsWithAzureExtensions, getAzureBatchImageGenerationOperationStatus, beginAzureBatchImageGeneration, + getEmbeddings, } from "./api/index.js"; export { OpenAIClientOptions } from "./api/OpenAIContext.js"; export class OpenAIClient { private _client: OpenAIContext; + /** The pipeline used by this client to make requests */ + public readonly pipeline: Pipeline; /** Azure OpenAI APIs for completions and search */ constructor( @@ -41,15 +59,71 @@ export class OpenAIClient { options: OpenAIClientOptions = {} ) { this._client = createOpenAI(endpoint, credential, options); + this.pipeline = this._client.pipeline; } - /** Return the embeddings for a given prompt. */ - getEmbeddings( - input: string[], + /** + * Gets transcribed text and associated metadata from provided spoken audio data. Audio will be transcribed in the + * written language corresponding to the language it was spoken in. + */ + getAudioTranscriptionAsPlainText( deploymentId: string, - options: GetEmbeddingsOptions = { requestOptions: {} } - ): Promise { - return getEmbeddings(this._client, input, deploymentId, options); + body: AudioTranscriptionOptions, + options: GetAudioTranscriptionAsPlainTextOptions = { requestOptions: {} } + ): Promise { + return getAudioTranscriptionAsPlainText( + this._client, + deploymentId, + body, + options + ); + } + + /** + * Gets transcribed text and associated metadata from provided spoken audio data. Audio will be transcribed in the + * written language corresponding to the language it was spoken in. + */ + getAudioTranscriptionAsResponseObject( + deploymentId: string, + body: AudioTranscriptionOptions, + options: GetAudioTranscriptionAsResponseObjectOptions = { + requestOptions: {}, + } + ): Promise { + return getAudioTranscriptionAsResponseObject( + this._client, + deploymentId, + body, + options + ); + } + + /** Gets English language transcribed text and associated metadata from provided spoken audio data. */ + getAudioTranslationAsPlainText( + deploymentId: string, + body: AudioTranslationOptions, + options: GetAudioTranslationAsPlainTextOptions = { requestOptions: {} } + ): Promise { + return getAudioTranslationAsPlainText( + this._client, + deploymentId, + body, + options + ); + } + + /** Gets English language transcribed text and associated metadata from provided spoken audio data. */ + getAudioTranslationAsResponseObject( + deploymentId: string, + body: AudioTranslationOptions, + options: GetAudioTranslationAsResponseObjectOptions = { requestOptions: {} } + ): Promise { + return getAudioTranslationAsResponseObject( + this._client, + deploymentId, + body, + options + ); } /** @@ -58,11 +132,11 @@ export class OpenAIClient { * provided prompt data. */ getCompletions( - prompt: string[], deploymentId: string, + body: CompletionsOptions, options: GetCompletionsOptions = { requestOptions: {} } ): Promise { - return getCompletions(this._client, prompt, deploymentId, options); + return getCompletions(this._client, deploymentId, body, options); } /** @@ -71,11 +145,11 @@ export class OpenAIClient { * provided prompt data. */ getChatCompletions( - messages: ChatMessage[], deploymentId: string, + body: ChatCompletionsOptions, options: GetChatCompletionsOptions = { requestOptions: {} } ): Promise { - return getChatCompletions(this._client, messages, deploymentId, options); + return getChatCompletions(this._client, deploymentId, body, options); } /** @@ -84,16 +158,16 @@ export class OpenAIClient { * other augmentations to the base chat completions capabilities. */ getChatCompletionsWithAzureExtensions( - messages: ChatMessage[], deploymentId: string, + body: ChatCompletionsOptions, options: GetChatCompletionsWithAzureExtensionsOptions = { requestOptions: {}, } ): Promise { return getChatCompletionsWithAzureExtensions( this._client, - messages, deploymentId, + body, options ); } @@ -114,9 +188,18 @@ export class OpenAIClient { /** Starts the generation of a batch of images from a text caption */ beginAzureBatchImageGeneration( - prompt: string, + body: ImageGenerationOptions, options: BeginAzureBatchImageGenerationOptions = { requestOptions: {} } ): Promise { - return beginAzureBatchImageGeneration(this._client, prompt, options); + return beginAzureBatchImageGeneration(this._client, body, options); + } + + /** Return the embeddings for a given prompt. */ + getEmbeddings( + deploymentId: string, + body: EmbeddingsOptions, + options: GetEmbeddingsOptions = { requestOptions: {} } + ): Promise { + return getEmbeddings(this._client, deploymentId, body, options); } } diff --git a/sdk/openai/openai/sources/generated/src/api/OpenAIContext.ts b/sdk/openai/openai/sources/generated/src/api/OpenAIContext.ts index 508410b53c7a..e7d5725dd7e1 100644 --- a/sdk/openai/openai/sources/generated/src/api/OpenAIContext.ts +++ b/sdk/openai/openai/sources/generated/src/api/OpenAIContext.ts @@ -1,10 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. +import { TokenCredential, KeyCredential } from "@azure/core-auth"; import { ClientOptions } from "@azure-rest/core-client"; import { OpenAIContext } from "../rest/index.js"; -import { KeyCredential } from "@azure/core-auth"; -import { TokenCredential } from "@azure/core-auth"; import getClient from "../rest/index.js"; export interface OpenAIClientOptions extends ClientOptions {} @@ -17,7 +16,6 @@ export function createOpenAI( credential: KeyCredential | TokenCredential, options: OpenAIClientOptions = {} ): OpenAIContext { - const baseUrl = endpoint; - const clientContext = getClient(baseUrl, credential, options); + const clientContext = getClient(endpoint, credential, options); return clientContext; } diff --git a/sdk/openai/openai/sources/generated/src/api/index.ts b/sdk/openai/openai/sources/generated/src/api/index.ts index c1cbf151a9e9..981fa35db337 100644 --- a/sdk/openai/openai/sources/generated/src/api/index.ts +++ b/sdk/openai/openai/sources/generated/src/api/index.ts @@ -7,10 +7,14 @@ export { OpenAIContext, } from "./OpenAIContext.js"; export { - getEmbeddings, + getAudioTranscriptionAsPlainText, + getAudioTranscriptionAsResponseObject, + getAudioTranslationAsPlainText, + getAudioTranslationAsResponseObject, getCompletions, getChatCompletions, getChatCompletionsWithAzureExtensions, getAzureBatchImageGenerationOperationStatus, beginAzureBatchImageGeneration, + getEmbeddings, } from "./operations.js"; diff --git a/sdk/openai/openai/sources/generated/src/api/operations.ts b/sdk/openai/openai/sources/generated/src/api/operations.ts index b9f0cd4c6043..ccd9b0d279c0 100644 --- a/sdk/openai/openai/sources/generated/src/api/operations.ts +++ b/sdk/openai/openai/sources/generated/src/api/operations.ts @@ -2,19 +2,33 @@ // Licensed under the MIT license. import { - Embeddings, + AudioTranscriptionOptions, + AudioTranscription, + AudioTranslationOptions, + AudioTranslation, + CompletionsOptions, Completions, - ChatMessage, + ChatCompletionsOptions, ChatCompletions, BatchImageGenerationOperationResponse, + ImageGenerationOptions, + EmbeddingsOptions, + Embeddings, } from "../models/models.js"; import { BeginAzureBatchImageGeneration202Response, BeginAzureBatchImageGenerationDefaultResponse, BeginAzureBatchImageGenerationLogicalResponse, + GetAudioTranscriptionAsPlainText200Response, + GetAudioTranscriptionAsPlainTextDefaultResponse, + GetAudioTranscriptionAsResponseObject200Response, + GetAudioTranscriptionAsResponseObjectDefaultResponse, + GetAudioTranslationAsPlainText200Response, + GetAudioTranslationAsPlainTextDefaultResponse, + GetAudioTranslationAsResponseObject200Response, + GetAudioTranslationAsResponseObjectDefaultResponse, GetAzureBatchImageGenerationOperationStatus200Response, GetAzureBatchImageGenerationOperationStatusDefaultResponse, - GetAzureBatchImageGenerationOperationStatusLogicalResponse, GetChatCompletions200Response, GetChatCompletionsDefaultResponse, GetChatCompletionsWithAzureExtensions200Response, @@ -30,68 +44,272 @@ import { StreamableMethod, operationOptionsToRequestParameters, } from "@azure-rest/core-client"; +import { uint8ArrayToString } from "@azure/core-util"; import { - GetEmbeddingsOptions, + GetAudioTranscriptionAsPlainTextOptions, + GetAudioTranscriptionAsResponseObjectOptions, + GetAudioTranslationAsPlainTextOptions, + GetAudioTranslationAsResponseObjectOptions, GetCompletionsOptions, GetChatCompletionsOptions, GetChatCompletionsWithAzureExtensionsOptions, GetAzureBatchImageGenerationOperationStatusOptions, BeginAzureBatchImageGenerationOptions, + GetEmbeddingsOptions, } from "../models/options.js"; -export function _getEmbeddingsSend( +export function _getAudioTranscriptionAsPlainTextSend( context: Client, - input: string[], deploymentId: string, - options: GetEmbeddingsOptions = { requestOptions: {} } -): StreamableMethod { + body: AudioTranscriptionOptions, + options: GetAudioTranscriptionAsPlainTextOptions = { requestOptions: {} } +): StreamableMethod< + | GetAudioTranscriptionAsPlainText200Response + | GetAudioTranscriptionAsPlainTextDefaultResponse +> { return context - .path("/deployments/{deploymentId}/embeddings", deploymentId) + .path("/deployments/{deploymentId}/audio/transcriptions", deploymentId) .post({ ...operationOptionsToRequestParameters(options), - body: { user: options?.user, model: options?.model, input: input }, + body: { + file: uint8ArrayToString(body["file"], "base64"), + response_format: body["responseFormat"], + language: body["language"], + prompt: body["prompt"], + temperature: body["temperature"], + model: body["model"], + }, }); } -export async function _getEmbeddingsDeserialize( - result: GetEmbeddings200Response | GetEmbeddingsDefaultResponse -): Promise { +export async function _getAudioTranscriptionAsPlainTextDeserialize( + result: + | GetAudioTranscriptionAsPlainText200Response + | GetAudioTranscriptionAsPlainTextDefaultResponse +): Promise { + if (isUnexpected(result)) { + throw result.body; + } + + return result.body; +} + +/** + * Gets transcribed text and associated metadata from provided spoken audio data. Audio will be transcribed in the + * written language corresponding to the language it was spoken in. + */ +export async function getAudioTranscriptionAsPlainText( + context: Client, + deploymentId: string, + body: AudioTranscriptionOptions, + options: GetAudioTranscriptionAsPlainTextOptions = { requestOptions: {} } +): Promise { + const result = await _getAudioTranscriptionAsPlainTextSend( + context, + deploymentId, + body, + options + ); + return _getAudioTranscriptionAsPlainTextDeserialize(result); +} + +export function _getAudioTranscriptionAsResponseObjectSend( + context: Client, + deploymentId: string, + body: AudioTranscriptionOptions, + options: GetAudioTranscriptionAsResponseObjectOptions = { requestOptions: {} } +): StreamableMethod< + | GetAudioTranscriptionAsResponseObject200Response + | GetAudioTranscriptionAsResponseObjectDefaultResponse +> { + return context + .path("/deployments/{deploymentId}/audio/transcriptions", deploymentId) + .post({ + ...operationOptionsToRequestParameters(options), + contentType: (options.contentType as any) ?? "multipart/form-data", + body: { + file: uint8ArrayToString(body["file"], "base64"), + response_format: body["responseFormat"], + language: body["language"], + prompt: body["prompt"], + temperature: body["temperature"], + model: body["model"], + }, + }); +} + +export async function _getAudioTranscriptionAsResponseObjectDeserialize( + result: + | GetAudioTranscriptionAsResponseObject200Response + | GetAudioTranscriptionAsResponseObjectDefaultResponse +): Promise { if (isUnexpected(result)) { - throw result.body.error; + throw result.body; } return { - data: (result.body["data"] ?? []).map((p) => ({ - embedding: p["embedding"], - index: p["index"], + text: result.body["text"], + task: result.body["task"], + language: result.body["language"], + duration: result.body["duration"], + segments: (result.body["segments"] ?? []).map((p) => ({ + id: p["id"], + start: p["start"], + end: p["end"], + text: p["text"], + temperature: p["temperature"], + avgLogprob: p["avg_logprob"], + compressionRatio: p["compression_ratio"], + noSpeechProb: p["no_speech_prob"], + tokens: p["tokens"], + seek: p["seek"], })), - usage: { - promptTokens: result.body.usage["prompt_tokens"], - totalTokens: result.body.usage["total_tokens"], - }, }; } -/** Return the embeddings for a given prompt. */ -export async function getEmbeddings( +/** + * Gets transcribed text and associated metadata from provided spoken audio data. Audio will be transcribed in the + * written language corresponding to the language it was spoken in. + */ +export async function getAudioTranscriptionAsResponseObject( context: Client, - input: string[], deploymentId: string, - options: GetEmbeddingsOptions = { requestOptions: {} } -): Promise { - const result = await _getEmbeddingsSend( + body: AudioTranscriptionOptions, + options: GetAudioTranscriptionAsResponseObjectOptions = { requestOptions: {} } +): Promise { + const result = await _getAudioTranscriptionAsResponseObjectSend( context, - input, deploymentId, + body, options ); - return _getEmbeddingsDeserialize(result); + return _getAudioTranscriptionAsResponseObjectDeserialize(result); +} + +export function _getAudioTranslationAsPlainTextSend( + context: Client, + deploymentId: string, + body: AudioTranslationOptions, + options: GetAudioTranslationAsPlainTextOptions = { requestOptions: {} } +): StreamableMethod< + | GetAudioTranslationAsPlainText200Response + | GetAudioTranslationAsPlainTextDefaultResponse +> { + return context + .path("/deployments/{deploymentId}/audio/translations", deploymentId) + .post({ + ...operationOptionsToRequestParameters(options), + body: { + file: uint8ArrayToString(body["file"], "base64"), + response_format: body["responseFormat"], + prompt: body["prompt"], + temperature: body["temperature"], + model: body["model"], + }, + }); +} + +export async function _getAudioTranslationAsPlainTextDeserialize( + result: + | GetAudioTranslationAsPlainText200Response + | GetAudioTranslationAsPlainTextDefaultResponse +): Promise { + if (isUnexpected(result)) { + throw result.body; + } + + return result.body; +} + +/** Gets English language transcribed text and associated metadata from provided spoken audio data. */ +export async function getAudioTranslationAsPlainText( + context: Client, + deploymentId: string, + body: AudioTranslationOptions, + options: GetAudioTranslationAsPlainTextOptions = { requestOptions: {} } +): Promise { + const result = await _getAudioTranslationAsPlainTextSend( + context, + deploymentId, + body, + options + ); + return _getAudioTranslationAsPlainTextDeserialize(result); +} + +export function _getAudioTranslationAsResponseObjectSend( + context: Client, + deploymentId: string, + body: AudioTranslationOptions, + options: GetAudioTranslationAsResponseObjectOptions = { requestOptions: {} } +): StreamableMethod< + | GetAudioTranslationAsResponseObject200Response + | GetAudioTranslationAsResponseObjectDefaultResponse +> { + return context + .path("/deployments/{deploymentId}/audio/translations", deploymentId) + .post({ + ...operationOptionsToRequestParameters(options), + contentType: (options.contentType as any) ?? "multipart/form-data", + body: { + file: uint8ArrayToString(body["file"], "base64"), + response_format: body["responseFormat"], + prompt: body["prompt"], + temperature: body["temperature"], + model: body["model"], + }, + }); +} + +export async function _getAudioTranslationAsResponseObjectDeserialize( + result: + | GetAudioTranslationAsResponseObject200Response + | GetAudioTranslationAsResponseObjectDefaultResponse +): Promise { + if (isUnexpected(result)) { + throw result.body; + } + + return { + text: result.body["text"], + task: result.body["task"], + language: result.body["language"], + duration: result.body["duration"], + segments: (result.body["segments"] ?? []).map((p) => ({ + id: p["id"], + start: p["start"], + end: p["end"], + text: p["text"], + temperature: p["temperature"], + avgLogprob: p["avg_logprob"], + compressionRatio: p["compression_ratio"], + noSpeechProb: p["no_speech_prob"], + tokens: p["tokens"], + seek: p["seek"], + })), + }; +} + +/** Gets English language transcribed text and associated metadata from provided spoken audio data. */ +export async function getAudioTranslationAsResponseObject( + context: Client, + deploymentId: string, + body: AudioTranslationOptions, + options: GetAudioTranslationAsResponseObjectOptions = { requestOptions: {} } +): Promise { + const result = await _getAudioTranslationAsResponseObjectSend( + context, + deploymentId, + body, + options + ); + return _getAudioTranslationAsResponseObjectDeserialize(result); } export function _getCompletionsSend( context: Client, - prompt: string[], deploymentId: string, + body: CompletionsOptions, options: GetCompletionsOptions = { requestOptions: {} } ): StreamableMethod { return context @@ -99,21 +317,21 @@ export function _getCompletionsSend( .post({ ...operationOptionsToRequestParameters(options), body: { - prompt: prompt, - max_tokens: options?.maxTokens, - temperature: options?.temperature, - top_p: options?.topP, - logit_bias: options?.logitBias, - user: options?.user, - n: options?.n, - logprobs: options?.logprobs, - echo: options?.echo, - stop: options?.stop, - presence_penalty: options?.presencePenalty, - frequency_penalty: options?.frequencyPenalty, - best_of: options?.bestOf, - stream: options?.stream, - model: options?.model, + prompt: body["prompt"], + max_tokens: body["maxTokens"], + temperature: body["temperature"], + top_p: body["topP"], + logit_bias: body["logitBias"], + user: body["user"], + n: body["n"], + logprobs: body["logprobs"], + echo: body["echo"], + stop: body["stop"], + presence_penalty: body["presencePenalty"], + frequency_penalty: body["frequencyPenalty"], + best_of: body["bestOf"], + stream: body["stream"], + model: body["model"], }, }); } @@ -122,43 +340,48 @@ export async function _getCompletionsDeserialize( result: GetCompletions200Response | GetCompletionsDefaultResponse ): Promise { if (isUnexpected(result)) { - throw result.body.error; + throw result.body; } return { id: result.body["id"], created: new Date(result.body["created"]), - promptFilterResults: (result.body["prompt_annotations"] ?? []).map((p) => ({ - promptIndex: p["prompt_index"], - contentFilterResults: !p.content_filter_results - ? undefined - : { - sexual: !p.content_filter_results?.sexual - ? undefined - : { - severity: p.content_filter_results?.sexual?.["severity"], - filtered: p.content_filter_results?.sexual?.["filtered"], - }, - violence: !p.content_filter_results?.violence - ? undefined - : { - severity: p.content_filter_results?.violence?.["severity"], - filtered: p.content_filter_results?.violence?.["filtered"], - }, - hate: !p.content_filter_results?.hate - ? undefined - : { - severity: p.content_filter_results?.hate?.["severity"], - filtered: p.content_filter_results?.hate?.["filtered"], - }, - selfHarm: !p.content_filter_results?.self_harm - ? undefined - : { - severity: p.content_filter_results?.self_harm?.["severity"], - filtered: p.content_filter_results?.self_harm?.["filtered"], - }, - }, - })), + promptFilterResults: (result.body["prompt_filter_results"] ?? []).map( + (p) => ({ + promptIndex: p["prompt_index"], + contentFilterResults: !p.content_filter_results + ? undefined + : { + sexual: !p.content_filter_results?.sexual + ? undefined + : { + severity: p.content_filter_results?.sexual?.["severity"], + filtered: p.content_filter_results?.sexual?.["filtered"], + }, + violence: !p.content_filter_results?.violence + ? undefined + : { + severity: p.content_filter_results?.violence?.["severity"], + filtered: p.content_filter_results?.violence?.["filtered"], + }, + hate: !p.content_filter_results?.hate + ? undefined + : { + severity: p.content_filter_results?.hate?.["severity"], + filtered: p.content_filter_results?.hate?.["filtered"], + }, + selfHarm: !p.content_filter_results?.self_harm + ? undefined + : { + severity: p.content_filter_results?.self_harm?.["severity"], + filtered: p.content_filter_results?.self_harm?.["filtered"], + }, + error: !p.content_filter_results?.error + ? undefined + : p.content_filter_results?.error, + }, + }) + ), choices: (result.body["choices"] ?? []).map((p) => ({ text: p["text"], index: p["index"], @@ -189,6 +412,9 @@ export async function _getCompletionsDeserialize( severity: p.content_filter_results?.self_harm?.["severity"], filtered: p.content_filter_results?.self_harm?.["filtered"], }, + error: !p.content_filter_results?.error + ? undefined + : p.content_filter_results?.error, }, logprobs: p.logprobs === null @@ -216,14 +442,14 @@ export async function _getCompletionsDeserialize( */ export async function getCompletions( context: Client, - prompt: string[], deploymentId: string, + body: CompletionsOptions, options: GetCompletionsOptions = { requestOptions: {} } ): Promise { const result = await _getCompletionsSend( context, - prompt, deploymentId, + body, options ); return _getCompletionsDeserialize(result); @@ -231,8 +457,8 @@ export async function getCompletions( export function _getChatCompletionsSend( context: Client, - messages: ChatMessage[], deploymentId: string, + body: ChatCompletionsOptions, options: GetChatCompletionsOptions = { requestOptions: {} } ): StreamableMethod< GetChatCompletions200Response | GetChatCompletionsDefaultResponse @@ -242,21 +468,28 @@ export function _getChatCompletionsSend( .post({ ...operationOptionsToRequestParameters(options), body: { - messages: messages, - functions: options?.functions, - function_call: options?.functionCall, - max_tokens: options?.maxTokens, - temperature: options?.temperature, - top_p: options?.topP, - logit_bias: options?.logitBias, - user: options?.user, - n: options?.n, - stop: options?.stop, - presence_penalty: options?.presencePenalty, - frequency_penalty: options?.frequencyPenalty, - stream: options?.stream, - model: options?.model, - dataSources: options?.dataSources, + messages: body.messages as any, + functions: (body["functions"] ?? []).map((p) => ({ + name: p["name"], + description: p["description"], + parameters: p["parameters"], + })), + function_call: body["functionCall"], + max_tokens: body["maxTokens"], + temperature: body["temperature"], + top_p: body["topP"], + logit_bias: body["logitBias"], + user: body["user"], + n: body["n"], + stop: body["stop"], + presence_penalty: body["presencePenalty"], + frequency_penalty: body["frequencyPenalty"], + stream: body["stream"], + model: body["model"], + dataSources: (body["dataSources"] ?? []).map((p) => ({ + type: p["type"], + parameters: p["parameters"], + })), }, }); } @@ -265,7 +498,7 @@ export async function _getChatCompletionsDeserialize( result: GetChatCompletions200Response | GetChatCompletionsDefaultResponse ): Promise { if (isUnexpected(result)) { - throw result.body.error; + throw result.body; } return { @@ -322,39 +555,47 @@ export async function _getChatCompletionsDeserialize( severity: p.content_filter_results?.self_harm?.["severity"], filtered: p.content_filter_results?.self_harm?.["filtered"], }, - }, - })), - promptFilterResults: (result.body["prompt_annotations"] ?? []).map((p) => ({ - promptIndex: p["prompt_index"], - contentFilterResults: !p.content_filter_results - ? undefined - : { - sexual: !p.content_filter_results?.sexual - ? undefined - : { - severity: p.content_filter_results?.sexual?.["severity"], - filtered: p.content_filter_results?.sexual?.["filtered"], - }, - violence: !p.content_filter_results?.violence - ? undefined - : { - severity: p.content_filter_results?.violence?.["severity"], - filtered: p.content_filter_results?.violence?.["filtered"], - }, - hate: !p.content_filter_results?.hate - ? undefined - : { - severity: p.content_filter_results?.hate?.["severity"], - filtered: p.content_filter_results?.hate?.["filtered"], - }, - selfHarm: !p.content_filter_results?.self_harm + error: !p.content_filter_results?.error ? undefined - : { - severity: p.content_filter_results?.self_harm?.["severity"], - filtered: p.content_filter_results?.self_harm?.["filtered"], - }, + : p.content_filter_results?.error, }, })), + promptFilterResults: (result.body["prompt_filter_results"] ?? []).map( + (p) => ({ + promptIndex: p["prompt_index"], + contentFilterResults: !p.content_filter_results + ? undefined + : { + sexual: !p.content_filter_results?.sexual + ? undefined + : { + severity: p.content_filter_results?.sexual?.["severity"], + filtered: p.content_filter_results?.sexual?.["filtered"], + }, + violence: !p.content_filter_results?.violence + ? undefined + : { + severity: p.content_filter_results?.violence?.["severity"], + filtered: p.content_filter_results?.violence?.["filtered"], + }, + hate: !p.content_filter_results?.hate + ? undefined + : { + severity: p.content_filter_results?.hate?.["severity"], + filtered: p.content_filter_results?.hate?.["filtered"], + }, + selfHarm: !p.content_filter_results?.self_harm + ? undefined + : { + severity: p.content_filter_results?.self_harm?.["severity"], + filtered: p.content_filter_results?.self_harm?.["filtered"], + }, + error: !p.content_filter_results?.error + ? undefined + : p.content_filter_results?.error, + }, + }) + ), usage: { completionTokens: result.body.usage["completion_tokens"], promptTokens: result.body.usage["prompt_tokens"], @@ -370,14 +611,14 @@ export async function _getChatCompletionsDeserialize( */ export async function getChatCompletions( context: Client, - messages: ChatMessage[], deploymentId: string, + body: ChatCompletionsOptions, options: GetChatCompletionsOptions = { requestOptions: {} } ): Promise { const result = await _getChatCompletionsSend( context, - messages, deploymentId, + body, options ); return _getChatCompletionsDeserialize(result); @@ -385,8 +626,8 @@ export async function getChatCompletions( export function _getChatCompletionsWithAzureExtensionsSend( context: Client, - messages: ChatMessage[], deploymentId: string, + body: ChatCompletionsOptions, options: GetChatCompletionsWithAzureExtensionsOptions = { requestOptions: {} } ): StreamableMethod< | GetChatCompletionsWithAzureExtensions200Response @@ -400,21 +641,28 @@ export function _getChatCompletionsWithAzureExtensionsSend( .post({ ...operationOptionsToRequestParameters(options), body: { - messages: messages, - functions: options?.functions, - function_call: options?.functionCall, - max_tokens: options?.maxTokens, - temperature: options?.temperature, - top_p: options?.topP, - logit_bias: options?.logitBias, - user: options?.user, - n: options?.n, - stop: options?.stop, - presence_penalty: options?.presencePenalty, - frequency_penalty: options?.frequencyPenalty, - stream: options?.stream, - model: options?.model, - dataSources: options?.dataSources, + messages: body.messages as any, + functions: (body["functions"] ?? []).map((p) => ({ + name: p["name"], + description: p["description"], + parameters: p["parameters"], + })), + function_call: body["functionCall"], + max_tokens: body["maxTokens"], + temperature: body["temperature"], + top_p: body["topP"], + logit_bias: body["logitBias"], + user: body["user"], + n: body["n"], + stop: body["stop"], + presence_penalty: body["presencePenalty"], + frequency_penalty: body["frequencyPenalty"], + stream: body["stream"], + model: body["model"], + dataSources: (body["dataSources"] ?? []).map((p) => ({ + type: p["type"], + parameters: p["parameters"], + })), }, }); } @@ -482,39 +730,47 @@ export async function _getChatCompletionsWithAzureExtensionsDeserialize( severity: p.content_filter_results?.self_harm?.["severity"], filtered: p.content_filter_results?.self_harm?.["filtered"], }, - }, - })), - promptFilterResults: (result.body["prompt_annotations"] ?? []).map((p) => ({ - promptIndex: p["prompt_index"], - contentFilterResults: !p.content_filter_results - ? undefined - : { - sexual: !p.content_filter_results?.sexual + error: !p.content_filter_results?.error ? undefined - : { - severity: p.content_filter_results?.sexual?.["severity"], - filtered: p.content_filter_results?.sexual?.["filtered"], - }, - violence: !p.content_filter_results?.violence - ? undefined - : { - severity: p.content_filter_results?.violence?.["severity"], - filtered: p.content_filter_results?.violence?.["filtered"], - }, - hate: !p.content_filter_results?.hate - ? undefined - : { - severity: p.content_filter_results?.hate?.["severity"], - filtered: p.content_filter_results?.hate?.["filtered"], - }, - selfHarm: !p.content_filter_results?.self_harm - ? undefined - : { - severity: p.content_filter_results?.self_harm?.["severity"], - filtered: p.content_filter_results?.self_harm?.["filtered"], - }, + : p.content_filter_results?.error, }, })), + promptFilterResults: (result.body["prompt_filter_results"] ?? []).map( + (p) => ({ + promptIndex: p["prompt_index"], + contentFilterResults: !p.content_filter_results + ? undefined + : { + sexual: !p.content_filter_results?.sexual + ? undefined + : { + severity: p.content_filter_results?.sexual?.["severity"], + filtered: p.content_filter_results?.sexual?.["filtered"], + }, + violence: !p.content_filter_results?.violence + ? undefined + : { + severity: p.content_filter_results?.violence?.["severity"], + filtered: p.content_filter_results?.violence?.["filtered"], + }, + hate: !p.content_filter_results?.hate + ? undefined + : { + severity: p.content_filter_results?.hate?.["severity"], + filtered: p.content_filter_results?.hate?.["filtered"], + }, + selfHarm: !p.content_filter_results?.self_harm + ? undefined + : { + severity: p.content_filter_results?.self_harm?.["severity"], + filtered: p.content_filter_results?.self_harm?.["filtered"], + }, + error: !p.content_filter_results?.error + ? undefined + : p.content_filter_results?.error, + }, + }) + ), usage: { completionTokens: result.body.usage["completion_tokens"], promptTokens: result.body.usage["prompt_tokens"], @@ -530,14 +786,14 @@ export async function _getChatCompletionsWithAzureExtensionsDeserialize( */ export async function getChatCompletionsWithAzureExtensions( context: Client, - messages: ChatMessage[], deploymentId: string, + body: ChatCompletionsOptions, options: GetChatCompletionsWithAzureExtensionsOptions = { requestOptions: {} } ): Promise { const result = await _getChatCompletionsWithAzureExtensionsSend( context, - messages, deploymentId, + body, options ); return _getChatCompletionsWithAzureExtensionsDeserialize(result); @@ -552,7 +808,6 @@ export function _getAzureBatchImageGenerationOperationStatusSend( ): StreamableMethod< | GetAzureBatchImageGenerationOperationStatus200Response | GetAzureBatchImageGenerationOperationStatusDefaultResponse - | GetAzureBatchImageGenerationOperationStatusLogicalResponse > { return context .path("/operations/images/{operationId}", operationId) @@ -563,10 +818,9 @@ export async function _getAzureBatchImageGenerationOperationStatusDeserialize( result: | GetAzureBatchImageGenerationOperationStatus200Response | GetAzureBatchImageGenerationOperationStatusDefaultResponse - | GetAzureBatchImageGenerationOperationStatusLogicalResponse ): Promise { if (isUnexpected(result)) { - throw result.body.error; + throw result.body; } return { @@ -602,7 +856,7 @@ export async function getAzureBatchImageGenerationOperationStatus( export function _beginAzureBatchImageGenerationSend( context: Client, - prompt: string, + body: ImageGenerationOptions, options: BeginAzureBatchImageGenerationOptions = { requestOptions: {} } ): StreamableMethod< | BeginAzureBatchImageGeneration202Response @@ -614,11 +868,11 @@ export function _beginAzureBatchImageGenerationSend( .post({ ...operationOptionsToRequestParameters(options), body: { - prompt: prompt, - n: options?.n, - size: options?.size, - response_format: options?.responseFormat, - user: options?.user, + prompt: body["prompt"], + n: body["n"], + size: body["size"], + response_format: body["responseFormat"], + user: body["user"], }, }); } @@ -630,7 +884,7 @@ export async function _beginAzureBatchImageGenerationDeserialize( | BeginAzureBatchImageGenerationLogicalResponse ): Promise { if (isUnexpected(result)) { - throw result.body.error; + throw result.body; } return { @@ -651,13 +905,57 @@ export async function _beginAzureBatchImageGenerationDeserialize( /** Starts the generation of a batch of images from a text caption */ export async function beginAzureBatchImageGeneration( context: Client, - prompt: string, + body: ImageGenerationOptions, options: BeginAzureBatchImageGenerationOptions = { requestOptions: {} } ): Promise { const result = await _beginAzureBatchImageGenerationSend( context, - prompt, + body, options ); return _beginAzureBatchImageGenerationDeserialize(result); } + +export function _getEmbeddingsSend( + context: Client, + deploymentId: string, + body: EmbeddingsOptions, + options: GetEmbeddingsOptions = { requestOptions: {} } +): StreamableMethod { + return context + .path("/deployments/{deploymentId}/embeddings", deploymentId) + .post({ + ...operationOptionsToRequestParameters(options), + body: { user: body["user"], model: body["model"], input: body["input"] }, + }); +} + +export async function _getEmbeddingsDeserialize( + result: GetEmbeddings200Response | GetEmbeddingsDefaultResponse +): Promise { + if (isUnexpected(result)) { + throw result.body; + } + + return { + data: (result.body["data"] ?? []).map((p) => ({ + embedding: p["embedding"], + index: p["index"], + })), + usage: { + promptTokens: result.body.usage["prompt_tokens"], + totalTokens: result.body.usage["total_tokens"], + }, + }; +} + +/** Return the embeddings for a given prompt. */ +export async function getEmbeddings( + context: Client, + deploymentId: string, + body: EmbeddingsOptions, + options: GetEmbeddingsOptions = { requestOptions: {} } +): Promise { + const result = await _getEmbeddingsSend(context, deploymentId, body, options); + return _getEmbeddingsDeserialize(result); +} diff --git a/sdk/openai/openai/sources/generated/src/index.ts b/sdk/openai/openai/sources/generated/src/index.ts index 1f84fadf750f..0df0dc103d7f 100644 --- a/sdk/openai/openai/sources/generated/src/index.ts +++ b/sdk/openai/openai/sources/generated/src/index.ts @@ -3,9 +3,16 @@ export { OpenAIClient, OpenAIClientOptions } from "./OpenAIClient.js"; export { - Embeddings, - EmbeddingItem, - EmbeddingsUsage, + AudioTranscriptionOptions, + AudioTranscriptionFormat, + AudioTranscription, + AudioTaskLabel, + AudioTranscriptionSegment, + AudioTranslationOptions, + AudioTranslationFormat, + AudioTranslation, + AudioTranslationSegment, + CompletionsOptions, Completions, PromptFilterResult, ContentFilterResults, @@ -15,6 +22,7 @@ export { CompletionsLogProbabilityModel, CompletionsFinishReason, CompletionsUsage, + ChatCompletionsOptions, ChatMessage, ChatRole, FunctionCall, @@ -31,12 +39,21 @@ export { ImageLocation, ImagePayload, AzureOpenAIOperationState, + ImageGenerationOptions, ImageSize, ImageGenerationResponseFormat, - GetEmbeddingsOptions, + EmbeddingsOptions, + Embeddings, + EmbeddingItem, + EmbeddingsUsage, + GetAudioTranscriptionAsPlainTextOptions, + GetAudioTranscriptionAsResponseObjectOptions, + GetAudioTranslationAsPlainTextOptions, + GetAudioTranslationAsResponseObjectOptions, GetCompletionsOptions, GetChatCompletionsOptions, GetChatCompletionsWithAzureExtensionsOptions, GetAzureBatchImageGenerationOperationStatusOptions, BeginAzureBatchImageGenerationOptions, + GetEmbeddingsOptions, } from "./models/index.js"; diff --git a/sdk/openai/openai/sources/generated/src/models/index.ts b/sdk/openai/openai/sources/generated/src/models/index.ts index 3ae2dac66dd3..2c4c65aefbd6 100644 --- a/sdk/openai/openai/sources/generated/src/models/index.ts +++ b/sdk/openai/openai/sources/generated/src/models/index.ts @@ -2,9 +2,16 @@ // Licensed under the MIT license. export { - Embeddings, - EmbeddingItem, - EmbeddingsUsage, + AudioTranscriptionOptions, + AudioTranscriptionFormat, + AudioTranscription, + AudioTaskLabel, + AudioTranscriptionSegment, + AudioTranslationOptions, + AudioTranslationFormat, + AudioTranslation, + AudioTranslationSegment, + CompletionsOptions, Completions, PromptFilterResult, ContentFilterResults, @@ -14,6 +21,7 @@ export { CompletionsLogProbabilityModel, CompletionsFinishReason, CompletionsUsage, + ChatCompletionsOptions, ChatMessage, ChatRole, FunctionCall, @@ -30,14 +38,23 @@ export { ImageLocation, ImagePayload, AzureOpenAIOperationState, + ImageGenerationOptions, ImageSize, ImageGenerationResponseFormat, + EmbeddingsOptions, + Embeddings, + EmbeddingItem, + EmbeddingsUsage, } from "./models.js"; export { - GetEmbeddingsOptions, + GetAudioTranscriptionAsPlainTextOptions, + GetAudioTranscriptionAsResponseObjectOptions, + GetAudioTranslationAsPlainTextOptions, + GetAudioTranslationAsResponseObjectOptions, GetCompletionsOptions, GetChatCompletionsOptions, GetChatCompletionsWithAzureExtensionsOptions, GetAzureBatchImageGenerationOperationStatusOptions, BeginAzureBatchImageGenerationOptions, + GetEmbeddingsOptions, } from "./options.js"; diff --git a/sdk/openai/openai/sources/generated/src/models/models.ts b/sdk/openai/openai/sources/generated/src/models/models.ts index 596897337291..b2fbfe458849 100644 --- a/sdk/openai/openai/sources/generated/src/models/models.ts +++ b/sdk/openai/openai/sources/generated/src/models/models.ts @@ -3,35 +3,264 @@ import { ErrorModel } from "@azure-rest/core-client"; +/** The configuration information for an audio transcription request. */ +export interface AudioTranscriptionOptions { + /** + * The audio data to transcribe. This must be the binary content of a file in one of the supported media formats: + * flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, webm. + */ + file: Uint8Array; + /** The requested format of the transcription response data, which will influence the content and detail of the result. */ + responseFormat?: AudioTranscriptionFormat; + /** + * The primary spoken language of the audio data to be transcribed, supplied as a two-letter ISO-639-1 language code + * such as 'en' or 'fr'. + * Providing this known input language is optional but may improve the accuracy and/or latency of transcription. + */ + language?: string; + /** + * An optional hint to guide the model's style or continue from a prior audio segment. The written language of the + * prompt should match the primary spoken language of the audio data. + */ + prompt?: string; + /** + * The sampling temperature, between 0 and 1. + * Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + * If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit. + */ + temperature?: number; + /** The model to use for this transcription request. */ + model?: string; +} + +/** Defines available options for the underlying response format of output transcription information. */ +/** "json", "verbose_json", "text", "srt", "vtt" */ +export type AudioTranscriptionFormat = string; + +/** Result information for an operation that transcribed spoken audio into written text. */ +export interface AudioTranscription { + /** The transcribed text for the provided audio data. */ + text: string; + /** The label that describes which operation type generated the accompanying response data. */ + task?: AudioTaskLabel; + /** + * The spoken language that was detected in the transcribed audio data. + * This is expressed as a two-letter ISO-639-1 language code like 'en' or 'fr'. + */ + language?: string; + /** The total duration of the audio processed to produce accompanying transcription information. */ + duration?: number; + /** A collection of information about the timing, probabilities, and other detail of each processed audio segment. */ + segments?: AudioTranscriptionSegment[]; +} + +/** Defines the possible descriptors for available audio operation responses. */ +/** "transcribe", "translate" */ +export type AudioTaskLabel = string; + /** - * Representation of the response data from an embeddings request. - * Embeddings measure the relatedness of text strings and are commonly used for search, clustering, - * recommendations, and other similar scenarios. + * Extended information about a single segment of transcribed audio data. + * Segments generally represent roughly 5-10 seconds of speech. Segment boundaries typically occur between words but not + * necessarily sentences. */ -export interface Embeddings { - /** Embedding values for the prompts submitted in the request. */ - data: EmbeddingItem[]; - /** Usage counts for tokens input using the embeddings API. */ - usage: EmbeddingsUsage; +export interface AudioTranscriptionSegment { + /** The 0-based index of this segment within a transcription. */ + id: number; + /** The time at which this segment started relative to the beginning of the transcribed audio. */ + start: number; + /** The time at which this segment ended relative to the beginning of the transcribed audio. */ + end: number; + /** The transcribed text that was part of this audio segment. */ + text: string; + /** The temperature score associated with this audio segment. */ + temperature: number; + /** The average log probability associated with this audio segment. */ + avgLogprob: number; + /** The compression ratio of this audio segment. */ + compressionRatio: number; + /** The probability of no speech detection within this audio segment. */ + noSpeechProb: number; + /** The token IDs matching the transcribed text in this audio segment. */ + tokens: number[]; + /** + * The seek position associated with the processing of this audio segment. + * Seek positions are expressed as hundredths of seconds. + * The model may process several segments from a single seek position, so while the seek position will never represent + * a later time than the segment's start, the segment's start may represent a significantly later time than the + * segment's associated seek position. + */ + seek: number; } -/** Representation of a single embeddings relatedness comparison. */ -export interface EmbeddingItem { +/** The configuration information for an audio translation request. */ +export interface AudioTranslationOptions { /** - * List of embeddings value for the input prompt. These represent a measurement of the - * vector-based relatedness of the provided input. + * The audio data to translate. This must be the binary content of a file in one of the supported media formats: + * flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, webm. */ - embedding: number[]; - /** Index of the prompt to which the EmbeddingItem corresponds. */ - index: number; + file: Uint8Array; + /** The requested format of the translation response data, which will influence the content and detail of the result. */ + responseFormat?: AudioTranslationFormat; + /** + * An optional hint to guide the model's style or continue from a prior audio segment. The written language of the + * prompt should match the primary spoken language of the audio data. + */ + prompt?: string; + /** + * The sampling temperature, between 0 and 1. + * Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + * If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit. + */ + temperature?: number; + /** The model to use for this translation request. */ + model?: string; } -/** Measurement of the amount of tokens used in this request and response. */ -export interface EmbeddingsUsage { - /** Number of tokens sent in the original request. */ - promptTokens: number; - /** Total number of tokens transacted in this request/response. */ - totalTokens: number; +/** Defines available options for the underlying response format of output translation information. */ +/** "json", "verbose_json", "text", "srt", "vtt" */ +export type AudioTranslationFormat = string; + +/** Result information for an operation that translated spoken audio into written text. */ +export interface AudioTranslation { + /** The translated text for the provided audio data. */ + text: string; + /** The label that describes which operation type generated the accompanying response data. */ + task?: AudioTaskLabel; + /** + * The spoken language that was detected in the translated audio data. + * This is expressed as a two-letter ISO-639-1 language code like 'en' or 'fr'. + */ + language?: string; + /** The total duration of the audio processed to produce accompanying translation information. */ + duration?: number; + /** A collection of information about the timing, probabilities, and other detail of each processed audio segment. */ + segments?: AudioTranslationSegment[]; +} + +/** + * Extended information about a single segment of translated audio data. + * Segments generally represent roughly 5-10 seconds of speech. Segment boundaries typically occur between words but not + * necessarily sentences. + */ +export interface AudioTranslationSegment { + /** The 0-based index of this segment within a translation. */ + id: number; + /** The time at which this segment started relative to the beginning of the translated audio. */ + start: number; + /** The time at which this segment ended relative to the beginning of the translated audio. */ + end: number; + /** The translated text that was part of this audio segment. */ + text: string; + /** The temperature score associated with this audio segment. */ + temperature: number; + /** The average log probability associated with this audio segment. */ + avgLogprob: number; + /** The compression ratio of this audio segment. */ + compressionRatio: number; + /** The probability of no speech detection within this audio segment. */ + noSpeechProb: number; + /** The token IDs matching the translated text in this audio segment. */ + tokens: number[]; + /** + * The seek position associated with the processing of this audio segment. + * Seek positions are expressed as hundredths of seconds. + * The model may process several segments from a single seek position, so while the seek position will never represent + * a later time than the segment's start, the segment's start may represent a significantly later time than the + * segment's associated seek position. + */ + seek: number; +} + +/** + * The configuration information for a completions request. + * Completions support a wide variety of tasks and generate text that continues from or "completes" + * provided prompt data. + */ +export interface CompletionsOptions { + /** The prompts to generate completions from. */ + prompt: string[]; + /** The maximum number of tokens to generate. */ + maxTokens?: number; + /** + * The sampling temperature to use that controls the apparent creativity of generated completions. + * Higher values will make output more random while lower values will make results more focused + * and deterministic. + * It is not recommended to modify temperature and top_p for the same completions request as the + * interaction of these two settings is difficult to predict. + */ + temperature?: number; + /** + * An alternative to sampling with temperature called nucleus sampling. This value causes the + * model to consider the results of tokens with the provided probability mass. As an example, a + * value of 0.15 will cause only the tokens comprising the top 15% of probability mass to be + * considered. + * It is not recommended to modify temperature and top_p for the same completions request as the + * interaction of these two settings is difficult to predict. + */ + topP?: number; + /** + * A map between GPT token IDs and bias scores that influences the probability of specific tokens + * appearing in a completions response. Token IDs are computed via external tokenizer tools, while + * bias scores reside in the range of -100 to 100 with minimum and maximum values corresponding to + * a full ban or exclusive selection of a token, respectively. The exact behavior of a given bias + * score varies by model. + */ + logitBias?: Record; + /** + * An identifier for the caller or end user of the operation. This may be used for tracking + * or rate-limiting purposes. + */ + user?: string; + /** + * The number of completions choices that should be generated per provided prompt as part of an + * overall completions response. + * Because this setting can generate many completions, it may quickly consume your token quota. + * Use carefully and ensure reasonable settings for max_tokens and stop. + */ + n?: number; + /** + * A value that controls the emission of log probabilities for the provided number of most likely + * tokens within a completions response. + */ + logprobs?: number; + /** + * A value specifying whether completions responses should include input prompts as prefixes to + * their generated output. + */ + echo?: boolean; + /** A collection of textual sequences that will end completions generation. */ + stop?: string[]; + /** + * A value that influences the probability of generated tokens appearing based on their existing + * presence in generated text. + * Positive values will make tokens less likely to appear when they already exist and increase the + * model's likelihood to output new topics. + */ + presencePenalty?: number; + /** + * A value that influences the probability of generated tokens appearing based on their cumulative + * frequency in generated text. + * Positive values will make tokens less likely to appear as their frequency increases and + * decrease the likelihood of the model repeating the same statements verbatim. + */ + frequencyPenalty?: number; + /** + * A value that controls how many completions will be internally generated prior to response + * formulation. + * When used together with n, best_of controls the number of candidate completions and must be + * greater than n. + * Because this setting can generate many completions, it may quickly consume your token quota. + * Use carefully and ensure reasonable settings for max_tokens and stop. + */ + bestOf?: number; + /** A value indicating whether chat completions should be streamed for this request. */ + stream?: boolean; + /** + * The model name to provide as part of this completions request. + * Not applicable to Azure OpenAI, where deployment information should be included in the Azure + * resource URI that's connected to. + */ + model?: string; } /** @@ -97,6 +326,11 @@ export interface ContentFilterResults { * or damage one’s body, or kill oneself. */ selfHarm?: ContentFilterResult; + /** + * Describes an error returned if the content filtering system is + * down or otherwise unable to complete the operation in time. + */ + error?: ErrorModel; } /** Information about filtered content severity level and if it has been filtered or not. */ @@ -175,6 +409,98 @@ export interface CompletionsUsage { totalTokens: number; } +/** + * The configuration information for a chat completions request. + * Completions support a wide variety of tasks and generate text that continues from or "completes" + * provided prompt data. + */ +export interface ChatCompletionsOptions { + /** + * The collection of context messages associated with this chat completions request. + * Typical usage begins with a chat message for the System role that provides instructions for + * the behavior of the assistant, followed by alternating messages between the User and + * Assistant roles. + */ + messages: ChatMessage[]; + /** A list of functions the model may generate JSON inputs for. */ + functions?: FunctionDefinition[]; + /** + * Controls how the model responds to function calls. "none" means the model does not call a function, + * and responds to the end-user. "auto" means the model can pick between an end-user or calling a function. + * Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. + * "none" is the default when no functions are present. "auto" is the default if functions are present. + */ + functionCall?: FunctionCallPreset | FunctionName; + /** The maximum number of tokens to generate. */ + maxTokens?: number; + /** + * The sampling temperature to use that controls the apparent creativity of generated completions. + * Higher values will make output more random while lower values will make results more focused + * and deterministic. + * It is not recommended to modify temperature and top_p for the same completions request as the + * interaction of these two settings is difficult to predict. + */ + temperature?: number; + /** + * An alternative to sampling with temperature called nucleus sampling. This value causes the + * model to consider the results of tokens with the provided probability mass. As an example, a + * value of 0.15 will cause only the tokens comprising the top 15% of probability mass to be + * considered. + * It is not recommended to modify temperature and top_p for the same completions request as the + * interaction of these two settings is difficult to predict. + */ + topP?: number; + /** + * A map between GPT token IDs and bias scores that influences the probability of specific tokens + * appearing in a completions response. Token IDs are computed via external tokenizer tools, while + * bias scores reside in the range of -100 to 100 with minimum and maximum values corresponding to + * a full ban or exclusive selection of a token, respectively. The exact behavior of a given bias + * score varies by model. + */ + logitBias?: Record; + /** + * An identifier for the caller or end user of the operation. This may be used for tracking + * or rate-limiting purposes. + */ + user?: string; + /** + * The number of chat completions choices that should be generated for a chat completions + * response. + * Because this setting can generate many completions, it may quickly consume your token quota. + * Use carefully and ensure reasonable settings for max_tokens and stop. + */ + n?: number; + /** A collection of textual sequences that will end completions generation. */ + stop?: string[]; + /** + * A value that influences the probability of generated tokens appearing based on their existing + * presence in generated text. + * Positive values will make tokens less likely to appear when they already exist and increase the + * model's likelihood to output new topics. + */ + presencePenalty?: number; + /** + * A value that influences the probability of generated tokens appearing based on their cumulative + * frequency in generated text. + * Positive values will make tokens less likely to appear as their frequency increases and + * decrease the likelihood of the model repeating the same statements verbatim. + */ + frequencyPenalty?: number; + /** A value indicating whether chat completions should be streamed for this request. */ + stream?: boolean; + /** + * The model name to provide as part of this completions request. + * Not applicable to Azure OpenAI, where deployment information should be included in the Azure + * resource URI that's connected to. + */ + model?: string; + /** + * The configuration entries for Azure OpenAI chat extensions that use them. + * This additional specification is only compatible with Azure OpenAI. + */ + dataSources?: AzureChatExtensionConfiguration[]; +} + /** A single, role-attributed message within a chat completion interaction. */ export interface ChatMessage { /** The role associated with this message payload. */ @@ -240,7 +566,7 @@ export interface FunctionDefinition { */ description?: string; /** The parameters the functions accepts, described as a JSON Schema object. */ - parameters?: any; + parameters?: unknown; } /** @@ -275,7 +601,7 @@ export interface AzureChatExtensionConfiguration { * extension being configured. * Azure chat extensions are only compatible with Azure OpenAI. */ - parameters: any; + parameters: unknown; } /** @@ -375,9 +701,85 @@ export interface ImagePayload { /** The state of a job or item. */ /** "notRunning", "running", "succeeded", "canceled", "failed" */ export type AzureOpenAIOperationState = string; + +/** Represents the request data used to generate images. */ +export interface ImageGenerationOptions { + /** A description of the desired images. */ + prompt: string; + /** The number of images to generate (defaults to 1). */ + n?: number; + /** The desired size of the generated images. Must be one of 256x256, 512x512, or 1024x1024 (defaults to 1024x1024). */ + size?: ImageSize; + /** + * The format in which image generation response items should be presented. + * Azure OpenAI only supports URL response items. + */ + responseFormat?: ImageGenerationResponseFormat; + /** A unique identifier representing your end-user, which can help to monitor and detect abuse. */ + user?: string; +} + /** The desired size of the generated images. Must be one of 256x256, 512x512, or 1024x1024. */ /** "256x256", "512x512", "1024x1024" */ export type ImageSize = string; /** The format in which the generated images are returned. */ /** "url", "b64_json" */ export type ImageGenerationResponseFormat = string; + +/** + * The configuration information for an embeddings request. + * Embeddings measure the relatedness of text strings and are commonly used for search, clustering, + * recommendations, and other similar scenarios. + */ +export interface EmbeddingsOptions { + /** + * An identifier for the caller or end user of the operation. This may be used for tracking + * or rate-limiting purposes. + */ + user?: string; + /** + * The model name to provide as part of this embeddings request. + * Not applicable to Azure OpenAI, where deployment information should be included in the Azure + * resource URI that's connected to. + */ + model?: string; + /** + * Input texts to get embeddings for, encoded as a an array of strings. + * Each input must not exceed 2048 tokens in length. + * + * Unless you are embedding code, we suggest replacing newlines (\n) in your input with a single space, + * as we have observed inferior results when newlines are present. + */ + input: string[]; +} + +/** + * Representation of the response data from an embeddings request. + * Embeddings measure the relatedness of text strings and are commonly used for search, clustering, + * recommendations, and other similar scenarios. + */ +export interface Embeddings { + /** Embedding values for the prompts submitted in the request. */ + data: EmbeddingItem[]; + /** Usage counts for tokens input using the embeddings API. */ + usage: EmbeddingsUsage; +} + +/** Representation of a single embeddings relatedness comparison. */ +export interface EmbeddingItem { + /** + * List of embeddings value for the input prompt. These represent a measurement of the + * vector-based relatedness of the provided input. + */ + embedding: number[]; + /** Index of the prompt to which the EmbeddingItem corresponds. */ + index: number; +} + +/** Measurement of the amount of tokens used in this request and response. */ +export interface EmbeddingsUsage { + /** Number of tokens sent in the original request. */ + promptTokens: number; + /** Total number of tokens transacted in this request/response. */ + totalTokens: number; +} diff --git a/sdk/openai/openai/sources/generated/src/models/options.ts b/sdk/openai/openai/sources/generated/src/models/options.ts index 3140d1a9457c..6b6fad961cf3 100644 --- a/sdk/openai/openai/sources/generated/src/models/options.ts +++ b/sdk/openai/openai/sources/generated/src/models/options.ts @@ -2,289 +2,36 @@ // Licensed under the MIT license. import { OperationOptions } from "@azure-rest/core-client"; -import { - FunctionDefinition, - FunctionCallPreset, - FunctionName, - AzureChatExtensionConfiguration, - ImageSize, - ImageGenerationResponseFormat, -} from "./models.js"; -export interface GetEmbeddingsOptions extends OperationOptions { - /** - * An identifier for the caller or end user of the operation. This may be used for tracking - * or rate-limiting purposes. - */ - user?: string; - /** - * The model name to provide as part of this embeddings request. - * Not applicable to Azure OpenAI, where deployment information should be included in the Azure - * resource URI that's connected to. - */ - model?: string; -} +export interface GetAudioTranscriptionAsPlainTextOptions + extends OperationOptions {} -export interface GetCompletionsOptions extends OperationOptions { - /** The maximum number of tokens to generate. */ - maxTokens?: number; - /** - * The sampling temperature to use that controls the apparent creativity of generated completions. - * Higher values will make output more random while lower values will make results more focused - * and deterministic. - * It is not recommended to modify temperature and top_p for the same completions request as the - * interaction of these two settings is difficult to predict. - */ - temperature?: number; - /** - * An alternative to sampling with temperature called nucleus sampling. This value causes the - * model to consider the results of tokens with the provided probability mass. As an example, a - * value of 0.15 will cause only the tokens comprising the top 15% of probability mass to be - * considered. - * It is not recommended to modify temperature and top_p for the same completions request as the - * interaction of these two settings is difficult to predict. - */ - topP?: number; - /** - * A map between GPT token IDs and bias scores that influences the probability of specific tokens - * appearing in a completions response. Token IDs are computed via external tokenizer tools, while - * bias scores reside in the range of -100 to 100 with minimum and maximum values corresponding to - * a full ban or exclusive selection of a token, respectively. The exact behavior of a given bias - * score varies by model. - */ - logitBias?: Record; - /** - * An identifier for the caller or end user of the operation. This may be used for tracking - * or rate-limiting purposes. - */ - user?: string; - /** - * The number of completions choices that should be generated per provided prompt as part of an - * overall completions response. - * Because this setting can generate many completions, it may quickly consume your token quota. - * Use carefully and ensure reasonable settings for max_tokens and stop. - */ - n?: number; - /** - * A value that controls the emission of log probabilities for the provided number of most likely - * tokens within a completions response. - */ - logprobs?: number; - /** - * A value specifying whether completions responses should include input prompts as prefixes to - * their generated output. - */ - echo?: boolean; - /** A collection of textual sequences that will end completions generation. */ - stop?: string[]; - /** - * A value that influences the probability of generated tokens appearing based on their existing - * presence in generated text. - * Positive values will make tokens less likely to appear when they already exist and increase the - * model's likelihood to output new topics. - */ - presencePenalty?: number; - /** - * A value that influences the probability of generated tokens appearing based on their cumulative - * frequency in generated text. - * Positive values will make tokens less likely to appear as their frequency increases and - * decrease the likelihood of the model repeating the same statements verbatim. - */ - frequencyPenalty?: number; - /** - * A value that controls how many completions will be internally generated prior to response - * formulation. - * When used together with n, best_of controls the number of candidate completions and must be - * greater than n. - * Because this setting can generate many completions, it may quickly consume your token quota. - * Use carefully and ensure reasonable settings for max_tokens and stop. - */ - bestOf?: number; - /** A value indicating whether chat completions should be streamed for this request. */ - stream?: boolean; - /** - * The model name to provide as part of this completions request. - * Not applicable to Azure OpenAI, where deployment information should be included in the Azure - * resource URI that's connected to. - */ - model?: string; +export interface GetAudioTranscriptionAsResponseObjectOptions + extends OperationOptions { + /** The content type for the operation. Always multipart/form-data for this operation. */ + contentType?: string; } -export interface GetChatCompletionsOptions extends OperationOptions { - /** A list of functions the model may generate JSON inputs for. */ - functions?: FunctionDefinition[]; - /** - * Controls how the model responds to function calls. "none" means the model does not call a function, - * and responds to the end-user. "auto" means the model can pick between an end-user or calling a function. - * Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. - * "none" is the default when no functions are present. "auto" is the default if functions are present. - */ - functionCall?: FunctionCallPreset | FunctionName; - /** The maximum number of tokens to generate. */ - maxTokens?: number; - /** - * The sampling temperature to use that controls the apparent creativity of generated completions. - * Higher values will make output more random while lower values will make results more focused - * and deterministic. - * It is not recommended to modify temperature and top_p for the same completions request as the - * interaction of these two settings is difficult to predict. - */ - temperature?: number; - /** - * An alternative to sampling with temperature called nucleus sampling. This value causes the - * model to consider the results of tokens with the provided probability mass. As an example, a - * value of 0.15 will cause only the tokens comprising the top 15% of probability mass to be - * considered. - * It is not recommended to modify temperature and top_p for the same completions request as the - * interaction of these two settings is difficult to predict. - */ - topP?: number; - /** - * A map between GPT token IDs and bias scores that influences the probability of specific tokens - * appearing in a completions response. Token IDs are computed via external tokenizer tools, while - * bias scores reside in the range of -100 to 100 with minimum and maximum values corresponding to - * a full ban or exclusive selection of a token, respectively. The exact behavior of a given bias - * score varies by model. - */ - logitBias?: Record; - /** - * An identifier for the caller or end user of the operation. This may be used for tracking - * or rate-limiting purposes. - */ - user?: string; - /** - * The number of chat completions choices that should be generated for a chat completions - * response. - * Because this setting can generate many completions, it may quickly consume your token quota. - * Use carefully and ensure reasonable settings for max_tokens and stop. - */ - n?: number; - /** A collection of textual sequences that will end completions generation. */ - stop?: string[]; - /** - * A value that influences the probability of generated tokens appearing based on their existing - * presence in generated text. - * Positive values will make tokens less likely to appear when they already exist and increase the - * model's likelihood to output new topics. - */ - presencePenalty?: number; - /** - * A value that influences the probability of generated tokens appearing based on their cumulative - * frequency in generated text. - * Positive values will make tokens less likely to appear as their frequency increases and - * decrease the likelihood of the model repeating the same statements verbatim. - */ - frequencyPenalty?: number; - /** A value indicating whether chat completions should be streamed for this request. */ - stream?: boolean; - /** - * The model name to provide as part of this completions request. - * Not applicable to Azure OpenAI, where deployment information should be included in the Azure - * resource URI that's connected to. - */ - model?: string; - /** - * The configuration entries for Azure OpenAI chat extensions that use them. - * This additional specification is only compatible with Azure OpenAI. - */ - dataSources?: AzureChatExtensionConfiguration[]; -} +export interface GetAudioTranslationAsPlainTextOptions + extends OperationOptions {} -export interface GetChatCompletionsWithAzureExtensionsOptions +export interface GetAudioTranslationAsResponseObjectOptions extends OperationOptions { - /** A list of functions the model may generate JSON inputs for. */ - functions?: FunctionDefinition[]; - /** - * Controls how the model responds to function calls. "none" means the model does not call a function, - * and responds to the end-user. "auto" means the model can pick between an end-user or calling a function. - * Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. - * "none" is the default when no functions are present. "auto" is the default if functions are present. - */ - functionCall?: FunctionCallPreset | FunctionName; - /** The maximum number of tokens to generate. */ - maxTokens?: number; - /** - * The sampling temperature to use that controls the apparent creativity of generated completions. - * Higher values will make output more random while lower values will make results more focused - * and deterministic. - * It is not recommended to modify temperature and top_p for the same completions request as the - * interaction of these two settings is difficult to predict. - */ - temperature?: number; - /** - * An alternative to sampling with temperature called nucleus sampling. This value causes the - * model to consider the results of tokens with the provided probability mass. As an example, a - * value of 0.15 will cause only the tokens comprising the top 15% of probability mass to be - * considered. - * It is not recommended to modify temperature and top_p for the same completions request as the - * interaction of these two settings is difficult to predict. - */ - topP?: number; - /** - * A map between GPT token IDs and bias scores that influences the probability of specific tokens - * appearing in a completions response. Token IDs are computed via external tokenizer tools, while - * bias scores reside in the range of -100 to 100 with minimum and maximum values corresponding to - * a full ban or exclusive selection of a token, respectively. The exact behavior of a given bias - * score varies by model. - */ - logitBias?: Record; - /** - * An identifier for the caller or end user of the operation. This may be used for tracking - * or rate-limiting purposes. - */ - user?: string; - /** - * The number of chat completions choices that should be generated for a chat completions - * response. - * Because this setting can generate many completions, it may quickly consume your token quota. - * Use carefully and ensure reasonable settings for max_tokens and stop. - */ - n?: number; - /** A collection of textual sequences that will end completions generation. */ - stop?: string[]; - /** - * A value that influences the probability of generated tokens appearing based on their existing - * presence in generated text. - * Positive values will make tokens less likely to appear when they already exist and increase the - * model's likelihood to output new topics. - */ - presencePenalty?: number; - /** - * A value that influences the probability of generated tokens appearing based on their cumulative - * frequency in generated text. - * Positive values will make tokens less likely to appear as their frequency increases and - * decrease the likelihood of the model repeating the same statements verbatim. - */ - frequencyPenalty?: number; - /** A value indicating whether chat completions should be streamed for this request. */ - stream?: boolean; - /** - * The model name to provide as part of this completions request. - * Not applicable to Azure OpenAI, where deployment information should be included in the Azure - * resource URI that's connected to. - */ - model?: string; - /** - * The configuration entries for Azure OpenAI chat extensions that use them. - * This additional specification is only compatible with Azure OpenAI. - */ - dataSources?: AzureChatExtensionConfiguration[]; + /** The content type for the operation. Always multipart/form-data for this operation. */ + contentType?: string; } +export interface GetCompletionsOptions extends OperationOptions {} + +export interface GetChatCompletionsOptions extends OperationOptions {} + +export interface GetChatCompletionsWithAzureExtensionsOptions + extends OperationOptions {} + export interface GetAzureBatchImageGenerationOperationStatusOptions extends OperationOptions {} export interface BeginAzureBatchImageGenerationOptions - extends OperationOptions { - /** The number of images to generate (defaults to 1). */ - n?: number; - /** The desired size of the generated images. Must be one of 256x256, 512x512, or 1024x1024 (defaults to 1024x1024). */ - size?: ImageSize; - /** - * The format in which image generation response items should be presented. - * Azure OpenAI only supports URL response items. - */ - responseFormat?: ImageGenerationResponseFormat; - /** A unique identifier representing your end-user, which can help to monitor and detect abuse. */ - user?: string; -} + extends OperationOptions {} + +export interface GetEmbeddingsOptions extends OperationOptions {} diff --git a/sdk/openai/openai/sources/generated/src/rest/clientDefinitions.ts b/sdk/openai/openai/sources/generated/src/rest/clientDefinitions.ts index 42715365f3ed..535e3ae54464 100644 --- a/sdk/openai/openai/sources/generated/src/rest/clientDefinitions.ts +++ b/sdk/openai/openai/sources/generated/src/rest/clientDefinitions.ts @@ -2,16 +2,26 @@ // Licensed under the MIT license. import { - GetEmbeddingsParameters, + GetAudioTranscriptionAsPlainTextParameters, + GetAudioTranscriptionAsResponseObjectParameters, + GetAudioTranslationAsPlainTextParameters, + GetAudioTranslationAsResponseObjectParameters, GetCompletionsParameters, GetChatCompletionsParameters, GetChatCompletionsWithAzureExtensionsParameters, GetAzureBatchImageGenerationOperationStatusParameters, BeginAzureBatchImageGenerationParameters, + GetEmbeddingsParameters, } from "./parameters.js"; import { - GetEmbeddings200Response, - GetEmbeddingsDefaultResponse, + GetAudioTranscriptionAsPlainText200Response, + GetAudioTranscriptionAsPlainTextDefaultResponse, + GetAudioTranscriptionAsResponseObject200Response, + GetAudioTranscriptionAsResponseObjectDefaultResponse, + GetAudioTranslationAsPlainText200Response, + GetAudioTranslationAsPlainTextDefaultResponse, + GetAudioTranslationAsResponseObject200Response, + GetAudioTranslationAsResponseObjectDefaultResponse, GetCompletions200Response, GetCompletionsDefaultResponse, GetChatCompletions200Response, @@ -22,14 +32,49 @@ import { GetAzureBatchImageGenerationOperationStatusDefaultResponse, BeginAzureBatchImageGeneration202Response, BeginAzureBatchImageGenerationDefaultResponse, + GetEmbeddings200Response, + GetEmbeddingsDefaultResponse, } from "./responses.js"; import { Client, StreamableMethod } from "@azure-rest/core-client"; -export interface GetEmbeddings { - /** Return the embeddings for a given prompt. */ +export interface GetAudioTranscriptionAsPlainText { + /** + * Gets transcribed text and associated metadata from provided spoken audio data. Audio will be transcribed in the + * written language corresponding to the language it was spoken in. + */ post( - options?: GetEmbeddingsParameters - ): StreamableMethod; + options?: GetAudioTranscriptionAsPlainTextParameters + ): StreamableMethod< + | GetAudioTranscriptionAsPlainText200Response + | GetAudioTranscriptionAsPlainTextDefaultResponse + >; + /** + * Gets transcribed text and associated metadata from provided spoken audio data. Audio will be transcribed in the + * written language corresponding to the language it was spoken in. + */ + post( + options: GetAudioTranscriptionAsResponseObjectParameters + ): StreamableMethod< + | GetAudioTranscriptionAsResponseObject200Response + | GetAudioTranscriptionAsResponseObjectDefaultResponse + >; +} + +export interface GetAudioTranslationAsPlainText { + /** Gets English language transcribed text and associated metadata from provided spoken audio data. */ + post( + options?: GetAudioTranslationAsPlainTextParameters + ): StreamableMethod< + | GetAudioTranslationAsPlainText200Response + | GetAudioTranslationAsPlainTextDefaultResponse + >; + /** Gets English language transcribed text and associated metadata from provided spoken audio data. */ + post( + options: GetAudioTranslationAsResponseObjectParameters + ): StreamableMethod< + | GetAudioTranslationAsResponseObject200Response + | GetAudioTranslationAsResponseObjectDefaultResponse + >; } export interface GetCompletions { @@ -92,12 +137,24 @@ export interface BeginAzureBatchImageGeneration { >; } +export interface GetEmbeddings { + /** Return the embeddings for a given prompt. */ + post( + options?: GetEmbeddingsParameters + ): StreamableMethod; +} + export interface Routes { - /** Resource for '/deployments/\{deploymentId\}/embeddings' has methods for the following verbs: post */ + /** Resource for '/deployments/\{deploymentId\}/audio/transcriptions' has methods for the following verbs: post */ ( - path: "/deployments/{deploymentId}/embeddings", + path: "/deployments/{deploymentId}/audio/transcriptions", deploymentId: string - ): GetEmbeddings; + ): GetAudioTranscriptionAsPlainText; + /** Resource for '/deployments/\{deploymentId\}/audio/translations' has methods for the following verbs: post */ + ( + path: "/deployments/{deploymentId}/audio/translations", + deploymentId: string + ): GetAudioTranslationAsPlainText; /** Resource for '/deployments/\{deploymentId\}/completions' has methods for the following verbs: post */ ( path: "/deployments/{deploymentId}/completions", @@ -120,6 +177,11 @@ export interface Routes { ): GetAzureBatchImageGenerationOperationStatus; /** Resource for '/images/generations:submit' has methods for the following verbs: post */ (path: "/images/generations:submit"): BeginAzureBatchImageGeneration; + /** Resource for '/deployments/\{deploymentId\}/embeddings' has methods for the following verbs: post */ + ( + path: "/deployments/{deploymentId}/embeddings", + deploymentId: string + ): GetEmbeddings; } export type OpenAIContext = Client & { diff --git a/sdk/openai/openai/sources/generated/src/rest/isUnexpected.ts b/sdk/openai/openai/sources/generated/src/rest/isUnexpected.ts index 5dab3fe0efef..c5877a0a5d52 100644 --- a/sdk/openai/openai/sources/generated/src/rest/isUnexpected.ts +++ b/sdk/openai/openai/sources/generated/src/rest/isUnexpected.ts @@ -2,8 +2,10 @@ // Licensed under the MIT license. import { - GetEmbeddings200Response, - GetEmbeddingsDefaultResponse, + GetAudioTranscriptionAsPlainText200Response, + GetAudioTranscriptionAsPlainTextDefaultResponse, + GetAudioTranslationAsPlainText200Response, + GetAudioTranslationAsPlainTextDefaultResponse, GetCompletions200Response, GetCompletionsDefaultResponse, GetChatCompletions200Response, @@ -11,26 +13,36 @@ import { GetChatCompletionsWithAzureExtensions200Response, GetChatCompletionsWithAzureExtensionsDefaultResponse, GetAzureBatchImageGenerationOperationStatus200Response, - GetAzureBatchImageGenerationOperationStatusLogicalResponse, GetAzureBatchImageGenerationOperationStatusDefaultResponse, BeginAzureBatchImageGeneration202Response, BeginAzureBatchImageGenerationLogicalResponse, BeginAzureBatchImageGenerationDefaultResponse, + GetEmbeddings200Response, + GetEmbeddingsDefaultResponse, } from "./responses.js"; const responseMap: Record = { - "POST /deployments/{deploymentId}/embeddings": ["200"], + "POST /deployments/{deploymentId}/audio/transcriptions": ["200"], + "POST /deployments/{deploymentId}/audio/translations": ["200"], "POST /deployments/{deploymentId}/completions": ["200"], "POST /deployments/{deploymentId}/chat/completions": ["200"], "POST /deployments/{deploymentId}/extensions/chat/completions": ["200"], "GET /operations/images/{operationId}": ["200"], "POST /images/generations:submit": ["202"], "GET /images/generations:submit": ["200", "202"], + "POST /deployments/{deploymentId}/embeddings": ["200"], }; export function isUnexpected( - response: GetEmbeddings200Response | GetEmbeddingsDefaultResponse -): response is GetEmbeddingsDefaultResponse; + response: + | GetAudioTranscriptionAsPlainText200Response + | GetAudioTranscriptionAsPlainTextDefaultResponse +): response is GetAudioTranscriptionAsPlainTextDefaultResponse; +export function isUnexpected( + response: + | GetAudioTranslationAsPlainText200Response + | GetAudioTranslationAsPlainTextDefaultResponse +): response is GetAudioTranslationAsPlainTextDefaultResponse; export function isUnexpected( response: GetCompletions200Response | GetCompletionsDefaultResponse ): response is GetCompletionsDefaultResponse; @@ -45,7 +57,6 @@ export function isUnexpected( export function isUnexpected( response: | GetAzureBatchImageGenerationOperationStatus200Response - | GetAzureBatchImageGenerationOperationStatusLogicalResponse | GetAzureBatchImageGenerationOperationStatusDefaultResponse ): response is GetAzureBatchImageGenerationOperationStatusDefaultResponse; export function isUnexpected( @@ -54,10 +65,15 @@ export function isUnexpected( | BeginAzureBatchImageGenerationLogicalResponse | BeginAzureBatchImageGenerationDefaultResponse ): response is BeginAzureBatchImageGenerationDefaultResponse; +export function isUnexpected( + response: GetEmbeddings200Response | GetEmbeddingsDefaultResponse +): response is GetEmbeddingsDefaultResponse; export function isUnexpected( response: - | GetEmbeddings200Response - | GetEmbeddingsDefaultResponse + | GetAudioTranscriptionAsPlainText200Response + | GetAudioTranscriptionAsPlainTextDefaultResponse + | GetAudioTranslationAsPlainText200Response + | GetAudioTranslationAsPlainTextDefaultResponse | GetCompletions200Response | GetCompletionsDefaultResponse | GetChatCompletions200Response @@ -65,18 +81,21 @@ export function isUnexpected( | GetChatCompletionsWithAzureExtensions200Response | GetChatCompletionsWithAzureExtensionsDefaultResponse | GetAzureBatchImageGenerationOperationStatus200Response - | GetAzureBatchImageGenerationOperationStatusLogicalResponse | GetAzureBatchImageGenerationOperationStatusDefaultResponse | BeginAzureBatchImageGeneration202Response | BeginAzureBatchImageGenerationLogicalResponse | BeginAzureBatchImageGenerationDefaultResponse + | GetEmbeddings200Response + | GetEmbeddingsDefaultResponse ): response is - | GetEmbeddingsDefaultResponse + | GetAudioTranscriptionAsPlainTextDefaultResponse + | GetAudioTranslationAsPlainTextDefaultResponse | GetCompletionsDefaultResponse | GetChatCompletionsDefaultResponse | GetChatCompletionsWithAzureExtensionsDefaultResponse | GetAzureBatchImageGenerationOperationStatusDefaultResponse - | BeginAzureBatchImageGenerationDefaultResponse { + | BeginAzureBatchImageGenerationDefaultResponse + | GetEmbeddingsDefaultResponse { const lroOriginal = response.headers["x-ms-original-url"]; const url = new URL(lroOriginal ?? response.request.url); const method = response.request.method; diff --git a/sdk/openai/openai/sources/generated/src/rest/models.ts b/sdk/openai/openai/sources/generated/src/rest/models.ts index 8ee9e10a0a08..0c8739000bea 100644 --- a/sdk/openai/openai/sources/generated/src/rest/models.ts +++ b/sdk/openai/openai/sources/generated/src/rest/models.ts @@ -1,31 +1,66 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -/** - * The configuration information for an embeddings request. - * Embeddings measure the relatedness of text strings and are commonly used for search, clustering, - * recommendations, and other similar scenarios. - */ -export interface EmbeddingsOptions { +/** The configuration information for an audio transcription request. */ +export interface AudioTranscriptionOptions { /** - * An identifier for the caller or end user of the operation. This may be used for tracking - * or rate-limiting purposes. + * The audio data to transcribe. This must be the binary content of a file in one of the supported media formats: + * flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, webm. */ - user?: string; + file: string; /** - * The model name to provide as part of this embeddings request. - * Not applicable to Azure OpenAI, where deployment information should be included in the Azure - * resource URI that's connected to. + * The requested format of the transcription response data, which will influence the content and detail of the result. + * + * Possible values: json, verbose_json, text, srt, vtt + */ + response_format?: string; + /** + * The primary spoken language of the audio data to be transcribed, supplied as a two-letter ISO-639-1 language code + * such as 'en' or 'fr'. + * Providing this known input language is optional but may improve the accuracy and/or latency of transcription. */ + language?: string; + /** + * An optional hint to guide the model's style or continue from a prior audio segment. The written language of the + * prompt should match the primary spoken language of the audio data. + */ + prompt?: string; + /** + * The sampling temperature, between 0 and 1. + * Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + * If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit. + */ + temperature?: number; + /** The model to use for this transcription request. */ model?: string; +} + +/** The configuration information for an audio translation request. */ +export interface AudioTranslationOptions { /** - * Input texts to get embeddings for, encoded as a an array of strings. - * Each input must not exceed 2048 tokens in length. + * The audio data to translate. This must be the binary content of a file in one of the supported media formats: + * flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, webm. + */ + file: string; + /** + * The requested format of the translation response data, which will influence the content and detail of the result. * - * Unless you are embedding code, we suggest replacing newlines (\n) in your input with a single space, - * as we have observed inferior results when newlines are present. + * Possible values: json, verbose_json, text, srt, vtt */ - input: string[]; + response_format?: string; + /** + * An optional hint to guide the model's style or continue from a prior audio segment. The written language of the + * prompt should match the primary spoken language of the audio data. + */ + prompt?: string; + /** + * The sampling temperature, between 0 and 1. + * Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + * If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit. + */ + temperature?: number; + /** The model to use for this translation request. */ + model?: string; } /** @@ -332,3 +367,30 @@ export interface ImageGenerationOptions { /** A unique identifier representing your end-user, which can help to monitor and detect abuse. */ user?: string; } + +/** + * The configuration information for an embeddings request. + * Embeddings measure the relatedness of text strings and are commonly used for search, clustering, + * recommendations, and other similar scenarios. + */ +export interface EmbeddingsOptions { + /** + * An identifier for the caller or end user of the operation. This may be used for tracking + * or rate-limiting purposes. + */ + user?: string; + /** + * The model name to provide as part of this embeddings request. + * Not applicable to Azure OpenAI, where deployment information should be included in the Azure + * resource URI that's connected to. + */ + model?: string; + /** + * Input texts to get embeddings for, encoded as a an array of strings. + * Each input must not exceed 2048 tokens in length. + * + * Unless you are embedding code, we suggest replacing newlines (\n) in your input with a single space, + * as we have observed inferior results when newlines are present. + */ + input: string[]; +} diff --git a/sdk/openai/openai/sources/generated/src/rest/openAIClient.ts b/sdk/openai/openai/sources/generated/src/rest/openAIClient.ts index d878e8fb3a6a..74a6baaf1b91 100644 --- a/sdk/openai/openai/sources/generated/src/rest/openAIClient.ts +++ b/sdk/openai/openai/sources/generated/src/rest/openAIClient.ts @@ -19,18 +19,8 @@ export default function createClient( options: ClientOptions = {} ): OpenAIContext { const baseUrl = options.baseUrl ?? `${endpoint}/openai`; - options.apiVersion = options.apiVersion ?? "2023-08-01-preview"; - options = { - ...options, - credentials: { - scopes: options.credentials?.scopes ?? [ - "https://cognitiveservices.azure.com/.default", - ], - apiKeyHeaderName: options.credentials?.apiKeyHeaderName ?? "api-key", - }, - }; - - const userAgentInfo = `azsdk-js-openai-rest/1.0.0-beta.5`; + options.apiVersion = options.apiVersion ?? "2023-09-01-preview"; + const userAgentInfo = `azsdk-js-openai-rest/1.0.0-beta.1`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}` @@ -43,6 +33,12 @@ export default function createClient( loggingOptions: { logger: options.loggingOptions?.logger ?? logger.info, }, + credentials: { + scopes: options.credentials?.scopes ?? [ + "https://cognitiveservices.azure.com/.default", + ], + apiKeyHeaderName: options.credentials?.apiKeyHeaderName ?? "api-key", + }, }; const client = getClient(baseUrl, credentials, options) as OpenAIContext; diff --git a/sdk/openai/openai/sources/generated/src/rest/outputModels.ts b/sdk/openai/openai/sources/generated/src/rest/outputModels.ts index 98c8b607c638..96fecb1cc96e 100644 --- a/sdk/openai/openai/sources/generated/src/rest/outputModels.ts +++ b/sdk/openai/openai/sources/generated/src/rest/outputModels.ts @@ -9,35 +9,114 @@ export interface DeploymentOutput { readonly deploymentId: string; } +/** Result information for an operation that transcribed spoken audio into written text. */ +export interface AudioTranscriptionOutput { + /** The transcribed text for the provided audio data. */ + text: string; + /** + * The label that describes which operation type generated the accompanying response data. + * + * Possible values: transcribe, translate + */ + task?: string; + /** + * The spoken language that was detected in the transcribed audio data. + * This is expressed as a two-letter ISO-639-1 language code like 'en' or 'fr'. + */ + language?: string; + /** The total duration of the audio processed to produce accompanying transcription information. */ + duration?: number; + /** A collection of information about the timing, probabilities, and other detail of each processed audio segment. */ + segments?: Array; +} + /** - * Representation of the response data from an embeddings request. - * Embeddings measure the relatedness of text strings and are commonly used for search, clustering, - * recommendations, and other similar scenarios. + * Extended information about a single segment of transcribed audio data. + * Segments generally represent roughly 5-10 seconds of speech. Segment boundaries typically occur between words but not + * necessarily sentences. */ -export interface EmbeddingsOutput { - /** Embedding values for the prompts submitted in the request. */ - data: Array; - /** Usage counts for tokens input using the embeddings API. */ - usage: EmbeddingsUsageOutput; +export interface AudioTranscriptionSegmentOutput { + /** The 0-based index of this segment within a transcription. */ + id: number; + /** The time at which this segment started relative to the beginning of the transcribed audio. */ + start: number; + /** The time at which this segment ended relative to the beginning of the transcribed audio. */ + end: number; + /** The transcribed text that was part of this audio segment. */ + text: string; + /** The temperature score associated with this audio segment. */ + temperature: number; + /** The average log probability associated with this audio segment. */ + avg_logprob: number; + /** The compression ratio of this audio segment. */ + compression_ratio: number; + /** The probability of no speech detection within this audio segment. */ + no_speech_prob: number; + /** The token IDs matching the transcribed text in this audio segment. */ + tokens: number[]; + /** + * The seek position associated with the processing of this audio segment. + * Seek positions are expressed as hundredths of seconds. + * The model may process several segments from a single seek position, so while the seek position will never represent + * a later time than the segment's start, the segment's start may represent a significantly later time than the + * segment's associated seek position. + */ + seek: number; } -/** Representation of a single embeddings relatedness comparison. */ -export interface EmbeddingItemOutput { +/** Result information for an operation that translated spoken audio into written text. */ +export interface AudioTranslationOutput { + /** The translated text for the provided audio data. */ + text: string; /** - * List of embeddings value for the input prompt. These represent a measurement of the - * vector-based relatedness of the provided input. + * The label that describes which operation type generated the accompanying response data. + * + * Possible values: transcribe, translate */ - embedding: number[]; - /** Index of the prompt to which the EmbeddingItem corresponds. */ - index: number; + task?: string; + /** + * The spoken language that was detected in the translated audio data. + * This is expressed as a two-letter ISO-639-1 language code like 'en' or 'fr'. + */ + language?: string; + /** The total duration of the audio processed to produce accompanying translation information. */ + duration?: number; + /** A collection of information about the timing, probabilities, and other detail of each processed audio segment. */ + segments?: Array; } -/** Measurement of the amount of tokens used in this request and response. */ -export interface EmbeddingsUsageOutput { - /** Number of tokens sent in the original request. */ - prompt_tokens: number; - /** Total number of tokens transacted in this request/response. */ - total_tokens: number; +/** + * Extended information about a single segment of translated audio data. + * Segments generally represent roughly 5-10 seconds of speech. Segment boundaries typically occur between words but not + * necessarily sentences. + */ +export interface AudioTranslationSegmentOutput { + /** The 0-based index of this segment within a translation. */ + id: number; + /** The time at which this segment started relative to the beginning of the translated audio. */ + start: number; + /** The time at which this segment ended relative to the beginning of the translated audio. */ + end: number; + /** The translated text that was part of this audio segment. */ + text: string; + /** The temperature score associated with this audio segment. */ + temperature: number; + /** The average log probability associated with this audio segment. */ + avg_logprob: number; + /** The compression ratio of this audio segment. */ + compression_ratio: number; + /** The probability of no speech detection within this audio segment. */ + no_speech_prob: number; + /** The token IDs matching the translated text in this audio segment. */ + tokens: number[]; + /** + * The seek position associated with the processing of this audio segment. + * Seek positions are expressed as hundredths of seconds. + * The model may process several segments from a single seek position, so while the seek position will never represent + * a later time than the segment's start, the segment's start may represent a significantly later time than the + * segment's associated seek position. + */ + seek: number; } /** @@ -57,7 +136,7 @@ export interface CompletionsOutput { * Content filtering results for zero or more prompts in the request. In a streaming request, * results for different prompts may arrive at different times or in different orders. */ - prompt_annotations?: Array; + prompt_filter_results?: Array; /** * The collection of completions choices associated with this completions response. * Generally, `n` choices are generated per provided prompt with a default value of 1. @@ -248,7 +327,7 @@ export interface ChatCompletionsOutput { * Content filtering results for zero or more prompts in the request. In a streaming request, * results for different prompts may arrive at different times or in different orders. */ - prompt_annotations?: Array; + prompt_filter_results?: Array; /** Usage information for tokens processed and generated as part of this completions operation. */ usage: CompletionsUsageOutput; } @@ -337,3 +416,34 @@ export interface ImageGenerationOptionsOutput { /** A unique identifier representing your end-user, which can help to monitor and detect abuse. */ user?: string; } + +/** + * Representation of the response data from an embeddings request. + * Embeddings measure the relatedness of text strings and are commonly used for search, clustering, + * recommendations, and other similar scenarios. + */ +export interface EmbeddingsOutput { + /** Embedding values for the prompts submitted in the request. */ + data: Array; + /** Usage counts for tokens input using the embeddings API. */ + usage: EmbeddingsUsageOutput; +} + +/** Representation of a single embeddings relatedness comparison. */ +export interface EmbeddingItemOutput { + /** + * List of embeddings value for the input prompt. These represent a measurement of the + * vector-based relatedness of the provided input. + */ + embedding: number[]; + /** Index of the prompt to which the EmbeddingItem corresponds. */ + index: number; +} + +/** Measurement of the amount of tokens used in this request and response. */ +export interface EmbeddingsUsageOutput { + /** Number of tokens sent in the original request. */ + prompt_tokens: number; + /** Total number of tokens transacted in this request/response. */ + total_tokens: number; +} diff --git a/sdk/openai/openai/sources/generated/src/rest/parameters.ts b/sdk/openai/openai/sources/generated/src/rest/parameters.ts index f21e5cc8ce55..9aa2fd7c7861 100644 --- a/sdk/openai/openai/sources/generated/src/rest/parameters.ts +++ b/sdk/openai/openai/sources/generated/src/rest/parameters.ts @@ -3,18 +3,55 @@ import { RequestParameters } from "@azure-rest/core-client"; import { - EmbeddingsOptions, + AudioTranscriptionOptions, + AudioTranslationOptions, CompletionsOptions, ChatCompletionsOptions, ImageGenerationOptions, + EmbeddingsOptions, } from "./models.js"; -export interface GetEmbeddingsBodyParam { - body?: EmbeddingsOptions; +export interface GetAudioTranscriptionAsPlainTextBodyParam { + body?: AudioTranscriptionOptions; } -export type GetEmbeddingsParameters = GetEmbeddingsBodyParam & - RequestParameters; +export type GetAudioTranscriptionAsPlainTextParameters = + GetAudioTranscriptionAsPlainTextBodyParam & RequestParameters; + +export interface GetAudioTranscriptionAsResponseObjectBodyParam { + body?: AudioTranscriptionOptions; +} + +export interface GetAudioTranscriptionAsResponseObjectMediaTypesParam { + /** The content type for the operation. Always multipart/form-data for this operation. */ + contentType: "multipart/form-data"; +} + +export type GetAudioTranscriptionAsResponseObjectParameters = + GetAudioTranscriptionAsResponseObjectMediaTypesParam & + GetAudioTranscriptionAsResponseObjectBodyParam & + RequestParameters; + +export interface GetAudioTranslationAsPlainTextBodyParam { + body?: AudioTranslationOptions; +} + +export type GetAudioTranslationAsPlainTextParameters = + GetAudioTranslationAsPlainTextBodyParam & RequestParameters; + +export interface GetAudioTranslationAsResponseObjectBodyParam { + body?: AudioTranslationOptions; +} + +export interface GetAudioTranslationAsResponseObjectMediaTypesParam { + /** The content type for the operation. Always multipart/form-data for this operation. */ + contentType: "multipart/form-data"; +} + +export type GetAudioTranslationAsResponseObjectParameters = + GetAudioTranslationAsResponseObjectMediaTypesParam & + GetAudioTranslationAsResponseObjectBodyParam & + RequestParameters; export interface GetCompletionsBodyParam { body?: CompletionsOptions; @@ -45,3 +82,10 @@ export interface BeginAzureBatchImageGenerationBodyParam { export type BeginAzureBatchImageGenerationParameters = BeginAzureBatchImageGenerationBodyParam & RequestParameters; + +export interface GetEmbeddingsBodyParam { + body?: EmbeddingsOptions; +} + +export type GetEmbeddingsParameters = GetEmbeddingsBodyParam & + RequestParameters; diff --git a/sdk/openai/openai/sources/generated/src/rest/pollingHelper.ts b/sdk/openai/openai/sources/generated/src/rest/pollingHelper.ts index 47d8fdcea6dd..2a79964f9c75 100644 --- a/sdk/openai/openai/sources/generated/src/rest/pollingHelper.ts +++ b/sdk/openai/openai/sources/generated/src/rest/pollingHelper.ts @@ -11,9 +11,6 @@ import { createHttpPoller, } from "@azure/core-lro"; import { - GetAzureBatchImageGenerationOperationStatus200Response, - GetAzureBatchImageGenerationOperationStatusDefaultResponse, - GetAzureBatchImageGenerationOperationStatusLogicalResponse, BeginAzureBatchImageGeneration202Response, BeginAzureBatchImageGenerationDefaultResponse, BeginAzureBatchImageGenerationLogicalResponse, @@ -36,17 +33,6 @@ export async function getLongRunningPoller< | BeginAzureBatchImageGenerationDefaultResponse, options?: CreateHttpPollerOptions> ): Promise, TResult>>; -export async function getLongRunningPoller< - TResult extends - | GetAzureBatchImageGenerationOperationStatusLogicalResponse - | GetAzureBatchImageGenerationOperationStatusDefaultResponse ->( - client: Client, - initialResponse: - | GetAzureBatchImageGenerationOperationStatus200Response - | GetAzureBatchImageGenerationOperationStatusDefaultResponse, - options?: CreateHttpPollerOptions> -): Promise, TResult>>; export async function getLongRunningPoller( client: Client, initialResponse: TResult, diff --git a/sdk/openai/openai/sources/generated/src/rest/responses.ts b/sdk/openai/openai/sources/generated/src/rest/responses.ts index 5f5fcb9ad1a6..e32fd648f89b 100644 --- a/sdk/openai/openai/sources/generated/src/rest/responses.ts +++ b/sdk/openai/openai/sources/generated/src/rest/responses.ts @@ -4,27 +4,88 @@ import { RawHttpHeaders } from "@azure/core-rest-pipeline"; import { HttpResponse, ErrorResponse } from "@azure-rest/core-client"; import { - EmbeddingsOutput, + AudioTranscriptionOutput, + AudioTranslationOutput, CompletionsOutput, ChatCompletionsOutput, BatchImageGenerationOperationResponseOutput, + EmbeddingsOutput, } from "./outputModels.js"; /** The request has succeeded. */ -export interface GetEmbeddings200Response extends HttpResponse { +export interface GetAudioTranscriptionAsPlainText200Response + extends HttpResponse { status: "200"; - body: EmbeddingsOutput; + body: string; } -export interface GetEmbeddingsDefaultHeaders { +export interface GetAudioTranscriptionAsPlainTextDefaultHeaders { /** String error code indicating what went wrong. */ "x-ms-error-code"?: string; } -export interface GetEmbeddingsDefaultResponse extends HttpResponse { +export interface GetAudioTranscriptionAsPlainTextDefaultResponse + extends HttpResponse { status: string; body: ErrorResponse; - headers: RawHttpHeaders & GetEmbeddingsDefaultHeaders; + headers: RawHttpHeaders & GetAudioTranscriptionAsPlainTextDefaultHeaders; +} + +/** The request has succeeded. */ +export interface GetAudioTranscriptionAsResponseObject200Response + extends HttpResponse { + status: "200"; + body: AudioTranscriptionOutput; +} + +export interface GetAudioTranscriptionAsResponseObjectDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface GetAudioTranscriptionAsResponseObjectDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & GetAudioTranscriptionAsResponseObjectDefaultHeaders; +} + +/** The request has succeeded. */ +export interface GetAudioTranslationAsPlainText200Response + extends HttpResponse { + status: "200"; + body: string; +} + +export interface GetAudioTranslationAsPlainTextDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface GetAudioTranslationAsPlainTextDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & GetAudioTranslationAsPlainTextDefaultHeaders; +} + +/** The request has succeeded. */ +export interface GetAudioTranslationAsResponseObject200Response + extends HttpResponse { + status: "200"; + body: AudioTranslationOutput; +} + +export interface GetAudioTranslationAsResponseObjectDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface GetAudioTranslationAsResponseObjectDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & GetAudioTranslationAsResponseObjectDefaultHeaders; } /** The request has succeeded. */ @@ -100,13 +161,6 @@ export interface GetAzureBatchImageGenerationOperationStatusDefaultResponse GetAzureBatchImageGenerationOperationStatusDefaultHeaders; } -/** The final response for long-running getAzureBatchImageGenerationOperationStatus operation */ -export interface GetAzureBatchImageGenerationOperationStatusLogicalResponse - extends HttpResponse { - status: "200"; - body: BatchImageGenerationOperationResponseOutput; -} - export interface BeginAzureBatchImageGeneration202Headers { /** The location for monitoring the operation state. */ "operation-location": string; @@ -138,3 +192,20 @@ export interface BeginAzureBatchImageGenerationLogicalResponse status: "200"; body: BatchImageGenerationOperationResponseOutput; } + +/** The request has succeeded. */ +export interface GetEmbeddings200Response extends HttpResponse { + status: "200"; + body: EmbeddingsOutput; +} + +export interface GetEmbeddingsDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface GetEmbeddingsDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & GetEmbeddingsDefaultHeaders; +} diff --git a/sdk/openai/openai/tsconfig.json b/sdk/openai/openai/tsconfig.json index f68a1f924e6f..02a6a246faf1 100644 --- a/sdk/openai/openai/tsconfig.json +++ b/sdk/openai/openai/tsconfig.json @@ -3,12 +3,26 @@ "compilerOptions": { "outDir": "./dist-esm", "declarationDir": "./types", - "paths": { "@azure/openai": ["./src/index.js"] }, + "paths": { + "@azure/openai": [ + "./src/index.js" + ] + }, "module": "NodeNext", "moduleResolution": "NodeNext", - "lib": ["esnext", "dom"], + "lib": [ + "esnext", + "dom" + ], "rootDir": "." }, - "ts-node": { "esm": true }, - "include": ["src/**/*.ts", "sources/**/*.ts", "test/**/*.ts", "samples-dev/**/*.ts"] -} + "ts-node": { + "esm": true + }, + "include": [ + "src/**/*.ts", + "sources/**/*.ts", + "test/**/*.ts", + "samples-dev/**/*.ts" + ] +} \ No newline at end of file diff --git a/sdk/openai/openai/tsp-location.yaml b/sdk/openai/openai/tsp-location.yaml index 2246c7155e2f..ce882a4fc921 100644 --- a/sdk/openai/openai/tsp-location.yaml +++ b/sdk/openai/openai/tsp-location.yaml @@ -1,3 +1,5 @@ -directory: specification/cognitiveservices/OpenAI.Inference -commit: b646a42aa3b7a0ce488d05f1724827ea41d12cf1 +additionalDirectories: [] repo: Azure/azure-rest-api-specs +directory: specification/cognitiveservices/OpenAI.Inference +commit: 4c6ebd44758234bf4b70bacf3500464a0602412d +