diff --git a/eng/config.json b/eng/config.json index 77083b68aba6..025343812348 100644 --- a/eng/config.json +++ b/eng/config.json @@ -46,7 +46,7 @@ }, { "Name": "azopenai", - "CoverageGoal": 0.32 + "CoverageGoal": 0.28 }, { "Name": "aztemplate", diff --git a/sdk/ai/azopenai/.gitignore b/sdk/ai/azopenai/.gitignore new file mode 100644 index 000000000000..9793e7052e8b --- /dev/null +++ b/sdk/ai/azopenai/.gitignore @@ -0,0 +1,3 @@ +# generated apiview output +azopenai.json + diff --git a/sdk/ai/azopenai/CHANGELOG.md b/sdk/ai/azopenai/CHANGELOG.md index 65e4470edcd1..9bc7d1c6401d 100644 --- a/sdk/ai/azopenai/CHANGELOG.md +++ b/sdk/ai/azopenai/CHANGELOG.md @@ -1,5 +1,18 @@ # Release History +## 0.5.0 (2024-03-05) + +### Features Added + +- Updating to the `2024-02-15-preview` API version. +- `GetAudioSpeech` enables translating text to speech. + +### Breaking Changes + +- Citations, previously returned as an unparsed JSON blob, are now deserialized into a real type in `ChatResponseMessage.Citations`. +- `AzureCognitiveSearchChatExtensionConfiguration` has been renamed to `AzureSearchChatExtensionConfiguration`. +- `AzureCognitiveSearchChatExtensionParameters` has been renamed to `AzureSearchChatExtensionParameters`. + ## 0.4.1 (2024-01-16) ### Bugs Fixed diff --git a/sdk/ai/azopenai/README.md b/sdk/ai/azopenai/README.md index f4590827a505..0b7449a6ef87 100644 --- a/sdk/ai/azopenai/README.md +++ b/sdk/ai/azopenai/README.md @@ -2,7 +2,10 @@ NOTE: this client can be used with Azure OpenAI and OpenAI. -Azure OpenAI Service provides access to OpenAI's powerful language models including the GPT-4, GPT-35-Turbo, and Embeddings model series, as well as image generation using DALL-E. +Azure OpenAI Service provides access to OpenAI's features: +- Language models including the GPT-4, GPT-35-Turbo, and Embeddings model series. +- Image generation using DALL-E. +- Speech transcription and speech generation. [Source code][azopenai_repo] | [Package (pkg.go.dev)][azopenai_pkg_go] | [REST API documentation][openai_rest_docs] | [Product documentation][openai_docs] diff --git a/sdk/ai/azopenai/assets.json b/sdk/ai/azopenai/assets.json index 7cbfc913d854..743f949ea1c4 100644 --- a/sdk/ai/azopenai/assets.json +++ b/sdk/ai/azopenai/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "go", "TagPrefix": "go/ai/azopenai", - "Tag": "go/ai/azopenai_85a01b7ac6" + "Tag": "go/ai/azopenai_05b058e350" } diff --git a/sdk/ai/azopenai/autorest.md b/sdk/ai/azopenai/autorest.md index a56983b793aa..e38c837679b6 100644 --- a/sdk/ai/azopenai/autorest.md +++ b/sdk/ai/azopenai/autorest.md @@ -4,14 +4,15 @@ These settings apply only when `--go` is specified on the command line. ``` yaml input-file: -- https://github.com/Azure/azure-rest-api-specs/blob/3e0e2a93ddb3c9c44ff1baf4952baa24ca98e9db/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-12-01-preview/generated.json +# this file is generated using the ./testdata/genopenapi.ps1 file. +- ./testdata/generated/openapi.json output-folder: ../azopenai clear-output-folder: false module: github.com/Azure/azure-sdk-for-go/sdk/ai/azopenai license-header: MICROSOFT_MIT_NO_VERSION openapi-type: data-plane go: true -use: "@autorest/go@4.0.0-preview.52" +use: "@autorest/go@4.0.0-preview.63" title: "OpenAI" slice-elements-byval: true # can't use this since it removes an innererror type that we want () @@ -40,14 +41,25 @@ directive: ```yaml directive: - from: swagger-document - where: $.definitions + where: $.definitions.GenerateSpeechFromTextOptions.properties + transform: | + $["model"] = { + "type": "string", + "description": "The model to use for this request." + } + return $; + - from: + - models.go + - models_serde.go + - options.go + - client.go + where: $ transform: | - $["AudioTranscriptionOptions"].properties["model"]["x-ms-client-name"] = "DeploymentName"; - $["AudioTranslationOptions"].properties["model"]["x-ms-client-name"] = "DeploymentName"; - $["ChatCompletionsOptions"].properties["model"]["x-ms-client-name"] = "DeploymentName"; - $["CompletionsOptions"].properties["model"]["x-ms-client-name"] = "DeploymentName"; - $["EmbeddingsOptions"].properties["model"]["x-ms-client-name"] = "DeploymentName"; - $["ImageGenerationOptions"].properties["model"]["x-ms-client-name"] = "DeploymentName"; + return $.replace(/Model \*string/g, 'DeploymentName *string') + .replace(/populate\(objectMap, "model", (.)\.Model\)/g, 'populate(objectMap, "model", $1.DeploymentName)') + .replace(/err = unpopulate\(val, "Model", &(.)\.Model\)/g, 'err = unpopulate(val, "Model", &$1.DeploymentName)') + .replace(/Model:/g, "DeploymentName: "); + ``` ## Polymorphic adjustments @@ -111,21 +123,6 @@ directive: transform: return $.replace(/InternalChatCompletionsResponseFormat/g, "respType") ``` -## Model -> DeploymentName - -```yaml -directive: - - from: swagger-document - where: $.definitions - transform: | - $["AudioTranscriptionOptions"].properties["model"]["x-ms-client-name"] = "DeploymentName"; - $["AudioTranslationOptions"].properties["model"]["x-ms-client-name"] = "DeploymentName"; - $["ChatCompletionsOptions"].properties["model"]["x-ms-client-name"] = "DeploymentName"; - $["CompletionsOptions"].properties["model"]["x-ms-client-name"] = "DeploymentName"; - $["EmbeddingsOptions"].properties["model"]["x-ms-client-name"] = "DeploymentName"; - $["ImageGenerationOptions"].properties["model"]["x-ms-client-name"] = "DeploymentName"; -``` - ## Cleanup the audio transcription APIs We're wrapping the audio translation and transcription APIs, so we can eliminate some of @@ -139,21 +136,52 @@ directive: - models_serde.go where: $ transform: | - return $ - .replace(/type XMSPathsHksgfdDeploymentsDeploymentidAudioTranscriptionsOverloadGetaudiotranscriptionasresponseobjectPostRequestbodyContentMultipartFormDataSchema struct.+?\n}/s, "") - .replace(/\/\/ MarshalJSON implements the json.Marshaller interface for type XMSPathsHksgfdDeploymentsDeploymentidAudioTranscriptionsOverloadGetaudiotranscriptionasresponseobjectPostRequestbodyContentMultipartFormDataSchema.+?\n}/s, "") - .replace(/\/\/ UnmarshalJSON implements the json.Unmarshaller interface for type XMSPathsHksgfdDeploymentsDeploymentidAudioTranscriptionsOverloadGetaudiotranscriptionasresponseobjectPostRequestbodyContentMultipartFormDataSchema.+?\n}/s, "") - .replace(/type XMSPaths1Ak7Ov3DeploymentsDeploymentidAudioTranslationsOverloadGetaudiotranslationasresponseobjectPostRequestbodyContentMultipartFormDataSchema struct.+?\n}/s, "") - .replace(/\/\/ MarshalJSON implements the json.Marshaller interface for type XMSPaths1Ak7Ov3DeploymentsDeploymentidAudioTranslationsOverloadGetaudiotranslationasresponseobjectPostRequestbodyContentMultipartFormDataSchema.+?\n}/s, "") - .replace(/\/\/ UnmarshalJSON implements the json.Unmarshaller interface for type XMSPaths1Ak7Ov3DeploymentsDeploymentidAudioTranslationsOverloadGetaudiotranslationasresponseobjectPostRequestbodyContentMultipartFormDataSchema.+?\n}/s, ""); + const typesToRemove = [ + 'XMSPathsHksgfdDeploymentsDeploymentidAudioTranscriptionsOverloadGetaudiotranscriptionasresponseobjectPostRequestbodyContentMultipartFormDataSchema', + 'XMSPaths1Ak7Ov3DeploymentsDeploymentidAudioTranslationsOverloadGetaudiotranslationasresponseobjectPostRequestbodyContentMultipartFormDataSchema', + 'Paths1G1Yr9HDeploymentsDeploymentidAudioTranslationsPostRequestbodyContentMultipartFormDataSchema', + 'Paths1MlipaDeploymentsDeploymentidAudioTranscriptionsPostRequestbodyContentMultipartFormDataSchema' + ]; + + for (let name of typesToRemove) { + $ = $.replace(new RegExp(`type ${name} struct.+?\n}`, "s"), "") + .replace(new RegExp(`// MarshalJSON implements the json.Marshaller interface for type ${name}.+?\n}`, "s"), "") + .replace(new RegExp(`// UnmarshalJSON implements the json.Unmarshaller interface for type ${name}.+?\n}`, "s"), ""); + } + return $; # kill API functions - from: - client.go where: $ transform: | + return $.replace(/\/\/ GetAudioTranscriptionAsPlainText -.+?\n\}\n/s, "") + .replace(/\/\/ GetAudioTranslationAsPlainText -.+?\n\}\n/s, "") + .replace(/\/\/ getAudioTranscriptionAsPlainTextCreateRequest.+?\n}\n/s, "") + .replace(/\/\/ getAudioTranscriptionAsPlainTextHandleResponse.+?\n}\n/s, "") + .replace(/\/\/ getAudioTranslationAsPlainTextCreateRequest.+?\n}\n/s, "") + .replace(/\/\/ getAudioTranslationAsPlainTextHandleResponse.+?\n}\n/s, ""); + # remove other plain text models/options + - from: + - options.go + where: $ + transform: | + return $.replace(/\/\/ ClientGetAudioTranslationAsPlainTextOptions .+?\n\}\n/s, "") + .replace(/\/\/ ClientGetAudioTranscriptionAsPlainTextOptions .+?\n\}\n/s, ""); + # remove other plain text models/options + - from: + - responses.go + where: $ + transform: | + return $.replace(/\/\/ ClientGetAudioTranscriptionAsPlainTextResponse .+?\n\}\n/s, "") + .replace(/\/\/ ClientGetAudioTranslationAsPlainTextResponse .+?\n\}\n/s, ""); + + # fix any calls that don't use 'deploymentID' + - from: client.go + where: $ + transform: | return $ - .replace(/\/\/ GetAudioTranscriptionAsPlainText -.+?\n}/s, "") - .replace(/\/\/ GetAudioTransclationAsPlainText -.+?\n}/s, ""); + .replace(/, deploymentID string,/g, ",") + .replace(/ctx, deploymentID, /g, "ctx, ") ``` ## Move the Azure extensions into their own section of the options @@ -168,7 +196,7 @@ We've moved these 'extension' data types into their own field. ```yaml directive: - from: swagger-document - where: $.definitions.ChatCompletionsOptions.properties.dataSources + where: $.definitions.ChatCompletionsOptions.properties.data_sources transform: $["x-ms-client-name"] = "AzureExtensionsOptions" ``` @@ -266,7 +294,7 @@ directive: - client.go - models.go - models_serde.go - - response_types.go + - responses.go - options.go where: $ transform: | @@ -314,7 +342,7 @@ directive: - models.go - models_serde.go - options.go - - response_types.go + - responses.go where: $ transform: return $.replace(/Logprobs/g, "LogProbs") ``` @@ -386,18 +414,18 @@ directive: - client.go - models.go - options.go - - response_types.go + - responses.go where: $ transform: return $.replace(/Client(\w+)((?:Options|Response))/g, "$1$2"); # Make the Azure extensions internal - we expose these through the GetChatCompletions*() functions # and just treat which endpoint we use as an implementation detail. - - from: client.go - where: $ - transform: | - return $ - .replace(/GetChatCompletionsWithAzureExtensions([ (])/g, "getChatCompletionsWithAzureExtensions$1") - .replace(/GetChatCompletions([ (])/g, "getChatCompletions$1"); + # - from: client.go + # where: $ + # transform: | + # return $ + # .replace(/GetChatCompletionsWithAzureExtensions([ (])/g, "getChatCompletionsWithAzureExtensions$1") + # .replace(/GetChatCompletions([ (])/g, "getChatCompletions$1"); ``` ## Workarounds @@ -556,35 +584,6 @@ directive: `}\n`); ``` -Add in the older style of function call as that's still the only way to talk to older models. - -```yaml -directive: - - from: models.go - where: $ - transform: | - const text = - `// Controls how the model responds to function calls. "none" means the model does not call a function, and responds to the\n` + - `// end-user. "auto" means the model can pick between an end-user or calling a\n` + - `// function. Specifying a particular function via {"name": "my_function"} forces the model to call that function. "none" is\n` + - `// the default when no functions are present. "auto" is the default if functions\n` + - `// are present.\n` + - `FunctionCall *ChatCompletionsOptionsFunctionCall\n` + - `\n` + - `// A list of functions the model may generate JSON inputs for.\n` + - `Functions []FunctionDefinition\n`; - - return $.replace(/(type ChatCompletionsOptions struct \{.+?FrequencyPenalty \*float32)/s, "$1\n\n" + text); - - from: models_serde.go - where: $ - transform: | - const populateLines = - `populate(objectMap, "function_call", c.FunctionCall)\n` + - `populate(objectMap, "functions", c.Functions)`; - - return $.replace(/(func \(c ChatCompletionsOptions\) MarshalJSON\(\).+?populate\(objectMap, "frequency_penalty", c.FrequencyPenalty\))/s, "$1\n" + populateLines) -``` - Fix ToolChoice discriminated union ```yaml @@ -602,3 +601,13 @@ directive: .replace(/ToolChoiceRenameMe/g, "ToolChoice") // rename all other references .replace(/populateAny\(objectMap, "tool_choice", c\.ToolChoice\)/, 'populate(objectMap, "tool_choice", c.ToolChoice)'); // treat field as typed so nil means omit. ``` + +```yaml +directive: + - from: models.go + where: $ + transform: return $.replace(/FunctionCall any/, "FunctionCall *ChatCompletionsOptionsFunctionCall"); + - from: models_serde.go + where: $ + transform: return $.replace(/populateAny\(objectMap, "function_call", c\.FunctionCall\)/, 'populate(objectMap, "function_call", c.FunctionCall)'); +``` diff --git a/sdk/ai/azopenai/build.go b/sdk/ai/azopenai/build.go index a3e6fe79680f..f891219bb83b 100644 --- a/sdk/ai/azopenai/build.go +++ b/sdk/ai/azopenai/build.go @@ -1,13 +1,12 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. //go:build go1.18 // +build go1.18 +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +//go:generate pwsh ./testdata/genopenapi.ps1 //go:generate autorest ./autorest.md //go:generate go mod tidy //go:generate goimports -w . -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. - package azopenai diff --git a/sdk/ai/azopenai/client.go b/sdk/ai/azopenai/client.go index cc3e175e010b..90ddfa424f16 100644 --- a/sdk/ai/azopenai/client.go +++ b/sdk/ai/azopenai/client.go @@ -25,46 +25,60 @@ type Client struct { clientData } -// getAudioTranscriptionAsPlainTextCreateRequest creates the GetAudioTranscriptionAsPlainText request. -func (client *Client) getAudioTranscriptionAsPlainTextCreateRequest(ctx context.Context, body AudioTranscriptionOptions, options *GetAudioTranscriptionAsPlainTextOptions) (*policy.Request, error) { - urlPath := "audio/transcriptions" +// GenerateSpeechFromText - Generates text-to-speech audio from the input text. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-02-15-preview +// - options - GenerateSpeechFromTextOptions contains the optional parameters for the Client.GenerateSpeechFromText method. +func (client *Client) GenerateSpeechFromText(ctx context.Context, body SpeechGenerationOptions, options *GenerateSpeechFromTextOptions) (GenerateSpeechFromTextResponse, error) { + var err error + req, err := client.generateSpeechFromTextCreateRequest(ctx, body, options) + if err != nil { + return GenerateSpeechFromTextResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return GenerateSpeechFromTextResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = client.newError(httpResp) + return GenerateSpeechFromTextResponse{}, err + } + return GenerateSpeechFromTextResponse{Body: httpResp.Body}, nil +} + +// generateSpeechFromTextCreateRequest creates the GenerateSpeechFromText request. +func (client *Client) generateSpeechFromTextCreateRequest(ctx context.Context, body SpeechGenerationOptions, options *GenerateSpeechFromTextOptions) (*policy.Request, error) { + urlPath := "audio/speech" req, err := runtime.NewRequest(ctx, http.MethodPost, client.formatURL(urlPath, getDeployment(body))) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-12-01-preview") + reqQP.Set("api-version", "2024-02-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} + runtime.SkipBodyDownload(req) + req.Raw().Header["Accept"] = []string{"application/octet-stream, application/json"} if err := runtime.MarshalAsJSON(req, body); err != nil { return nil, err } return req, nil } -// getAudioTranscriptionAsPlainTextHandleResponse handles the GetAudioTranscriptionAsPlainText response. -func (client *Client) getAudioTranscriptionAsPlainTextHandleResponse(resp *http.Response) (GetAudioTranscriptionAsPlainTextResponse, error) { - result := GetAudioTranscriptionAsPlainTextResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Value); err != nil { - return GetAudioTranscriptionAsPlainTextResponse{}, err - } - return result, nil -} - // getAudioTranscriptionInternal - 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. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-12-01-preview +// Generated from API version 2024-02-15-preview // - deploymentID - Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure // OpenAI) to use for this request. // - file - 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. // - options - getAudioTranscriptionInternalOptions contains the optional parameters for the Client.getAudioTranscriptionInternal // method. -func (client *Client) getAudioTranscriptionInternal(ctx context.Context, deploymentID string, file io.ReadSeekCloser, options *getAudioTranscriptionInternalOptions) (getAudioTranscriptionInternalResponse, error) { +func (client *Client) getAudioTranscriptionInternal(ctx context.Context, file io.ReadSeekCloser, options *getAudioTranscriptionInternalOptions) (getAudioTranscriptionInternalResponse, error) { var err error - req, err := client.getAudioTranscriptionInternalCreateRequest(ctx, deploymentID, file, options) + req, err := client.getAudioTranscriptionInternalCreateRequest(ctx, file, options) if err != nil { return getAudioTranscriptionInternalResponse{}, err } @@ -81,14 +95,14 @@ func (client *Client) getAudioTranscriptionInternal(ctx context.Context, deploym } // getAudioTranscriptionInternalCreateRequest creates the getAudioTranscriptionInternal request. -func (client *Client) getAudioTranscriptionInternalCreateRequest(ctx context.Context, deploymentID string, file io.ReadSeekCloser, body *getAudioTranscriptionInternalOptions) (*policy.Request, error) { +func (client *Client) getAudioTranscriptionInternalCreateRequest(ctx context.Context, file io.ReadSeekCloser, body *getAudioTranscriptionInternalOptions) (*policy.Request, error) { urlPath := "audio/transcriptions" req, err := runtime.NewRequest(ctx, http.MethodPost, client.formatURL(urlPath, getDeployment(body))) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-12-01-preview") + reqQP.Set("api-version", "2024-02-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := setMultipartFormData(req, file, *body); err != nil { @@ -106,71 +120,20 @@ func (client *Client) getAudioTranscriptionInternalHandleResponse(resp *http.Res return result, nil } -// GetAudioTranslationAsPlainText - Gets English language transcribed text and associated metadata from provided spoken audio -// data. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2023-12-01-preview -// - options - GetAudioTranslationAsPlainTextOptions contains the optional parameters for the Client.GetAudioTranslationAsPlainText -// method. -func (client *Client) GetAudioTranslationAsPlainText(ctx context.Context, body AudioTranslationOptions, options *GetAudioTranslationAsPlainTextOptions) (GetAudioTranslationAsPlainTextResponse, error) { - var err error - req, err := client.getAudioTranslationAsPlainTextCreateRequest(ctx, body, options) - if err != nil { - return GetAudioTranslationAsPlainTextResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return GetAudioTranslationAsPlainTextResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = client.newError(httpResp) - return GetAudioTranslationAsPlainTextResponse{}, err - } - resp, err := client.getAudioTranslationAsPlainTextHandleResponse(httpResp) - return resp, err -} - -// getAudioTranslationAsPlainTextCreateRequest creates the GetAudioTranslationAsPlainText request. -func (client *Client) getAudioTranslationAsPlainTextCreateRequest(ctx context.Context, body AudioTranslationOptions, options *GetAudioTranslationAsPlainTextOptions) (*policy.Request, error) { - urlPath := "audio/translations" - req, err := runtime.NewRequest(ctx, http.MethodPost, client.formatURL(urlPath, getDeployment(body))) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-12-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, body); err != nil { - return nil, err - } - return req, nil -} - -// getAudioTranslationAsPlainTextHandleResponse handles the GetAudioTranslationAsPlainText response. -func (client *Client) getAudioTranslationAsPlainTextHandleResponse(resp *http.Response) (GetAudioTranslationAsPlainTextResponse, error) { - result := GetAudioTranslationAsPlainTextResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Value); err != nil { - return GetAudioTranslationAsPlainTextResponse{}, err - } - return result, nil -} - // getAudioTranslationInternal - Gets English language transcribed text and associated metadata from provided spoken audio // data. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-12-01-preview +// Generated from API version 2024-02-15-preview // - deploymentID - Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure // OpenAI) to use for this request. // - file - 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. // - options - getAudioTranslationInternalOptions contains the optional parameters for the Client.getAudioTranslationInternal // method. -func (client *Client) getAudioTranslationInternal(ctx context.Context, deploymentID string, file io.ReadSeekCloser, options *getAudioTranslationInternalOptions) (getAudioTranslationInternalResponse, error) { +func (client *Client) getAudioTranslationInternal(ctx context.Context, file io.ReadSeekCloser, options *getAudioTranslationInternalOptions) (getAudioTranslationInternalResponse, error) { var err error - req, err := client.getAudioTranslationInternalCreateRequest(ctx, deploymentID, file, options) + req, err := client.getAudioTranslationInternalCreateRequest(ctx, file, options) if err != nil { return getAudioTranslationInternalResponse{}, err } @@ -187,14 +150,14 @@ func (client *Client) getAudioTranslationInternal(ctx context.Context, deploymen } // getAudioTranslationInternalCreateRequest creates the getAudioTranslationInternal request. -func (client *Client) getAudioTranslationInternalCreateRequest(ctx context.Context, deploymentID string, file io.ReadSeekCloser, body *getAudioTranslationInternalOptions) (*policy.Request, error) { +func (client *Client) getAudioTranslationInternalCreateRequest(ctx context.Context, file io.ReadSeekCloser, body *getAudioTranslationInternalOptions) (*policy.Request, error) { urlPath := "audio/translations" req, err := runtime.NewRequest(ctx, http.MethodPost, client.formatURL(urlPath, getDeployment(body))) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-12-01-preview") + reqQP.Set("api-version", "2024-02-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := setMultipartFormData(req, file, *body); err != nil { @@ -212,13 +175,13 @@ func (client *Client) getAudioTranslationInternalHandleResponse(resp *http.Respo return result, nil } -// getChatCompletions - Gets chat completions for the provided chat messages. Completions support a wide variety of tasks +// GetChatCompletions - Gets chat completions for the provided chat messages. Completions support a wide variety of tasks // and generate text that continues from or "completes" provided prompt data. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-12-01-preview -// - options - GetChatCompletionsOptions contains the optional parameters for the Client.getChatCompletions method. -func (client *Client) getChatCompletions(ctx context.Context, body ChatCompletionsOptions, options *GetChatCompletionsOptions) (GetChatCompletionsResponse, error) { +// Generated from API version 2024-02-15-preview +// - options - GetChatCompletionsOptions contains the optional parameters for the Client.GetChatCompletions method. +func (client *Client) GetChatCompletions(ctx context.Context, body ChatCompletionsOptions, options *GetChatCompletionsOptions) (GetChatCompletionsResponse, error) { var err error req, err := client.getChatCompletionsCreateRequest(ctx, body, options) if err != nil { @@ -236,7 +199,7 @@ func (client *Client) getChatCompletions(ctx context.Context, body ChatCompletio return resp, err } -// getChatCompletionsCreateRequest creates the getChatCompletions request. +// getChatCompletionsCreateRequest creates the GetChatCompletions request. func (client *Client) getChatCompletionsCreateRequest(ctx context.Context, body ChatCompletionsOptions, options *GetChatCompletionsOptions) (*policy.Request, error) { urlPath := "chat/completions" req, err := runtime.NewRequest(ctx, http.MethodPost, client.formatURL(urlPath, getDeployment(body))) @@ -244,7 +207,7 @@ func (client *Client) getChatCompletionsCreateRequest(ctx context.Context, body return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-12-01-preview") + reqQP.Set("api-version", "2024-02-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, body); err != nil { @@ -253,7 +216,7 @@ func (client *Client) getChatCompletionsCreateRequest(ctx context.Context, body return req, nil } -// getChatCompletionsHandleResponse handles the getChatCompletions response. +// getChatCompletionsHandleResponse handles the GetChatCompletions response. func (client *Client) getChatCompletionsHandleResponse(resp *http.Response) (GetChatCompletionsResponse, error) { result := GetChatCompletionsResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.ChatCompletions); err != nil { @@ -262,63 +225,11 @@ func (client *Client) getChatCompletionsHandleResponse(resp *http.Response) (Get return result, nil } -// getChatCompletionsWithAzureExtensions - Gets chat completions for the provided chat messages. This is an Azure-specific -// version of chat completions that supports integration with configured data sources and other augmentations to the base -// chat completions capabilities. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2023-12-01-preview -// - options - GetChatCompletionsWithAzureExtensionsOptions contains the optional parameters for the Client.GetChatCompletionsWithAzureExtensions -// method. -func (client *Client) getChatCompletionsWithAzureExtensions(ctx context.Context, body ChatCompletionsOptions, options *GetChatCompletionsWithAzureExtensionsOptions) (GetChatCompletionsWithAzureExtensionsResponse, error) { - var err error - req, err := client.getChatCompletionsWithAzureExtensionsCreateRequest(ctx, body, options) - if err != nil { - return GetChatCompletionsWithAzureExtensionsResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return GetChatCompletionsWithAzureExtensionsResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = client.newError(httpResp) - return GetChatCompletionsWithAzureExtensionsResponse{}, err - } - resp, err := client.getChatCompletionsWithAzureExtensionsHandleResponse(httpResp) - return resp, err -} - -// getChatCompletionsWithAzureExtensionsCreateRequest creates the getChatCompletionsWithAzureExtensions request. -func (client *Client) getChatCompletionsWithAzureExtensionsCreateRequest(ctx context.Context, body ChatCompletionsOptions, options *GetChatCompletionsWithAzureExtensionsOptions) (*policy.Request, error) { - urlPath := "extensions/chat/completions" - req, err := runtime.NewRequest(ctx, http.MethodPost, client.formatURL(urlPath, getDeployment(body))) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-12-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, body); err != nil { - return nil, err - } - return req, nil -} - -// getChatCompletionsWithAzureExtensionsHandleResponse handles the getChatCompletionsWithAzureExtensions response. -func (client *Client) getChatCompletionsWithAzureExtensionsHandleResponse(resp *http.Response) (GetChatCompletionsWithAzureExtensionsResponse, error) { - result := GetChatCompletionsWithAzureExtensionsResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ChatCompletions); err != nil { - return GetChatCompletionsWithAzureExtensionsResponse{}, err - } - return result, nil -} - // GetCompletions - Gets completions for the provided input prompts. Completions support a wide variety of tasks and generate // text that continues from or "completes" provided prompt data. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-12-01-preview +// Generated from API version 2024-02-15-preview // - options - GetCompletionsOptions contains the optional parameters for the Client.GetCompletions method. func (client *Client) GetCompletions(ctx context.Context, body CompletionsOptions, options *GetCompletionsOptions) (GetCompletionsResponse, error) { var err error @@ -346,7 +257,7 @@ func (client *Client) getCompletionsCreateRequest(ctx context.Context, body Comp return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-12-01-preview") + reqQP.Set("api-version", "2024-02-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, body); err != nil { @@ -367,7 +278,7 @@ func (client *Client) getCompletionsHandleResponse(resp *http.Response) (GetComp // GetEmbeddings - Return the embeddings for a given prompt. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-12-01-preview +// Generated from API version 2024-02-15-preview // - options - GetEmbeddingsOptions contains the optional parameters for the Client.GetEmbeddings method. func (client *Client) GetEmbeddings(ctx context.Context, body EmbeddingsOptions, options *GetEmbeddingsOptions) (GetEmbeddingsResponse, error) { var err error @@ -395,7 +306,7 @@ func (client *Client) getEmbeddingsCreateRequest(ctx context.Context, body Embed return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-12-01-preview") + reqQP.Set("api-version", "2024-02-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, body); err != nil { @@ -416,7 +327,7 @@ func (client *Client) getEmbeddingsHandleResponse(resp *http.Response) (GetEmbed // GetImageGenerations - Creates an image given a prompt. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-12-01-preview +// Generated from API version 2024-02-15-preview // - options - GetImageGenerationsOptions contains the optional parameters for the Client.GetImageGenerations method. func (client *Client) GetImageGenerations(ctx context.Context, body ImageGenerationOptions, options *GetImageGenerationsOptions) (GetImageGenerationsResponse, error) { var err error @@ -444,7 +355,7 @@ func (client *Client) getImageGenerationsCreateRequest(ctx context.Context, body return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-12-01-preview") + reqQP.Set("api-version", "2024-02-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, body); err != nil { diff --git a/sdk/ai/azopenai/client_audio_internal_test.go b/sdk/ai/azopenai/client_audio_internal_test.go index e5d6385231cd..d755232645c0 100644 --- a/sdk/ai/azopenai/client_audio_internal_test.go +++ b/sdk/ai/azopenai/client_audio_internal_test.go @@ -21,18 +21,14 @@ import ( "github.com/stretchr/testify/require" ) -func newSeekableBytes(data []byte) io.ReadSeekCloser { - return streaming.NopCloser(bytes.NewReader(data)) -} - func TestSetMultipartFormData(t *testing.T) { t.Run("getAudioTranscriptionInternalOptions", func(t *testing.T) { req, err := runtime.NewRequest(context.Background(), "POST", "http://localhost") require.NoError(t, err) - err = setMultipartFormData(req, newSeekableBytes([]byte{1, 2, 3}), getAudioTranscriptionInternalOptions{ + err = setMultipartFormData(req, streaming.NopCloser(bytes.NewReader([]byte{1, 2, 3})), getAudioTranscriptionInternalOptions{ Language: to.Ptr("en"), - Model: to.Ptr("hello"), + DeploymentName: to.Ptr("hello"), Prompt: to.Ptr("my prompt"), ResponseFormat: to.Ptr(AudioTranscriptionFormatJSON), Temperature: to.Ptr[float32](1.0), @@ -58,8 +54,8 @@ func TestSetMultipartFormData(t *testing.T) { req, err := runtime.NewRequest(context.Background(), "POST", "http://localhost") require.NoError(t, err) - err = setMultipartFormData(req, newSeekableBytes([]byte{1, 2, 3}), getAudioTranslationInternalOptions{ - Model: to.Ptr("hello"), + err = setMultipartFormData(req, streaming.NopCloser(bytes.NewReader([]byte{1, 2, 3})), getAudioTranslationInternalOptions{ + DeploymentName: to.Ptr("hello"), Prompt: to.Ptr("my prompt"), ResponseFormat: to.Ptr(AudioTranslationFormatJSON), Temperature: to.Ptr[float32](1.0), diff --git a/sdk/ai/azopenai/client_audio_test.go b/sdk/ai/azopenai/client_audio_test.go index fb6d3a2e1dd6..8e433548bf75 100644 --- a/sdk/ai/azopenai/client_audio_test.go +++ b/sdk/ai/azopenai/client_audio_test.go @@ -9,6 +9,7 @@ package azopenai_test import ( "context" "fmt" + "io" "os" "path/filepath" "testing" @@ -20,52 +21,75 @@ import ( func TestClient_GetAudioTranscription_AzureOpenAI(t *testing.T) { client := newTestClient(t, azureOpenAI.Whisper.Endpoint, withForgivingRetryOption()) - runTranscriptionTests(t, client, azureOpenAI.Whisper.Model) + runTranscriptionTests(t, client, azureOpenAI.Whisper.Model, true) } func TestClient_GetAudioTranscription_OpenAI(t *testing.T) { client := newOpenAIClientForTest(t) - - testFiles := []string{ - `testdata/sampledata_audiofiles_myVoiceIsMyPassportVerifyMe01.m4a`, - `testdata/sampledata_audiofiles_myVoiceIsMyPassportVerifyMe01.mp3`, - } - - for _, audioFile := range testFiles { - t.Run(fmt.Sprintf("verbose (%s)", filepath.Ext(audioFile)), func(t *testing.T) { - args := newTranscriptionOptions(azopenai.AudioTranscriptionFormatVerboseJSON, openAI.Whisper.Model, audioFile) - - transcriptResp, err := client.GetAudioTranscription(context.Background(), args, nil) - require.NoError(t, err) - require.NotEmpty(t, transcriptResp) - - require.NotEmpty(t, *transcriptResp.Text) - require.Greater(t, *transcriptResp.Duration, float32(0.0)) - require.NotEmpty(t, *transcriptResp.Language) - require.NotEmpty(t, transcriptResp.Segments) - require.NotEmpty(t, transcriptResp.Segments[0]) - require.NotEmpty(t, transcriptResp.Task) - }) - } + runTranscriptionTests(t, client, openAI.Whisper.Model, false) } func TestClient_GetAudioTranslation_AzureOpenAI(t *testing.T) { client := newTestClient(t, azureOpenAI.Whisper.Endpoint, withForgivingRetryOption()) - runTranslationTests(t, client, azureOpenAI.Whisper.Model) + runTranslationTests(t, client, azureOpenAI.Whisper.Model, true) } func TestClient_GetAudioTranslation_OpenAI(t *testing.T) { client := newOpenAIClientForTest(t) + runTranslationTests(t, client, openAI.Whisper.Model, false) +} - testFiles := []string{ - `testdata/sampledata_audiofiles_myVoiceIsMyPassportVerifyMe01.m4a`, - `testdata/sampledata_audiofiles_myVoiceIsMyPassportVerifyMe01.mp3`, - } +func TestClient_GetAudioSpeech(t *testing.T) { + client := newOpenAIClientForTest(t) - for _, audioFile := range testFiles { - t.Run(fmt.Sprintf("verbose (%s)", filepath.Ext(audioFile)), func(t *testing.T) { - args := newTranslationOptions(azopenai.AudioTranslationFormatVerboseJSON, openAI.Whisper.Model, audioFile) - transcriptResp, err := client.GetAudioTranslation(context.Background(), args, nil) + audioResp, err := client.GenerateSpeechFromText(context.Background(), azopenai.SpeechGenerationOptions{ + Input: to.Ptr("i am a computer"), + Voice: to.Ptr(azopenai.SpeechVoiceAlloy), + ResponseFormat: to.Ptr(azopenai.SpeechGenerationResponseFormatFlac), + DeploymentName: to.Ptr("tts-1"), + }, nil) + require.NoError(t, err) + + audioBytes, err := io.ReadAll(audioResp.Body) + require.NoError(t, err) + + require.NotEmpty(t, audioBytes) + require.Equal(t, "fLaC", string(audioBytes[0:4])) + + // now send _it_ back through the transcription API and see if we can get something useful. + transcriptionResp, err := client.GetAudioTranscription(context.Background(), azopenai.AudioTranscriptionOptions{ + Filename: to.Ptr("test.flac"), + File: audioBytes, + ResponseFormat: to.Ptr(azopenai.AudioTranscriptionFormatVerboseJSON), + DeploymentName: &openAI.Whisper.Model, + Temperature: to.Ptr[float32](0.0), + }, nil) + require.NoError(t, err) + + require.NotZero(t, *transcriptionResp.Duration) + + // it occasionally comes back with different punctuation or makes a complete sentence but + // the major words always come through. + require.Contains(t, *transcriptionResp.Text, "computer") +} + +func runTranscriptionTests(t *testing.T, client *azopenai.Client, model string, isAzure bool) { + // We're experiencing load issues on some of our shared test resources so we'll just spot check. + // The bulk of the logic will test against OpenAI anyways. + if isAzure { + t.Run(fmt.Sprintf("%s (%s)", azopenai.AudioTranscriptionFormatText, "m4a"), func(t *testing.T) { + args := newTranscriptionOptions(azopenai.AudioTranscriptionFormatText, model, "testdata/sampledata_audiofiles_myVoiceIsMyPassportVerifyMe01.m4a") + transcriptResp, err := client.GetAudioTranscription(context.Background(), args, nil) + require.NoError(t, err) + require.NotEmpty(t, transcriptResp) + + require.NotEmpty(t, *transcriptResp.Text) + requireEmptyAudioTranscription(t, transcriptResp.AudioTranscription) + }) + + t.Run(fmt.Sprintf("%s (%s)", azopenai.AudioTranscriptionFormatVerboseJSON, "mp3"), func(t *testing.T) { + args := newTranscriptionOptions(azopenai.AudioTranscriptionFormatVerboseJSON, model, "testdata/sampledata_audiofiles_myVoiceIsMyPassportVerifyMe01.mp3") + transcriptResp, err := client.GetAudioTranscription(context.Background(), args, nil) require.NoError(t, err) require.NotEmpty(t, transcriptResp) @@ -76,10 +100,9 @@ func TestClient_GetAudioTranslation_OpenAI(t *testing.T) { require.NotEmpty(t, transcriptResp.Segments[0]) require.NotEmpty(t, transcriptResp.Task) }) + return } -} -func runTranscriptionTests(t *testing.T, client *azopenai.Client, model string) { testFiles := []string{ `testdata/sampledata_audiofiles_myVoiceIsMyPassportVerifyMe01.m4a`, `testdata/sampledata_audiofiles_myVoiceIsMyPassportVerifyMe01.mp3`, @@ -144,7 +167,37 @@ func runTranscriptionTests(t *testing.T, client *azopenai.Client, model string) } } -func runTranslationTests(t *testing.T, client *azopenai.Client, model string) { +func runTranslationTests(t *testing.T, client *azopenai.Client, model string, isAzure bool) { + // We're experiencing load issues on some of our shared test resources so we'll just spot check. + // The bulk of the logic will test against OpenAI anyways. + if isAzure { + t.Run(fmt.Sprintf("%s (%s)", azopenai.AudioTranscriptionFormatText, "m4a"), func(t *testing.T) { + args := newTranslationOptions(azopenai.AudioTranslationFormatText, model, "testdata/sampledata_audiofiles_myVoiceIsMyPassportVerifyMe01.m4a") + transcriptResp, err := client.GetAudioTranslation(context.Background(), args, nil) + require.NoError(t, err) + require.NotEmpty(t, transcriptResp) + + require.NotEmpty(t, *transcriptResp.Text) + requireEmptyAudioTranslation(t, transcriptResp.AudioTranslation) + }) + + t.Run(fmt.Sprintf("%s (%s)", azopenai.AudioTranscriptionFormatVerboseJSON, "mp3"), func(t *testing.T) { + args := newTranslationOptions(azopenai.AudioTranslationFormatVerboseJSON, model, "testdata/sampledata_audiofiles_myVoiceIsMyPassportVerifyMe01.mp3") + transcriptResp, err := client.GetAudioTranslation(context.Background(), args, nil) + require.NoError(t, err) + require.NotEmpty(t, transcriptResp) + + require.NotEmpty(t, *transcriptResp.Text) + require.Greater(t, *transcriptResp.Duration, float32(0.0)) + require.NotEmpty(t, *transcriptResp.Language) + require.NotEmpty(t, transcriptResp.Segments) + require.NotEmpty(t, transcriptResp.Segments[0]) + require.NotEmpty(t, transcriptResp.Task) + }) + + return + } + testFiles := []string{ `testdata/sampledata_audiofiles_myVoiceIsMyPassportVerifyMe01.m4a`, `testdata/sampledata_audiofiles_myVoiceIsMyPassportVerifyMe01.mp3`, diff --git a/sdk/ai/azopenai/client_chat_completions_extensions_test.go b/sdk/ai/azopenai/client_chat_completions_extensions_test.go index 4647b343cbec..23d5d5db25f0 100644 --- a/sdk/ai/azopenai/client_chat_completions_extensions_test.go +++ b/sdk/ai/azopenai/client_chat_completions_extensions_test.go @@ -31,12 +31,10 @@ func TestChatCompletions_extensions_bringYourOwnData(t *testing.T) { DeploymentName: &azureOpenAI.ChatCompletionsOYD.Model, }, nil) require.NoError(t, err) + require.NotEmpty(t, resp) - // when you BYOD you get some extra content showing you metadata/info from the external - // data source. msgContext := resp.Choices[0].Message.Context - require.NotEmpty(t, msgContext.Messages[0].Content) - require.Equal(t, azopenai.ChatRoleTool, *msgContext.Messages[0].Role) + require.NotEmpty(t, msgContext.Citations[0].Content) require.NotEmpty(t, *resp.Choices[0].Message.Content) require.Equal(t, azopenai.CompletionsFinishReasonStopped, *resp.Choices[0].FinishReason) @@ -77,8 +75,7 @@ func TestChatExtensionsStreaming_extensions_bringYourOwnData(t *testing.T) { // data source. first = false msgContext := event.Choices[0].Message.Context - require.NotEmpty(t, msgContext.Messages[0].Content) - require.Equal(t, azopenai.ChatRoleTool, *msgContext.Messages[0].Role) + require.NotEmpty(t, msgContext.Citations[0].Content) } for _, choice := range event.Choices { diff --git a/sdk/ai/azopenai/client_chat_completions_test.go b/sdk/ai/azopenai/client_chat_completions_test.go index c00ac1b9a278..5a54a1e3ad73 100644 --- a/sdk/ai/azopenai/client_chat_completions_test.go +++ b/sdk/ai/azopenai/client_chat_completions_test.go @@ -14,6 +14,7 @@ import ( "net/http" "os" "testing" + "time" "github.com/Azure/azure-sdk-for-go/sdk/ai/azopenai" "github.com/Azure/azure-sdk-for-go/sdk/azcore" @@ -229,7 +230,7 @@ func TestClient_GetChatCompletionsStream_Error(t *testing.T) { }) } -func TestClient_OpenAI_GetChatCompletions_Vision(t *testing.T) { +func TestClient_GetChatCompletions_Vision(t *testing.T) { testFn := func(t *testing.T, chatClient *azopenai.Client, deploymentName string) { imageURL := "https://www.bing.com/th?id=OHR.BradgateFallow_EN-US3932725763_1920x1080.jpg" @@ -244,13 +245,17 @@ func TestClient_OpenAI_GetChatCompletions_Vision(t *testing.T) { }, }) - resp, err := chatClient.GetChatCompletions(context.Background(), azopenai.ChatCompletionsOptions{ + ctx, cancel := context.WithTimeout(context.TODO(), time.Minute) + defer cancel() + + resp, err := chatClient.GetChatCompletions(ctx, azopenai.ChatCompletionsOptions{ Messages: []azopenai.ChatRequestMessageClassification{ &azopenai.ChatRequestUserMessage{ Content: content, }, }, DeploymentName: to.Ptr(deploymentName), + MaxTokens: to.Ptr[int32](512), }, nil) require.NoError(t, err) require.NotEmpty(t, resp.Choices[0].Message.Content) @@ -263,7 +268,7 @@ func TestClient_OpenAI_GetChatCompletions_Vision(t *testing.T) { testFn(t, chatClient, openAI.Vision.Model) }) - t.Run("AOAI", func(t *testing.T) { + t.Run("AzureOpenAI", func(t *testing.T) { chatClient := newTestClient(t, azureOpenAI.Vision.Endpoint) testFn(t, chatClient, azureOpenAI.Vision.Model) }) diff --git a/sdk/ai/azopenai/client_shared_test.go b/sdk/ai/azopenai/client_shared_test.go index 400ddaa01f57..597442a4a382 100644 --- a/sdk/ai/azopenai/client_shared_test.go +++ b/sdk/ai/azopenai/client_shared_test.go @@ -43,7 +43,7 @@ type testVars struct { ChatCompletions string ChatCompletionsLegacyFunctions string Embeddings string - Cognitive azopenai.AzureCognitiveSearchChatExtensionConfiguration + Cognitive azopenai.AzureSearchChatExtensionConfiguration Whisper endpointWithModel DallE endpointWithModel Vision endpointWithModel @@ -158,8 +158,8 @@ func newTestVars(prefix string) testVars { ChatCompletionsLegacyFunctions: getRequired(prefix + "_CHAT_COMPLETIONS_MODEL_LEGACY_FUNCTIONS"), Embeddings: getRequired(prefix + "_EMBEDDINGS_MODEL"), - Cognitive: azopenai.AzureCognitiveSearchChatExtensionConfiguration{ - Parameters: &azopenai.AzureCognitiveSearchChatExtensionParameters{ + Cognitive: azopenai.AzureSearchChatExtensionConfiguration{ + Parameters: &azopenai.AzureSearchChatExtensionParameters{ Endpoint: to.Ptr(getRequired("COGNITIVE_SEARCH_API_ENDPOINT")), IndexName: to.Ptr(getRequired("COGNITIVE_SEARCH_API_INDEX")), Authentication: &azopenai.OnYourDataAPIKeyAuthenticationOptions{ @@ -203,7 +203,7 @@ func initEnvVars() { azureOpenAI.Whisper = endpointWithModel{ Endpoint: azureOpenAI.Endpoint, - Model: "whisper-deployment", + Model: "whisper", } azureOpenAI.ChatCompletionsRAI = endpointWithModel{ @@ -257,8 +257,8 @@ func initEnvVars() { openAI.Embeddings = "text-embedding-ada-002" azureOpenAI.Embeddings = "text-embedding-ada-002" - azureOpenAI.Cognitive = azopenai.AzureCognitiveSearchChatExtensionConfiguration{ - Parameters: &azopenai.AzureCognitiveSearchChatExtensionParameters{ + azureOpenAI.Cognitive = azopenai.AzureSearchChatExtensionConfiguration{ + Parameters: &azopenai.AzureSearchChatExtensionParameters{ Endpoint: to.Ptr(fakeCognitiveEndpoint), IndexName: to.Ptr(fakeCognitiveIndexName), Authentication: &azopenai.OnYourDataAPIKeyAuthenticationOptions{ @@ -328,8 +328,8 @@ func newRecordingTransporter(t *testing.T) policy.Transporter { require.NoError(t, err) err = recording.AddGeneralRegexSanitizer( - fmt.Sprintf(`"indexName": "%s"`, fakeCognitiveIndexName), - fmt.Sprintf(`"indexName":\s*"%s"`, *azureOpenAI.Cognitive.Parameters.IndexName), nil) + fmt.Sprintf(`"index_name": "%s"`, fakeCognitiveIndexName), + fmt.Sprintf(`"index_name":\s*"%s"`, *azureOpenAI.Cognitive.Parameters.IndexName), nil) require.NoError(t, err) err = recording.AddGeneralRegexSanitizer( @@ -385,12 +385,12 @@ func newClientOptionsForTest(t *testing.T) *azopenai.ClientOptions { return co } -func newAzureOpenAIClientForTest(t *testing.T, tv testVars) *azopenai.Client { - return newTestClient(t, tv.Endpoint) +func newAzureOpenAIClientForTest(t *testing.T, tv testVars, options ...testClientOption) *azopenai.Client { + return newTestClient(t, tv.Endpoint, options...) } -func newOpenAIClientForTest(t *testing.T) *azopenai.Client { - return newTestClient(t, openAI.Endpoint) +func newOpenAIClientForTest(t *testing.T, options ...testClientOption) *azopenai.Client { + return newTestClient(t, openAI.Endpoint, options...) } // newBogusAzureOpenAIClient creates a client that uses an invalid key, which will cause Azure OpenAI to return diff --git a/sdk/ai/azopenai/constants.go b/sdk/ai/azopenai/constants.go index 0599b7d67761..343316b42360 100644 --- a/sdk/ai/azopenai/constants.go +++ b/sdk/ai/azopenai/constants.go @@ -92,55 +92,55 @@ func PossibleAudioTranslationFormatValues() []AudioTranslationFormat { type AzureChatExtensionType string const ( - // AzureChatExtensionTypeAzureCognitiveSearch - Represents the use of Azure Cognitive Search as an Azure OpenAI chat extension. - AzureChatExtensionTypeAzureCognitiveSearch AzureChatExtensionType = "AzureCognitiveSearch" // AzureChatExtensionTypeAzureCosmosDB - Represents the use of Azure Cosmos DB as an Azure OpenAI chat extension. - AzureChatExtensionTypeAzureCosmosDB AzureChatExtensionType = "AzureCosmosDB" + AzureChatExtensionTypeAzureCosmosDB AzureChatExtensionType = "azure_cosmos_db" // AzureChatExtensionTypeAzureMachineLearningIndex - Represents the use of Azure Machine Learning index as an Azure OpenAI // chat extension. - AzureChatExtensionTypeAzureMachineLearningIndex AzureChatExtensionType = "AzureMLIndex" + AzureChatExtensionTypeAzureMachineLearningIndex AzureChatExtensionType = "azure_ml_index" + // AzureChatExtensionTypeAzureSearch - Represents the use of Azure AI Search as an Azure OpenAI chat extension. + AzureChatExtensionTypeAzureSearch AzureChatExtensionType = "azure_search" // AzureChatExtensionTypeElasticsearch - Represents the use of Elasticsearch® index as an Azure OpenAI chat extension. - AzureChatExtensionTypeElasticsearch AzureChatExtensionType = "Elasticsearch" + AzureChatExtensionTypeElasticsearch AzureChatExtensionType = "elasticsearch" // AzureChatExtensionTypePinecone - Represents the use of Pinecone index as an Azure OpenAI chat extension. - AzureChatExtensionTypePinecone AzureChatExtensionType = "Pinecone" + AzureChatExtensionTypePinecone AzureChatExtensionType = "pinecone" ) // PossibleAzureChatExtensionTypeValues returns the possible values for the AzureChatExtensionType const type. func PossibleAzureChatExtensionTypeValues() []AzureChatExtensionType { return []AzureChatExtensionType{ - AzureChatExtensionTypeAzureCognitiveSearch, AzureChatExtensionTypeAzureCosmosDB, AzureChatExtensionTypeAzureMachineLearningIndex, + AzureChatExtensionTypeAzureSearch, AzureChatExtensionTypeElasticsearch, AzureChatExtensionTypePinecone, } } -// AzureCognitiveSearchQueryType - The type of Azure Cognitive Search retrieval query that should be executed when using it -// as an Azure OpenAI chat extension. -type AzureCognitiveSearchQueryType string +// AzureSearchQueryType - The type of Azure Search retrieval query that should be executed when using it as an Azure OpenAI +// chat extension. +type AzureSearchQueryType string const ( - // AzureCognitiveSearchQueryTypeSemantic - Represents the semantic query parser for advanced semantic modeling. - AzureCognitiveSearchQueryTypeSemantic AzureCognitiveSearchQueryType = "semantic" - // AzureCognitiveSearchQueryTypeSimple - Represents the default, simple query parser. - AzureCognitiveSearchQueryTypeSimple AzureCognitiveSearchQueryType = "simple" - // AzureCognitiveSearchQueryTypeVector - Represents vector search over computed data. - AzureCognitiveSearchQueryTypeVector AzureCognitiveSearchQueryType = "vector" - // AzureCognitiveSearchQueryTypeVectorSemanticHybrid - Represents a combination of semantic search and vector data querying. - AzureCognitiveSearchQueryTypeVectorSemanticHybrid AzureCognitiveSearchQueryType = "vectorSemanticHybrid" - // AzureCognitiveSearchQueryTypeVectorSimpleHybrid - Represents a combination of the simple query strategy with vector data. - AzureCognitiveSearchQueryTypeVectorSimpleHybrid AzureCognitiveSearchQueryType = "vectorSimpleHybrid" + // AzureSearchQueryTypeSemantic - Represents the semantic query parser for advanced semantic modeling. + AzureSearchQueryTypeSemantic AzureSearchQueryType = "semantic" + // AzureSearchQueryTypeSimple - Represents the default, simple query parser. + AzureSearchQueryTypeSimple AzureSearchQueryType = "simple" + // AzureSearchQueryTypeVector - Represents vector search over computed data. + AzureSearchQueryTypeVector AzureSearchQueryType = "vector" + // AzureSearchQueryTypeVectorSemanticHybrid - Represents a combination of semantic search and vector data querying. + AzureSearchQueryTypeVectorSemanticHybrid AzureSearchQueryType = "vector_semantic_hybrid" + // AzureSearchQueryTypeVectorSimpleHybrid - Represents a combination of the simple query strategy with vector data. + AzureSearchQueryTypeVectorSimpleHybrid AzureSearchQueryType = "vector_simple_hybrid" ) -// PossibleAzureCognitiveSearchQueryTypeValues returns the possible values for the AzureCognitiveSearchQueryType const type. -func PossibleAzureCognitiveSearchQueryTypeValues() []AzureCognitiveSearchQueryType { - return []AzureCognitiveSearchQueryType{ - AzureCognitiveSearchQueryTypeSemantic, - AzureCognitiveSearchQueryTypeSimple, - AzureCognitiveSearchQueryTypeVector, - AzureCognitiveSearchQueryTypeVectorSemanticHybrid, - AzureCognitiveSearchQueryTypeVectorSimpleHybrid, +// PossibleAzureSearchQueryTypeValues returns the possible values for the AzureSearchQueryType const type. +func PossibleAzureSearchQueryTypeValues() []AzureSearchQueryType { + return []AzureSearchQueryType{ + AzureSearchQueryTypeSemantic, + AzureSearchQueryTypeSimple, + AzureSearchQueryTypeVector, + AzureSearchQueryTypeVectorSemanticHybrid, + AzureSearchQueryTypeVectorSimpleHybrid, } } @@ -181,6 +181,55 @@ func PossibleChatCompletionRequestMessageContentPartTypeValues() []ChatCompletio } } +// ChatCompletionsToolSelectionPreset - Represents a generic policy for how a chat completions tool may be selected. +type ChatCompletionsToolSelectionPreset string + +const ( + // ChatCompletionsToolSelectionPresetAuto - Specifies that the model may either use any of the tools provided in this chat + // completions request or + // instead return a standard chat completions response as if no tools were provided. + ChatCompletionsToolSelectionPresetAuto ChatCompletionsToolSelectionPreset = "auto" + // ChatCompletionsToolSelectionPresetNone - Specifies that the model should not respond with a tool call and should instead + // provide a standard chat + // completions response. Response content may still be influenced by the provided tool definitions. + ChatCompletionsToolSelectionPresetNone ChatCompletionsToolSelectionPreset = "none" +) + +// PossibleChatCompletionsToolSelectionPresetValues returns the possible values for the ChatCompletionsToolSelectionPreset const type. +func PossibleChatCompletionsToolSelectionPresetValues() []ChatCompletionsToolSelectionPreset { + return []ChatCompletionsToolSelectionPreset{ + ChatCompletionsToolSelectionPresetAuto, + ChatCompletionsToolSelectionPresetNone, + } +} + +// ChatMessageImageDetailLevel - A representation of the possible image detail levels for image-based chat completions message +// content. +type ChatMessageImageDetailLevel string + +const ( + // ChatMessageImageDetailLevelAuto - Specifies that the model should determine which detail level to apply using heuristics + // like image size. + ChatMessageImageDetailLevelAuto ChatMessageImageDetailLevel = "auto" + // ChatMessageImageDetailLevelHigh - Specifies that image evaluation should enable the 'high-res' model that may be more accurate + // for highly detailed + // images but may also be slower and consume more tokens. + ChatMessageImageDetailLevelHigh ChatMessageImageDetailLevel = "high" + // ChatMessageImageDetailLevelLow - Specifies that image evaluation should be constrained to the 'low-res' model that may + // be faster and consume fewer + // tokens but may also be less accurate for highly detailed images. + ChatMessageImageDetailLevelLow ChatMessageImageDetailLevel = "low" +) + +// PossibleChatMessageImageDetailLevelValues returns the possible values for the ChatMessageImageDetailLevel const type. +func PossibleChatMessageImageDetailLevelValues() []ChatMessageImageDetailLevel { + return []ChatMessageImageDetailLevel{ + ChatMessageImageDetailLevelAuto, + ChatMessageImageDetailLevelHigh, + ChatMessageImageDetailLevelLow, + } +} + // ChatRole - A description of the intended purpose of a message within a chat completions interaction. type ChatRole string @@ -289,8 +338,30 @@ func PossibleElasticsearchQueryTypeValues() []ElasticsearchQueryType { } } -// ImageGenerationQuality - An image generation configuration that specifies how the model should prioritize quality, cost, -// and speed. Only configurable with dall-e-3 models. +// FunctionCallPreset - The collection of predefined behaviors for handling request-provided function information in a chat +// completions operation. +type FunctionCallPreset string + +const ( + // FunctionCallPresetAuto - Specifies that the model may either use any of the functions provided in this chat completions + // request or + // instead return a standard chat completions response as if no functions were provided. + FunctionCallPresetAuto FunctionCallPreset = "auto" + // FunctionCallPresetNone - Specifies that the model should not respond with a function call and should instead provide a + // standard chat + // completions response. Response content may still be influenced by the provided function information. + FunctionCallPresetNone FunctionCallPreset = "none" +) + +// PossibleFunctionCallPresetValues returns the possible values for the FunctionCallPreset const type. +func PossibleFunctionCallPresetValues() []FunctionCallPreset { + return []FunctionCallPreset{ + FunctionCallPresetAuto, + FunctionCallPresetNone, + } +} + +// ImageGenerationQuality - The desired image generation quality level to use. Only configurable with dall-e-3 models. type ImageGenerationQuality string const ( @@ -309,7 +380,7 @@ func PossibleImageGenerationQualityValues() []ImageGenerationQuality { } } -// ImageGenerationResponseFormat - The format in which the generated images are returned. +// ImageGenerationResponseFormat - The format in which image generation response items should be presented. type ImageGenerationResponseFormat string const ( @@ -327,8 +398,7 @@ func PossibleImageGenerationResponseFormatValues() []ImageGenerationResponseForm } } -// ImageGenerationStyle - An image generation configuration that specifies how the model should incorporate realism and other -// visual characteristics. Only configurable with dall-e-3 models. +// ImageGenerationStyle - The desired image generation style to use. Only configurable with dall-e-3 models. type ImageGenerationStyle string const ( @@ -348,7 +418,8 @@ func PossibleImageGenerationStyleValues() []ImageGenerationStyle { } } -// ImageSize - The desired size of generated images. +// ImageSize - The desired dimensions for generated images. Dall-e-2 models support 256x256, 512x512, or 1024x1024. Dall-e-3 +// models support 1024x1024, 1792x1024, or 1024x1792. type ImageSize string const ( @@ -385,22 +456,28 @@ type OnYourDataAuthenticationType string const ( // OnYourDataAuthenticationTypeAPIKey - Authentication via API key. - OnYourDataAuthenticationTypeAPIKey OnYourDataAuthenticationType = "APIKey" + OnYourDataAuthenticationTypeAPIKey OnYourDataAuthenticationType = "api_key" + // OnYourDataAuthenticationTypeAccessToken - Authentication via access token. + OnYourDataAuthenticationTypeAccessToken OnYourDataAuthenticationType = "access_token" // OnYourDataAuthenticationTypeConnectionString - Authentication via connection string. - OnYourDataAuthenticationTypeConnectionString OnYourDataAuthenticationType = "ConnectionString" + OnYourDataAuthenticationTypeConnectionString OnYourDataAuthenticationType = "connection_string" + // OnYourDataAuthenticationTypeEncodedAPIKey - Authentication via encoded API key. + OnYourDataAuthenticationTypeEncodedAPIKey OnYourDataAuthenticationType = "encoded_api_key" // OnYourDataAuthenticationTypeKeyAndKeyID - Authentication via key and key ID pair. - OnYourDataAuthenticationTypeKeyAndKeyID OnYourDataAuthenticationType = "KeyAndKeyId" + OnYourDataAuthenticationTypeKeyAndKeyID OnYourDataAuthenticationType = "key_and_key_id" // OnYourDataAuthenticationTypeSystemAssignedManagedIdentity - Authentication via system-assigned managed identity. - OnYourDataAuthenticationTypeSystemAssignedManagedIdentity OnYourDataAuthenticationType = "SystemAssignedManagedIdentity" + OnYourDataAuthenticationTypeSystemAssignedManagedIdentity OnYourDataAuthenticationType = "system_assigned_managed_identity" // OnYourDataAuthenticationTypeUserAssignedManagedIdentity - Authentication via user-assigned managed identity. - OnYourDataAuthenticationTypeUserAssignedManagedIdentity OnYourDataAuthenticationType = "UserAssignedManagedIdentity" + OnYourDataAuthenticationTypeUserAssignedManagedIdentity OnYourDataAuthenticationType = "user_assigned_managed_identity" ) // PossibleOnYourDataAuthenticationTypeValues returns the possible values for the OnYourDataAuthenticationType const type. func PossibleOnYourDataAuthenticationTypeValues() []OnYourDataAuthenticationType { return []OnYourDataAuthenticationType{ OnYourDataAuthenticationTypeAPIKey, + OnYourDataAuthenticationTypeAccessToken, OnYourDataAuthenticationTypeConnectionString, + OnYourDataAuthenticationTypeEncodedAPIKey, OnYourDataAuthenticationTypeKeyAndKeyID, OnYourDataAuthenticationTypeSystemAssignedManagedIdentity, OnYourDataAuthenticationTypeUserAssignedManagedIdentity, @@ -416,13 +493,13 @@ const ( // must be in the same Azure OpenAI resource, but // On Your Data will use this model deployment via an internal call rather than a public one, which enables vector // search even in private networks. - OnYourDataVectorizationSourceTypeDeploymentName OnYourDataVectorizationSourceType = "DeploymentName" + OnYourDataVectorizationSourceTypeDeploymentName OnYourDataVectorizationSourceType = "deployment_name" // OnYourDataVectorizationSourceTypeEndpoint - Represents vectorization performed by public service calls to an Azure OpenAI // embedding model. - OnYourDataVectorizationSourceTypeEndpoint OnYourDataVectorizationSourceType = "Endpoint" + OnYourDataVectorizationSourceTypeEndpoint OnYourDataVectorizationSourceType = "endpoint" // OnYourDataVectorizationSourceTypeModelID - Represents a specific embedding model ID as defined in the search service. // Currently only supported by Elasticsearch®. - OnYourDataVectorizationSourceTypeModelID OnYourDataVectorizationSourceType = "ModelId" + OnYourDataVectorizationSourceTypeModelID OnYourDataVectorizationSourceType = "model_id" ) // PossibleOnYourDataVectorizationSourceTypeValues returns the possible values for the OnYourDataVectorizationSourceType const type. @@ -433,3 +510,60 @@ func PossibleOnYourDataVectorizationSourceTypeValues() []OnYourDataVectorization OnYourDataVectorizationSourceTypeModelID, } } + +// SpeechGenerationResponseFormat - The audio output format for the spoken text. By default, the MP3 format will be used. +type SpeechGenerationResponseFormat string + +const ( + // SpeechGenerationResponseFormatAac - Use AAC as the audio output format. AAC is optimized for digital audio compression + // and is preferred by YouTube, Android, and iOS. + SpeechGenerationResponseFormatAac SpeechGenerationResponseFormat = "aac" + // SpeechGenerationResponseFormatFlac - Use FLAC as the audio output format. FLAC is a fully lossless format optimized for + // maximum quality at the expense of size. + SpeechGenerationResponseFormatFlac SpeechGenerationResponseFormat = "flac" + // SpeechGenerationResponseFormatMp3 - Use MP3 as the audio output format. MP3 is the default, general-purpose format. + SpeechGenerationResponseFormatMp3 SpeechGenerationResponseFormat = "mp3" + // SpeechGenerationResponseFormatOpus - Use Opus as the audio output format. Opus is optimized for internet streaming and + // low latency. + SpeechGenerationResponseFormatOpus SpeechGenerationResponseFormat = "opus" +) + +// PossibleSpeechGenerationResponseFormatValues returns the possible values for the SpeechGenerationResponseFormat const type. +func PossibleSpeechGenerationResponseFormatValues() []SpeechGenerationResponseFormat { + return []SpeechGenerationResponseFormat{ + SpeechGenerationResponseFormatAac, + SpeechGenerationResponseFormatFlac, + SpeechGenerationResponseFormatMp3, + SpeechGenerationResponseFormatOpus, + } +} + +// SpeechVoice - The available voices for text-to-speech. +type SpeechVoice string + +const ( + // SpeechVoiceAlloy - The Alloy voice. + SpeechVoiceAlloy SpeechVoice = "alloy" + // SpeechVoiceEcho - The Echo voice. + SpeechVoiceEcho SpeechVoice = "echo" + // SpeechVoiceFable - The Fable voice. + SpeechVoiceFable SpeechVoice = "fable" + // SpeechVoiceNova - The Nova voice. + SpeechVoiceNova SpeechVoice = "nova" + // SpeechVoiceOnyx - The Onyx voice. + SpeechVoiceOnyx SpeechVoice = "onyx" + // SpeechVoiceShimmer - The Shimmer voice. + SpeechVoiceShimmer SpeechVoice = "shimmer" +) + +// PossibleSpeechVoiceValues returns the possible values for the SpeechVoice const type. +func PossibleSpeechVoiceValues() []SpeechVoice { + return []SpeechVoice{ + SpeechVoiceAlloy, + SpeechVoiceEcho, + SpeechVoiceFable, + SpeechVoiceNova, + SpeechVoiceOnyx, + SpeechVoiceShimmer, + } +} diff --git a/sdk/ai/azopenai/custom_client.go b/sdk/ai/azopenai/custom_client.go index 286bc171cedf..f251cedf39c3 100644 --- a/sdk/ai/azopenai/custom_client.go +++ b/sdk/ai/azopenai/custom_client.go @@ -192,14 +192,7 @@ func (client *Client) GetCompletionsStream(ctx context.Context, body Completions // If the operation fails it returns an *azcore.ResponseError type. // - options - GetCompletionsOptions contains the optional parameters for the Client.GetCompletions method. func (client *Client) GetChatCompletionsStream(ctx context.Context, body ChatCompletionsOptions, options *GetChatCompletionsStreamOptions) (GetChatCompletionsStreamResponse, error) { - var req *policy.Request - var err error - - if hasAzureExtensions(body) { - req, err = client.getChatCompletionsWithAzureExtensionsCreateRequest(ctx, body, &GetChatCompletionsWithAzureExtensionsOptions{}) - } else { - req, err = client.getChatCompletionsCreateRequest(ctx, body, &GetChatCompletionsOptions{}) - } + req, err := client.getChatCompletionsCreateRequest(ctx, body, &GetChatCompletionsOptions{}) if err != nil { return GetChatCompletionsStreamResponse{}, err @@ -229,24 +222,6 @@ func (client *Client) GetChatCompletionsStream(ctx context.Context, body ChatCom }, nil } -// GetChatCompletions - Gets chat completions for the provided chat messages. Completions support a wide variety of tasks -// and generate text that continues from or "completes" provided prompt data. -// If the operation fails it returns an *azcore.ResponseError type. -func (client *Client) GetChatCompletions(ctx context.Context, body ChatCompletionsOptions, options *GetChatCompletionsOptions) (GetChatCompletionsResponse, error) { - if hasAzureExtensions(body) { - resp, err := client.getChatCompletionsWithAzureExtensions(ctx, body, nil) - - // convert - if err != nil { - return GetChatCompletionsResponse{}, err - } - - return GetChatCompletionsResponse(resp), nil - } else { - return client.getChatCompletions(ctx, body, nil) - } -} - func (client *Client) formatURL(path string, deploymentID string) string { switch path { // https://learn.microsoft.com/en-us/azure/cognitive-services/openai/reference#image-generation @@ -271,10 +246,12 @@ type clientData struct { azure bool } -func getDeployment[T AudioTranscriptionOptions | AudioTranslationOptions | ChatCompletionsOptions | CompletionsOptions | EmbeddingsOptions | *getAudioTranscriptionInternalOptions | *getAudioTranslationInternalOptions | ImageGenerationOptions](v T) string { +func getDeployment[T SpeechGenerationOptions | AudioTranscriptionOptions | AudioTranslationOptions | ChatCompletionsOptions | CompletionsOptions | EmbeddingsOptions | *getAudioTranscriptionInternalOptions | *getAudioTranslationInternalOptions | ImageGenerationOptions](v T) string { var p *string switch a := any(v).(type) { + case SpeechGenerationOptions: + p = a.DeploymentName case AudioTranscriptionOptions: p = a.DeploymentName case AudioTranslationOptions: @@ -286,9 +263,9 @@ func getDeployment[T AudioTranscriptionOptions | AudioTranslationOptions | ChatC case EmbeddingsOptions: p = a.DeploymentName case *getAudioTranscriptionInternalOptions: - p = a.Model + p = a.DeploymentName case *getAudioTranslationInternalOptions: - p = a.Model + p = a.DeploymentName case ImageGenerationOptions: p = a.DeploymentName } @@ -300,10 +277,6 @@ func getDeployment[T AudioTranscriptionOptions | AudioTranslationOptions | ChatC return "" } -func hasAzureExtensions(body ChatCompletionsOptions) bool { - return body.AzureExtensionsOptions != nil && len(body.AzureExtensionsOptions) > 0 -} - // ChatRequestUserMessageContent contains the user prompt - either as a single string // or as a []ChatCompletionRequestMessageContentPart, enabling images and text as input. // diff --git a/sdk/ai/azopenai/custom_client_audio.go b/sdk/ai/azopenai/custom_client_audio.go index d9ce56f5177d..558eaec72787 100644 --- a/sdk/ai/azopenai/custom_client_audio.go +++ b/sdk/ai/azopenai/custom_client_audio.go @@ -41,12 +41,10 @@ type GetAudioTranscriptionResponse struct { // - body - contains parameters to specify audio data to transcribe and control the transcription. // - options - optional parameters for this method. func (client *Client) GetAudioTranscription(ctx context.Context, body AudioTranscriptionOptions, options *GetAudioTranscriptionOptions) (GetAudioTranscriptionResponse, error) { - audioStream := streaming.NopCloser(bytes.NewReader(body.File)) - - resp, err := client.getAudioTranscriptionInternal(ctx, getDeployment(body), audioStream, &getAudioTranscriptionInternalOptions{ + resp, err := client.getAudioTranscriptionInternal(ctx, streaming.NopCloser(bytes.NewReader(body.File)), &getAudioTranscriptionInternalOptions{ Filename: body.Filename, Language: body.Language, - Model: body.DeploymentName, + DeploymentName: body.DeploymentName, Prompt: body.Prompt, ResponseFormat: body.ResponseFormat, Temperature: body.Temperature, @@ -77,11 +75,9 @@ type GetAudioTranslationResponse struct { // - body - contains parameters to specify audio data to translate and control the translation. // - options - optional parameters for this method. func (client *Client) GetAudioTranslation(ctx context.Context, body AudioTranslationOptions, options *GetAudioTranslationOptions) (GetAudioTranslationResponse, error) { - audioStream := streaming.NopCloser(bytes.NewReader(body.File)) - - resp, err := client.getAudioTranslationInternal(ctx, getDeployment(body), audioStream, &getAudioTranslationInternalOptions{ + resp, err := client.getAudioTranslationInternal(ctx, streaming.NopCloser(bytes.NewReader(body.File)), &getAudioTranslationInternalOptions{ Filename: body.Filename, - Model: body.DeploymentName, + DeploymentName: body.DeploymentName, Prompt: body.Prompt, ResponseFormat: body.ResponseFormat, Temperature: body.Temperature, @@ -98,13 +94,17 @@ func setMultipartFormData[T getAudioTranscriptionInternalOptions | getAudioTrans body := bytes.Buffer{} writer := multipart.NewWriter(&body) - writeContent := func(fieldname, filename string, content io.ReadSeekCloser) error { + writeContent := func(fieldname, filename string, file io.ReadSeekCloser) error { fd, err := writer.CreateFormFile(fieldname, filename) + if err != nil { return err } - _, err = io.Copy(fd, file) + if _, err := io.Copy(fd, file); err != nil { + return err + } + return err } @@ -127,7 +127,7 @@ func setMultipartFormData[T getAudioTranscriptionInternalOptions | getAudioTrans switch v := any(options).(type) { case getAudioTranslationInternalOptions: - if err := writeField(writer, "model", v.Model); err != nil { + if err := writeField(writer, "model", v.DeploymentName); err != nil { return err } if err := writeField(writer, "prompt", v.Prompt); err != nil { @@ -143,7 +143,7 @@ func setMultipartFormData[T getAudioTranscriptionInternalOptions | getAudioTrans if err := writeField(writer, "language", v.Language); err != nil { return err } - if err := writeField(writer, "model", v.Model); err != nil { + if err := writeField(writer, "model", v.DeploymentName); err != nil { return err } if err := writeField(writer, "prompt", v.Prompt); err != nil { diff --git a/sdk/ai/azopenai/custom_models.go b/sdk/ai/azopenai/custom_models.go index 4366965b39df..57c2e71d2361 100644 --- a/sdk/ai/azopenai/custom_models.go +++ b/sdk/ai/azopenai/custom_models.go @@ -173,11 +173,8 @@ func (tf ChatCompletionsToolChoiceFunction) MarshalJSON() ([]byte, error) { } return json.Marshal(jsonFormat{ - Type: "function", - //nolint:gosimple,can't use the ChatCompletionsToolChoiceFunction here or marshalling will be circular! - Function: jsonInnerFunc{ - Name: tf.Name, - }, + Type: "function", + Function: jsonInnerFunc(tf), }) } diff --git a/sdk/ai/azopenai/example_client_audio_test.go b/sdk/ai/azopenai/example_client_audio_test.go index 94b11291fe55..b46e873e0e39 100644 --- a/sdk/ai/azopenai/example_client_audio_test.go +++ b/sdk/ai/azopenai/example_client_audio_test.go @@ -9,6 +9,7 @@ package azopenai_test import ( "context" "fmt" + "io" "log" "os" @@ -65,3 +66,51 @@ func ExampleClient_GetAudioTranscription() { // Output: } + +func ExampleClient_GenerateSpeechFromText() { + openAIKey := os.Getenv("OPENAI_API_KEY") + + // Ex: "https://api.openai.com/v1" + openAIEndpoint := os.Getenv("OPENAI_ENDPOINT") + + modelDeploymentID := "tts-1" + + if openAIKey == "" || openAIEndpoint == "" || modelDeploymentID == "" { + fmt.Fprintf(os.Stderr, "Skipping example, environment variables missing\n") + return + } + + keyCredential := azcore.NewKeyCredential(openAIKey) + + client, err := azopenai.NewClientForOpenAI(openAIEndpoint, keyCredential, nil) + + if err != nil { + // TODO: Update the following line with your application specific error handling logic + log.Fatalf("ERROR: %s", err) + } + + audioResp, err := client.GenerateSpeechFromText(context.Background(), azopenai.SpeechGenerationOptions{ + Input: to.Ptr("i am a computer"), + Voice: to.Ptr(azopenai.SpeechVoiceAlloy), + ResponseFormat: to.Ptr(azopenai.SpeechGenerationResponseFormatFlac), + DeploymentName: to.Ptr("tts-1"), + }, nil) + + if err != nil { + // TODO: Update the following line with your application specific error handling logic + log.Fatalf("ERROR: %s", err) + } + + defer audioResp.Body.Close() + + audioBytes, err := io.ReadAll(audioResp.Body) + + if err != nil { + // TODO: Update the following line with your application specific error handling logic + log.Fatalf("ERROR: %s", err) + } + + fmt.Fprintf(os.Stderr, "Got %d bytes of FLAC audio\n", len(audioBytes)) + + // Output: +} diff --git a/sdk/ai/azopenai/example_client_getchatcompletions_extensions_test.go b/sdk/ai/azopenai/example_client_getchatcompletions_extensions_test.go index dad9520dc638..ce2425301209 100644 --- a/sdk/ai/azopenai/example_client_getchatcompletions_extensions_test.go +++ b/sdk/ai/azopenai/example_client_getchatcompletions_extensions_test.go @@ -52,7 +52,7 @@ func ExampleClient_GetChatCompletions_bringYourOwnDataWithCognitiveSearch() { }, MaxTokens: to.Ptr[int32](512), AzureExtensionsOptions: []azopenai.AzureChatExtensionConfigurationClassification{ - &azopenai.AzureCognitiveSearchChatExtensionConfiguration{ + &azopenai.AzureSearchChatExtensionConfiguration{ // This allows Azure OpenAI to use an Azure Cognitive Search index. // // > Because the model has access to, and can reference specific sources to support its responses, answers are not only based on its pretrained knowledge @@ -60,7 +60,7 @@ func ExampleClient_GetChatCompletions_bringYourOwnDataWithCognitiveSearch() { // > based on outdated or incorrect information. // // Quote from here: https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/use-your-data - Parameters: &azopenai.AzureCognitiveSearchChatExtensionParameters{ + Parameters: &azopenai.AzureSearchChatExtensionParameters{ Endpoint: &searchEndpoint, IndexName: &searchIndex, Authentication: &azopenai.OnYourDataAPIKeyAuthenticationOptions{ @@ -80,9 +80,7 @@ func ExampleClient_GetChatCompletions_bringYourOwnDataWithCognitiveSearch() { // Contains contextual information from your Azure chat completion extensions, configured above in `AzureExtensionsOptions` msgContext := resp.Choices[0].Message.Context - fmt.Fprintf(os.Stderr, "Extensions Context Role: %s\nExtensions Context (length): %d\n", - *msgContext.Messages[0].Role, - len(*msgContext.Messages[0].Content)) + fmt.Fprintf(os.Stderr, "Extensions Context (length): %d\n", len(*msgContext.Citations[0].Content)) fmt.Fprintf(os.Stderr, "ChatRole: %s\nChat content: %s\n", *resp.Choices[0].Message.Role, diff --git a/sdk/ai/azopenai/example_client_getchatcompletions_test.go b/sdk/ai/azopenai/example_client_getchatcompletions_test.go index 1df056f22e6e..2cb41ec03b70 100644 --- a/sdk/ai/azopenai/example_client_getchatcompletions_test.go +++ b/sdk/ai/azopenai/example_client_getchatcompletions_test.go @@ -252,7 +252,7 @@ func ExampleClient_GetChatCompletions_legacyFunctions() { log.Fatalf("ERROR: %s", err) } - funcCall := resp.ChatCompletions.Choices[0].Message.FunctionCall + funcCall := resp.Choices[0].Message.FunctionCall // This is the function name we gave in the call to GetCompletions // Prints: Function name: "get_current_weather" diff --git a/sdk/ai/azopenai/example_client_getchatcompletions_vision_test.go b/sdk/ai/azopenai/example_client_getchatcompletions_vision_test.go index 1596ef082bc2..3801c2817034 100644 --- a/sdk/ai/azopenai/example_client_getchatcompletions_vision_test.go +++ b/sdk/ai/azopenai/example_client_getchatcompletions_vision_test.go @@ -8,6 +8,7 @@ import ( "fmt" "log" "os" + "time" "github.com/Azure/azure-sdk-for-go/sdk/ai/azopenai" "github.com/Azure/azure-sdk-for-go/sdk/azcore" @@ -50,12 +51,16 @@ func ExampleClient_GetChatCompletions_vision() { }, }) - resp, err := client.GetChatCompletions(context.Background(), azopenai.ChatCompletionsOptions{ + ctx, cancel := context.WithTimeout(context.TODO(), time.Minute) + defer cancel() + + resp, err := client.GetChatCompletions(ctx, azopenai.ChatCompletionsOptions{ Messages: []azopenai.ChatRequestMessageClassification{ &azopenai.ChatRequestUserMessage{ Content: content, }, }, + MaxTokens: to.Ptr[int32](512), DeploymentName: to.Ptr(modelDeployment), }, nil) diff --git a/sdk/ai/azopenai/go.mod b/sdk/ai/azopenai/go.mod index c0e80b3b5dc1..ce5865a66b5d 100644 --- a/sdk/ai/azopenai/go.mod +++ b/sdk/ai/azopenai/go.mod @@ -3,9 +3,9 @@ module github.com/Azure/azure-sdk-for-go/sdk/ai/azopenai go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 - github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1 + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2 github.com/joho/godotenv v1.3.0 github.com/stretchr/testify v1.8.4 ) diff --git a/sdk/ai/azopenai/go.sum b/sdk/ai/azopenai/go.sum index 31b134c529c3..f871c7d21dcd 100644 --- a/sdk/ai/azopenai/go.sum +++ b/sdk/ai/azopenai/go.sum @@ -1,9 +1,9 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1 h1:lGlwhPtrX6EVml1hO0ivjkUxsSyl4dsiw9qcA1k/3IQ= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1/go.mod h1:RKUqNu35KJYcVG/fqTRqmuXJZYNhYkBrnC/hX7yGbTA= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 h1:c4k2FIYIh4xtwqrQwV0Ct1v5+ehlNXj5NI/MWVsiTkQ= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2/go.mod h1:5FDJtLEO/GxwNgUxbwrY3LP0pEoThTQJtk2oysdXHxM= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 h1:vcYCAze6p19qBW7MhZybIsqD8sMV8js0NyQM8JDnVtg= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0/go.mod h1:OQeznEEkTZ9OrhHJoDD8ZDq51FHgXjqtP9z6bEwBq9U= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1 h1:6oNBlSdi1QqM1PNW7FPA6xOGA5UNsXnkaYZz9vdPGhA= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2 h1:LqbJ/WzJUwBf8UiaSzgX7aMclParm9/5Vgp+TY51uBQ= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2/go.mod h1:yInRyqWXAuaPrgI7p70+lDDgh3mlBohis29jGMISnmc= github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 h1:OBhqkivkhkMqLPymWEppkm7vgPQY2XsHoEkaMQ0AdZY= github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= diff --git a/sdk/ai/azopenai/interfaces.go b/sdk/ai/azopenai/interfaces.go index 0a01f3046248..6b8b60bf8eac 100644 --- a/sdk/ai/azopenai/interfaces.go +++ b/sdk/ai/azopenai/interfaces.go @@ -11,8 +11,8 @@ package azopenai // AzureChatExtensionConfigurationClassification provides polymorphic access to related types. // Call the interface's GetAzureChatExtensionConfiguration() method to access the common type. // Use a type switch to determine the concrete type. The possible types are: -// - *AzureChatExtensionConfiguration, *AzureCognitiveSearchChatExtensionConfiguration, *AzureCosmosDBChatExtensionConfiguration, -// - *AzureMachineLearningIndexChatExtensionConfiguration, *ElasticsearchChatExtensionConfiguration, *PineconeChatExtensionConfiguration +// - *AzureChatExtensionConfiguration, *AzureCosmosDBChatExtensionConfiguration, *AzureMachineLearningIndexChatExtensionConfiguration, +// - *AzureSearchChatExtensionConfiguration, *ElasticsearchChatExtensionConfiguration, *PineconeChatExtensionConfiguration type AzureChatExtensionConfigurationClassification interface { // GetAzureChatExtensionConfiguration returns the AzureChatExtensionConfiguration content of the underlying type. GetAzureChatExtensionConfiguration() *AzureChatExtensionConfiguration @@ -27,6 +27,15 @@ type ChatCompletionRequestMessageContentPartClassification interface { GetChatCompletionRequestMessageContentPart() *ChatCompletionRequestMessageContentPart } +// ChatCompletionsNamedToolSelectionClassification provides polymorphic access to related types. +// Call the interface's GetChatCompletionsNamedToolSelection() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *ChatCompletionsNamedFunctionToolSelection, *ChatCompletionsNamedToolSelection +type ChatCompletionsNamedToolSelectionClassification interface { + // GetChatCompletionsNamedToolSelection returns the ChatCompletionsNamedToolSelection content of the underlying type. + GetChatCompletionsNamedToolSelection() *ChatCompletionsNamedToolSelection +} + // ChatCompletionsResponseFormatClassification provides polymorphic access to related types. // Call the interface's GetChatCompletionsResponseFormat() method to access the common type. // Use a type switch to determine the concrete type. The possible types are: @@ -63,10 +72,20 @@ type ChatFinishDetailsClassification interface { GetChatFinishDetails() *ChatFinishDetails } +// ChatMessageContentItemClassification provides polymorphic access to related types. +// Call the interface's GetChatMessageContentItem() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *ChatMessageContentItem, *ChatMessageImageContentItem, *ChatMessageTextContentItem +type ChatMessageContentItemClassification interface { + // GetChatMessageContentItem returns the ChatMessageContentItem content of the underlying type. + GetChatMessageContentItem() *ChatMessageContentItem +} + // ChatRequestMessageClassification provides polymorphic access to related types. // Call the interface's GetChatRequestMessage() method to access the common type. // Use a type switch to determine the concrete type. The possible types are: -// - *ChatRequestAssistantMessage, *ChatRequestMessage, *ChatRequestSystemMessage, *ChatRequestToolMessage, *ChatRequestUserMessage +// - *ChatRequestAssistantMessage, *ChatRequestFunctionMessage, *ChatRequestMessage, *ChatRequestSystemMessage, *ChatRequestToolMessage, +// - *ChatRequestUserMessage type ChatRequestMessageClassification interface { // GetChatRequestMessage returns the ChatRequestMessage content of the underlying type. GetChatRequestMessage() *ChatRequestMessage @@ -75,8 +94,9 @@ type ChatRequestMessageClassification interface { // OnYourDataAuthenticationOptionsClassification provides polymorphic access to related types. // Call the interface's GetOnYourDataAuthenticationOptions() method to access the common type. // Use a type switch to determine the concrete type. The possible types are: -// - *OnYourDataAPIKeyAuthenticationOptions, *OnYourDataAuthenticationOptions, *OnYourDataConnectionStringAuthenticationOptions, -// - *OnYourDataKeyAndKeyIDAuthenticationOptions, *OnYourDataSystemAssignedManagedIdentityAuthenticationOptions, *OnYourDataUserAssignedManagedIdentityAuthenticationOptions +// - *OnYourDataAPIKeyAuthenticationOptions, *OnYourDataAccessTokenAuthenticationOptions, *OnYourDataAuthenticationOptions, +// - *OnYourDataConnectionStringAuthenticationOptions, *OnYourDataEncodedAPIKeyAuthenticationOptions, *OnYourDataKeyAndKeyIDAuthenticationOptions, +// - *OnYourDataSystemAssignedManagedIdentityAuthenticationOptions, *OnYourDataUserAssignedManagedIdentityAuthenticationOptions type OnYourDataAuthenticationOptionsClassification interface { // GetOnYourDataAuthenticationOptions returns the OnYourDataAuthenticationOptions content of the underlying type. GetOnYourDataAuthenticationOptions() *OnYourDataAuthenticationOptions diff --git a/sdk/ai/azopenai/models.go b/sdk/ai/azopenai/models.go index ad78bb97283a..69dcc9c6de7d 100644 --- a/sdk/ai/azopenai/models.go +++ b/sdk/ai/azopenai/models.go @@ -37,9 +37,6 @@ type AudioTranscriptionOptions struct { // flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, webm. File []byte - // The model to use for this transcription request. - DeploymentName *string - // The optional filename or descriptive identifier to associate with with the audio data. Filename *string @@ -48,6 +45,9 @@ type AudioTranscriptionOptions struct { // the accuracy and/or latency of transcription. Language *string + // The model to use for this transcription request. + DeploymentName *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 @@ -124,12 +124,12 @@ type AudioTranslationOptions struct { // flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, webm. File []byte - // The model to use for this translation request. - DeploymentName *string - // The optional filename or descriptive identifier to associate with with the audio data. Filename *string + // The model to use for this translation request. + DeploymentName *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 @@ -211,15 +211,39 @@ func (a *AzureChatExtensionConfiguration) GetAzureChatExtensionConfiguration() * return a } +// AzureChatExtensionDataSourceResponseCitation - A single instance of additional context information available when Azure +// OpenAI chat extensions are involved in the generation of a corresponding chat completions response. This context information +// is +// only populated when using an Azure OpenAI request configured to use a matching extension. +type AzureChatExtensionDataSourceResponseCitation struct { + // REQUIRED; The content of the citation. + Content *string + + // The chunk ID of the citation. + ChunkID *string + + // The file path of the citation. + Filepath *string + + // The title of the citation. + Title *string + + // The URL of the citation. + URL *string +} + // AzureChatExtensionsMessageContext - A representation of the additional context information available when Azure OpenAI // chat extensions are involved in the generation of a corresponding chat completions response. This context information // is only populated when using an Azure OpenAI request configured to use a matching extension. type AzureChatExtensionsMessageContext struct { - // The contextual message payload associated with the Azure chat extensions used for a chat completions request. These messages - // describe the data source retrievals, plugin invocations, and other - // intermediate steps taken in the course of generating a chat completions response that was augmented by capabilities from - // Azure OpenAI chat extensions. - Messages []ChatResponseMessage + // The contextual information associated with the Azure chat extensions used for a chat completions request. These messages + // describe the data source retrievals, plugin invocations, and other intermediate + // steps taken in the course of generating a chat completions response that was augmented by capabilities from Azure OpenAI + // chat extensions. + Citations []AzureChatExtensionDataSourceResponseCitation + + // The detected intent from the chat history, used to pass to the next turn to carry over the context. + Intent *string } // AzureChatGroundingEnhancementConfiguration - A representation of the available options for the Azure OpenAI grounding enhancement. @@ -235,95 +259,7 @@ type AzureChatOCREnhancementConfiguration struct { Enabled *bool } -// AzureCognitiveSearchChatExtensionConfiguration - A specific representation of configurable options for Azure Cognitive -// Search when using it as an Azure OpenAI chat extension. -type AzureCognitiveSearchChatExtensionConfiguration struct { - // REQUIRED; The label for the type of an Azure chat extension. This typically corresponds to a matching Azure resource. Azure - // chat extensions are only compatible with Azure OpenAI. - configType *AzureChatExtensionType - - // REQUIRED; The parameters to use when configuring Azure Cognitive Search. - Parameters *AzureCognitiveSearchChatExtensionParameters -} - -// GetAzureChatExtensionConfiguration implements the AzureChatExtensionConfigurationClassification interface for type AzureCognitiveSearchChatExtensionConfiguration. -func (a *AzureCognitiveSearchChatExtensionConfiguration) GetAzureChatExtensionConfiguration() *AzureChatExtensionConfiguration { - return &AzureChatExtensionConfiguration{ - configType: a.configType, - } -} - -// AzureCognitiveSearchChatExtensionParameters - Parameters for Azure Cognitive Search when used as an Azure OpenAI chat extension. -type AzureCognitiveSearchChatExtensionParameters struct { - // REQUIRED; The absolute endpoint path for the Azure Cognitive Search resource to use. - Endpoint *string - - // REQUIRED; The name of the index to use as available in the referenced Azure Cognitive Search resource. - IndexName *string - - // The authentication method to use when accessing the defined data source. Each data source type supports a specific set - // of available authentication methods; please see the documentation of the data - // source for supported mechanisms. If not otherwise provided, On Your Data will attempt to use System Managed Identity (default - // credential) authentication. - Authentication OnYourDataAuthenticationOptionsClassification - - // The embedding dependency for vector search. - EmbeddingDependency OnYourDataVectorizationSourceClassification - - // Customized field mapping behavior to use when interacting with the search index. - FieldsMapping *AzureCognitiveSearchIndexFieldMappingOptions - - // Search filter. - Filter *string - - // Whether queries should be restricted to use of indexed data. - InScope *bool - - // The query type to use with Azure Cognitive Search. - QueryType *AzureCognitiveSearchQueryType - - // Give the model instructions about how it should behave and any context it should reference when generating a response. - // You can describe the assistant's personality and tell it how to format responses. - // There's a 100 token limit for it, and it counts against the overall token limit. - RoleInformation *string - - // The additional semantic configuration for the query. - SemanticConfiguration *string - - // The configured strictness of the search relevance filtering. The higher of strictness, the higher of the precision but - // lower recall of the answer. - Strictness *int32 - - // The configured top number of documents to feature for the configured query. - TopNDocuments *int32 -} - -// AzureCognitiveSearchIndexFieldMappingOptions - Optional settings to control how fields are processed when using a configured -// Azure Cognitive Search resource. -type AzureCognitiveSearchIndexFieldMappingOptions struct { - // The names of index fields that should be treated as content. - ContentFields []string - - // The separator pattern that content fields should use. - ContentFieldsSeparator *string - - // The name of the index field to use as a filepath. - FilepathField *string - - // The names of fields that represent image vector data. - ImageVectorFields []string - - // The name of the index field to use as a title. - TitleField *string - - // The name of the index field to use as a URL. - URLField *string - - // The names of fields that represent vector data. - VectorFields []string -} - -// AzureCosmosDBChatExtensionConfiguration - A specific representation of configurable options for Elasticsearch when using +// AzureCosmosDBChatExtensionConfiguration - A specific representation of configurable options for Azure Cosmos DB when using // it as an Azure OpenAI chat extension. type AzureCosmosDBChatExtensionConfiguration struct { // REQUIRED; The label for the type of an Azure chat extension. This typically corresponds to a matching Azure resource. Azure @@ -342,7 +278,7 @@ func (a *AzureCosmosDBChatExtensionConfiguration) GetAzureChatExtensionConfigura } // AzureCosmosDBChatExtensionParameters - Parameters to use when configuring Azure OpenAI On Your Data chat extensions when -// using Azure Cosmos DB for MongoDB vCore. +// using Azure Cosmos DB for MongoDB vCore. The supported authentication type is ConnectionString. type AzureCosmosDBChatExtensionParameters struct { // REQUIRED; The name of the Azure Cosmos DB resource container. ContainerName *string @@ -350,6 +286,9 @@ type AzureCosmosDBChatExtensionParameters struct { // REQUIRED; The MongoDB vCore database name to use with Azure Cosmos DB. DatabaseName *string + // REQUIRED; The embedding dependency for vector search. + EmbeddingDependency OnYourDataVectorizationSourceClassification + // REQUIRED; Customized field mapping behavior to use when interacting with the search index. FieldsMapping *AzureCosmosDBFieldMappingOptions @@ -362,9 +301,6 @@ type AzureCosmosDBChatExtensionParameters struct { // credential) authentication. Authentication OnYourDataAuthenticationOptionsClassification - // The embedding dependency for vector search. - EmbeddingDependency OnYourDataVectorizationSourceClassification - // Whether queries should be restricted to use of indexed data. InScope *bool @@ -384,8 +320,23 @@ type AzureCosmosDBChatExtensionParameters struct { // AzureCosmosDBFieldMappingOptions - Optional settings to control how fields are processed when using a configured Azure // Cosmos DB resource. type AzureCosmosDBFieldMappingOptions struct { + // REQUIRED; The names of index fields that should be treated as content. + ContentFields []string + // REQUIRED; The names of fields that represent vector data. VectorFields []string + + // The separator pattern that content fields should use. + ContentFieldsSeparator *string + + // The name of the index field to use as a filepath. + FilepathField *string + + // The name of the index field to use as a title. + TitleField *string + + // The name of the index field to use as a URL. + URLField *string } // AzureGroundingEnhancement - The grounding enhancement that returns the bounding box of the objects detected in the image. @@ -448,6 +399,7 @@ func (a *AzureMachineLearningIndexChatExtensionConfiguration) GetAzureChatExtens } // AzureMachineLearningIndexChatExtensionParameters - Parameters for the Azure Machine Learning vector index chat extension. +// The supported authentication types are AccessToken, SystemAssignedManagedIdentity and UserAssignedManagedIdentity. type AzureMachineLearningIndexChatExtensionParameters struct { // REQUIRED; The Azure Machine Learning vector index name. Name *string @@ -483,6 +435,95 @@ type AzureMachineLearningIndexChatExtensionParameters struct { TopNDocuments *int32 } +// AzureSearchChatExtensionConfiguration - A specific representation of configurable options for Azure Search when using it +// as an Azure OpenAI chat extension. +type AzureSearchChatExtensionConfiguration struct { + // REQUIRED; The label for the type of an Azure chat extension. This typically corresponds to a matching Azure resource. Azure + // chat extensions are only compatible with Azure OpenAI. + configType *AzureChatExtensionType + + // REQUIRED; The parameters to use when configuring Azure Search. + Parameters *AzureSearchChatExtensionParameters +} + +// GetAzureChatExtensionConfiguration implements the AzureChatExtensionConfigurationClassification interface for type AzureSearchChatExtensionConfiguration. +func (a *AzureSearchChatExtensionConfiguration) GetAzureChatExtensionConfiguration() *AzureChatExtensionConfiguration { + return &AzureChatExtensionConfiguration{ + configType: a.configType, + } +} + +// AzureSearchChatExtensionParameters - Parameters for Azure Cognitive Search when used as an Azure OpenAI chat extension. +// The supported authentication types are APIKey, SystemAssignedManagedIdentity and UserAssignedManagedIdentity. +type AzureSearchChatExtensionParameters struct { + // REQUIRED; The absolute endpoint path for the Azure Cognitive Search resource to use. + Endpoint *string + + // REQUIRED; The name of the index to use as available in the referenced Azure Cognitive Search resource. + IndexName *string + + // The authentication method to use when accessing the defined data source. Each data source type supports a specific set + // of available authentication methods; please see the documentation of the data + // source for supported mechanisms. If not otherwise provided, On Your Data will attempt to use System Managed Identity (default + // credential) authentication. + Authentication OnYourDataAuthenticationOptionsClassification + + // The embedding dependency for vector search. + EmbeddingDependency OnYourDataVectorizationSourceClassification + + // Customized field mapping behavior to use when interacting with the search index. + FieldsMapping *AzureSearchIndexFieldMappingOptions + + // Search filter. + Filter *string + + // Whether queries should be restricted to use of indexed data. + InScope *bool + + // The query type to use with Azure Cognitive Search. + QueryType *AzureSearchQueryType + + // Give the model instructions about how it should behave and any context it should reference when generating a response. + // You can describe the assistant's personality and tell it how to format responses. + // There's a 100 token limit for it, and it counts against the overall token limit. + RoleInformation *string + + // The additional semantic configuration for the query. + SemanticConfiguration *string + + // The configured strictness of the search relevance filtering. The higher of strictness, the higher of the precision but + // lower recall of the answer. + Strictness *int32 + + // The configured top number of documents to feature for the configured query. + TopNDocuments *int32 +} + +// AzureSearchIndexFieldMappingOptions - Optional settings to control how fields are processed when using a configured Azure +// Search resource. +type AzureSearchIndexFieldMappingOptions struct { + // The names of index fields that should be treated as content. + ContentFields []string + + // The separator pattern that content fields should use. + ContentFieldsSeparator *string + + // The name of the index field to use as a filepath. + FilepathField *string + + // The names of fields that represent image vector data. + ImageVectorFields []string + + // The name of the index field to use as a title. + TitleField *string + + // The name of the index field to use as a URL. + URLField *string + + // The names of fields that represent vector data. + VectorFields []string +} + // ChatChoice - The representation of a single prompt completion as part of an overall chat completions request. Generally, // n choices are generated per provided prompt with a default value of 1. Token limits and // other settings may limit the number of choices generated. @@ -493,6 +534,9 @@ type ChatChoice struct { // REQUIRED; The ordered index associated with this chat completions choice. Index *int32 + // REQUIRED; The log probability information for this choice, as enabled via the 'logprobs' request option. + LogProbs *ChatChoiceLogProbs + // Information about the content filtering category (hate, sexual, violence, selfharm), if it has been detected, as well as // the severity level (verylow, low, medium, high-scale that determines the // intensity and risk level of harmful content) and if it has been filtered or not. @@ -514,6 +558,20 @@ type ChatChoice struct { Message *ChatResponseMessage } +// ChatChoiceLogProbabilityInfo - Log probability information for a choice, as requested via 'logprobs' and 'top_logprobs'. +type ChatChoiceLogProbabilityInfo struct { + // REQUIRED; The list of log probability information entries for the choice's message content tokens, as requested via the + // 'logprobs' option. + Content []ChatTokenLogProbabilityResult +} + +// ChatChoiceLogProbs - The log probability information for this choice, as enabled via the 'logprobs' request option. +type ChatChoiceLogProbs struct { + // REQUIRED; The list of log probability information entries for the choice's message content tokens, as requested via the + // 'logprobs' option. + Content []ChatTokenLogProbabilityResult +} + // ChatCompletionRequestMessageContentPart - represents either an image URL or text content for a prompt type ChatCompletionRequestMessageContentPart struct { // REQUIRED; The type of the content part. @@ -584,16 +642,16 @@ type ChatCompletions struct { // REQUIRED; A unique identifier associated with this chat completions response. ID *string - // REQUIRED; Can be used in conjunction with the seed request parameter to understand when backend changes have been made - // that might impact determinism. - SystemFingerprint *string - // REQUIRED; Usage information for tokens processed and generated as part of this completions operation. Usage *CompletionsUsage // 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. PromptFilterResults []ContentFilterResultsForPrompt + + // Can be used in conjunction with the seed request parameter to understand when backend changes have been made that might + // impact determinism. + SystemFingerprint *string } // ChatCompletionsFunctionToolCall - A tool call to a function tool, issued by the model in evaluation of a configured function @@ -612,8 +670,8 @@ type ChatCompletionsFunctionToolCall struct { // GetChatCompletionsToolCall implements the ChatCompletionsToolCallClassification interface for type ChatCompletionsFunctionToolCall. func (c *ChatCompletionsFunctionToolCall) GetChatCompletionsToolCall() *ChatCompletionsToolCall { return &ChatCompletionsToolCall{ - Type: c.Type, ID: c.ID, + Type: c.Type, } } @@ -634,6 +692,13 @@ func (c *ChatCompletionsFunctionToolDefinition) GetChatCompletionsToolDefinition } } +// ChatCompletionsFunctionToolSelection - A tool selection of a specific, named function tool that will limit chat completions +// to using the named function. +type ChatCompletionsFunctionToolSelection struct { + // REQUIRED; The name of the function that should be called. + Name *string +} + // ChatCompletionsJSONResponseFormat - A response format for Chat Completions that restricts responses to emitting valid JSON // objects. type ChatCompletionsJSONResponseFormat struct { @@ -648,6 +713,37 @@ func (c *ChatCompletionsJSONResponseFormat) GetChatCompletionsResponseFormat() * } } +// ChatCompletionsNamedFunctionToolSelection - A tool selection of a specific, named function tool that will limit chat completions +// to using the named function. +type ChatCompletionsNamedFunctionToolSelection struct { + // REQUIRED; The function that should be called. + Function *ChatCompletionsFunctionToolSelection + + // REQUIRED; The object type. + Type *string +} + +// GetChatCompletionsNamedToolSelection implements the ChatCompletionsNamedToolSelectionClassification interface for type +// ChatCompletionsNamedFunctionToolSelection. +func (c *ChatCompletionsNamedFunctionToolSelection) GetChatCompletionsNamedToolSelection() *ChatCompletionsNamedToolSelection { + return &ChatCompletionsNamedToolSelection{ + Type: c.Type, + } +} + +// ChatCompletionsNamedToolSelection - An abstract representation of an explicit, named tool selection to use for a chat completions +// request. +type ChatCompletionsNamedToolSelection struct { + // REQUIRED; The object type. + Type *string +} + +// GetChatCompletionsNamedToolSelection implements the ChatCompletionsNamedToolSelectionClassification interface for type +// ChatCompletionsNamedToolSelection. +func (c *ChatCompletionsNamedToolSelection) GetChatCompletionsNamedToolSelection() *ChatCompletionsNamedToolSelection { + return c +} + // ChatCompletionsOptions - 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. type ChatCompletionsOptions struct { @@ -660,10 +756,6 @@ type ChatCompletionsOptions struct { // with Azure OpenAI. AzureExtensionsOptions []AzureChatExtensionConfigurationClassification - // 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. - DeploymentName *string - // If provided, the configuration options for available Azure OpenAI chat enhancements. Enhancements *AzureChatEnhancementConfiguration @@ -689,9 +781,18 @@ type ChatCompletionsOptions struct { // by model. LogitBias map[string]*int32 + // Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output + // token returned in the content of message. This option is currently not available + // on the gpt-4-vision-preview model. + LogProbs *bool + // The maximum number of tokens to generate. MaxTokens *int32 + // 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. + DeploymentName *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. @@ -725,6 +826,11 @@ type ChatCompletionsOptions struct { // The available tool definitions that the chat completions request can use, including caller-defined functions. Tools []ChatCompletionsToolDefinitionClassification + // An integer between 0 and 5 specifying the number of most likely tokens to return at each token position, each with an associated + // log probability. logprobs must be set to true if this parameter is + // used. + TopLogProbs *int32 + // 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 @@ -796,6 +902,56 @@ type ChatFinishDetails struct { // GetChatFinishDetails implements the ChatFinishDetailsClassification interface for type ChatFinishDetails. func (c *ChatFinishDetails) GetChatFinishDetails() *ChatFinishDetails { return c } +// ChatMessageContentItem - An abstract representation of a structured content item within a chat message. +type ChatMessageContentItem struct { + // REQUIRED; The discriminated object type. + Type *string +} + +// GetChatMessageContentItem implements the ChatMessageContentItemClassification interface for type ChatMessageContentItem. +func (c *ChatMessageContentItem) GetChatMessageContentItem() *ChatMessageContentItem { return c } + +// ChatMessageImageContentItem - A structured chat content item containing an image reference. +type ChatMessageImageContentItem struct { + // REQUIRED; An internet location, which must be accessible to the model,from which the image may be retrieved. + ImageURL *ChatMessageImageURL + + // REQUIRED; The discriminated object type. + Type *string +} + +// GetChatMessageContentItem implements the ChatMessageContentItemClassification interface for type ChatMessageImageContentItem. +func (c *ChatMessageImageContentItem) GetChatMessageContentItem() *ChatMessageContentItem { + return &ChatMessageContentItem{ + Type: c.Type, + } +} + +// ChatMessageImageURL - An internet location from which the model may retrieve an image. +type ChatMessageImageURL struct { + // REQUIRED; The URL of the image. + URL *string + + // The evaluation quality setting to use, which controls relative prioritization of speed, token consumption, and accuracy. + Detail *ChatMessageImageDetailLevel +} + +// ChatMessageTextContentItem - A structured chat content item containing plain text. +type ChatMessageTextContentItem struct { + // REQUIRED; The content of the message. + Text *string + + // REQUIRED; The discriminated object type. + Type *string +} + +// GetChatMessageContentItem implements the ChatMessageContentItemClassification interface for type ChatMessageTextContentItem. +func (c *ChatMessageTextContentItem) GetChatMessageContentItem() *ChatMessageContentItem { + return &ChatMessageContentItem{ + Type: c.Type, + } +} + // ChatRequestAssistantMessage - A request chat message representing response or action from the assistant. type ChatRequestAssistantMessage struct { // REQUIRED; The content of the message. @@ -804,6 +960,10 @@ type ChatRequestAssistantMessage struct { // REQUIRED; The chat role associated with this message. role *ChatRole + // The function call that must be resolved and have its output appended to subsequent input messages for the chat completions + // request to resolve as configured. + FunctionCall *FunctionCall + // An optional name for the participant. Name *string @@ -819,6 +979,25 @@ func (c *ChatRequestAssistantMessage) GetChatRequestMessage() *ChatRequestMessag } } +// ChatRequestFunctionMessage - A request chat message representing requested output from a configured function. +type ChatRequestFunctionMessage struct { + // REQUIRED; The output of the function as requested by the function call. + Content *string + + // REQUIRED; The chat role associated with this message. + role *ChatRole + + // REQUIRED; The name of the function that was called to produce output. + Name *string +} + +// GetChatRequestMessage implements the ChatRequestMessageClassification interface for type ChatRequestFunctionMessage. +func (c *ChatRequestFunctionMessage) GetChatRequestMessage() *ChatRequestMessage { + return &ChatRequestMessage{ + role: c.role, + } +} + // ChatRequestMessage - An abstract representation of a chat message as provided in a request. type ChatRequestMessage struct { // REQUIRED; The chat role associated with this message. @@ -907,6 +1086,38 @@ type ChatResponseMessage struct { ToolCalls []ChatCompletionsToolCallClassification } +// ChatTokenLogProbabilityInfo - A representation of the log probability information for a single message content token. +type ChatTokenLogProbabilityInfo struct { + // REQUIRED; A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters + // are represented by multiple tokens and their byte representations must be combined to + // generate the correct text representation. Can be null if there is no bytes representation for the token. + Bytes []int32 + + // REQUIRED; The log probability of the message content token. + Logprob *float32 + + // REQUIRED; The message content token. + Token *string +} + +// ChatTokenLogProbabilityResult - A representation of the log probability information for a single content token, including +// a list of most likely tokens if 'top_logprobs' were requested. +type ChatTokenLogProbabilityResult struct { + // REQUIRED; A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters + // are represented by multiple tokens and their byte representations must be combined to + // generate the correct text representation. Can be null if there is no bytes representation for the token. + Bytes []int32 + + // REQUIRED; The log probability of the message content token. + Logprob *float32 + + // REQUIRED; The message content token. + Token *string + + // REQUIRED; The list of most likely tokens and their log probability information, as requested via 'top_logprobs'. + TopLogProbs []ChatTokenLogProbabilityInfo +} + // Choice - The representation of a single prompt completion as part of an overall completions request. Generally, n choices // are generated per provided prompt with a default value of 1. Token limits and other // settings may limit the number of choices generated. @@ -994,10 +1205,6 @@ type CompletionsOptions struct { // and ensure reasonable settings for maxtokens and stop. BestOf *int32 - // 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. - DeploymentName *string - // A value specifying whether completions responses should include input prompts as prefixes to their generated output. Echo *bool @@ -1020,6 +1227,10 @@ type CompletionsOptions struct { // The maximum number of tokens to generate. MaxTokens *int32 + // 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. + DeploymentName *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. @@ -1033,6 +1244,9 @@ type CompletionsOptions struct { // A collection of textual sequences that will end completions generation. Stop []string + // The suffix that comes after a completion of inserted text + Suffix *string + // 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 @@ -1204,6 +1418,7 @@ func (e *ElasticsearchChatExtensionConfiguration) GetAzureChatExtensionConfigura } // ElasticsearchChatExtensionParameters - Parameters to use when configuring Elasticsearch® as an Azure OpenAI chat extension. +// The supported authentication types are KeyAndKeyId and EncodedAPIKey. type ElasticsearchChatExtensionParameters struct { // REQUIRED; The endpoint of Elasticsearch®. Endpoint *string @@ -1294,6 +1509,9 @@ type EmbeddingsOptions struct { // inferior results when newlines are present. Input []string + // When using Azure OpenAI, specifies the input type to use for embedding search. + InputType *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. DeploymentName *string @@ -1345,12 +1563,50 @@ type FunctionDefinition struct { Parameters any } +// FunctionName - A structure that specifies the exact name of a specific, request-provided function to use when processing +// a chat completions operation. +type FunctionName struct { + // REQUIRED; The name of the function to call. + Name *string +} + +// ImageGenerationContentFilterResults - Describes the content filtering result for the image generation request. +type ImageGenerationContentFilterResults struct { + // Describes language attacks or uses that include pejorative or discriminatory language with reference to a person or identity + // group on the basis of certain differentiating attributes of these groups + // including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, religion, + // immigration status, ability status, personal appearance, and body size. + Hate *ContentFilterResult + + // Describes language related to physical actions intended to purposely hurt, injure, or damage one’s body, or kill oneself. + SelfHarm *ContentFilterResult + + // Describes language related to anatomical organs and genitals, romantic relationships, acts portrayed in erotic or affectionate + // terms, physical sexual acts, including those portrayed as an assault or a + // forced sexual violent act against one’s will, prostitution, pornography, and abuse. + Sexual *ContentFilterResult + + // Describes language related to physical actions intended to hurt, injure, damage, or kill someone or something; describes + // weapons, etc. + Violence *ContentFilterResult +} + // ImageGenerationData - A representation of a single generated image, provided as either base64-encoded data or as a URL // from which the image may be retrieved. type ImageGenerationData struct { // The complete data for an image, represented as a base64-encoded string. Base64Data *string + // Information about the content filtering results. + ContentFilterResults *ImageGenerationContentFilterResults + + // Information about the content filtering category (hate, sexual, violence, selfharm), if it has been detected, as well as + // the severity level (verylow, low, medium, high-scale that determines the + // intensity and risk level of harmful content) and if it has been filtered or not. Information about jailbreak content and + // profanity, if it has been detected, and if it has been filtered or not. And + // information about customer block list, if it has been filtered and its id. + PromptFilterResults *ImageGenerationPromptFilterResults + // The final prompt used by the model to generate the image. Only provided with dall-3-models and only when revisions were // made to the prompt. RevisedPrompt *string @@ -1389,6 +1645,33 @@ type ImageGenerationOptions struct { User *string } +// ImageGenerationPromptFilterResults - Describes the content filtering results for the prompt of a image generation request. +type ImageGenerationPromptFilterResults struct { + // Describes language attacks or uses that include pejorative or discriminatory language with reference to a person or identity + // group on the basis of certain differentiating attributes of these groups + // including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, religion, + // immigration status, ability status, personal appearance, and body size. + Hate *ContentFilterResult + + // Whether a jailbreak attempt was detected in the prompt. + Jailbreak *ContentFilterDetectionResult + + // Describes whether profanity was detected. + Profanity *ContentFilterDetectionResult + + // Describes language related to physical actions intended to purposely hurt, injure, or damage one’s body, or kill oneself. + SelfHarm *ContentFilterResult + + // Describes language related to anatomical organs and genitals, romantic relationships, acts portrayed in erotic or affectionate + // terms, physical sexual acts, including those portrayed as an assault or a + // forced sexual violent act against one’s will, prostitution, pornography, and abuse. + Sexual *ContentFilterResult + + // Describes language related to physical actions intended to hurt, injure, damage, or kill someone or something; describes + // weapons, etc. + Violence *ContentFilterResult +} + // ImageGenerations - The result of a successful image generation operation. type ImageGenerations struct { // REQUIRED; A timestamp representing when this operation was started. Expressed in seconds since the Unix epoch of 1970-01-01T00:00:00+0000. @@ -1428,6 +1711,23 @@ func (o *OnYourDataAPIKeyAuthenticationOptions) GetOnYourDataAuthenticationOptio } } +// OnYourDataAccessTokenAuthenticationOptions - The authentication options for Azure OpenAI On Your Data when using access +// token. +type OnYourDataAccessTokenAuthenticationOptions struct { + // REQUIRED; The access token to use for authentication. + AccessToken *string + + // REQUIRED; The authentication type. + configType *OnYourDataAuthenticationType +} + +// GetOnYourDataAuthenticationOptions implements the OnYourDataAuthenticationOptionsClassification interface for type OnYourDataAccessTokenAuthenticationOptions. +func (o *OnYourDataAccessTokenAuthenticationOptions) GetOnYourDataAuthenticationOptions() *OnYourDataAuthenticationOptions { + return &OnYourDataAuthenticationOptions{ + configType: o.configType, + } +} + // OnYourDataAuthenticationOptions - The authentication options for Azure OpenAI On Your Data. type OnYourDataAuthenticationOptions struct { // REQUIRED; The authentication type. @@ -1474,6 +1774,23 @@ func (o *OnYourDataDeploymentNameVectorizationSource) GetOnYourDataVectorization } } +// OnYourDataEncodedAPIKeyAuthenticationOptions - The authentication options for Azure OpenAI On Your Data when using an Elasticsearch +// encoded API key. +type OnYourDataEncodedAPIKeyAuthenticationOptions struct { + // REQUIRED; The encoded API key to use for authentication. + EncodedAPIKey *string + + // REQUIRED; The authentication type. + configType *OnYourDataAuthenticationType +} + +// GetOnYourDataAuthenticationOptions implements the OnYourDataAuthenticationOptionsClassification interface for type OnYourDataEncodedAPIKeyAuthenticationOptions. +func (o *OnYourDataEncodedAPIKeyAuthenticationOptions) GetOnYourDataAuthenticationOptions() *OnYourDataAuthenticationOptions { + return &OnYourDataAuthenticationOptions{ + configType: o.configType, + } +} + // OnYourDataEndpointVectorizationSource - The details of a a vectorization source, used by Azure OpenAI On Your Data when // applying vector search, that is based on a public Azure OpenAI endpoint call for embeddings. type OnYourDataEndpointVectorizationSource struct { @@ -1576,8 +1893,8 @@ func (o *OnYourDataVectorizationSource) GetOnYourDataVectorizationSource() *OnYo return o } -// PineconeChatExtensionConfiguration - A specific representation of configurable options for Elasticsearch when using it -// as an Azure OpenAI chat extension. +// PineconeChatExtensionConfiguration - A specific representation of configurable options for Pinecone when using it as an +// Azure OpenAI chat extension. type PineconeChatExtensionConfiguration struct { // REQUIRED; The label for the type of an Azure chat extension. This typically corresponds to a matching Azure resource. Azure // chat extensions are only compatible with Azure OpenAI. @@ -1594,8 +1911,12 @@ func (p *PineconeChatExtensionConfiguration) GetAzureChatExtensionConfiguration( } } -// PineconeChatExtensionParameters - Parameters for configuring Azure OpenAI Pinecone chat extensions. +// PineconeChatExtensionParameters - Parameters for configuring Azure OpenAI Pinecone chat extensions. The supported authentication +// type is APIKey. type PineconeChatExtensionParameters struct { + // REQUIRED; The embedding dependency for vector search. + EmbeddingDependency OnYourDataVectorizationSourceClassification + // REQUIRED; The environment name of Pinecone. Environment *string @@ -1611,9 +1932,6 @@ type PineconeChatExtensionParameters struct { // credential) authentication. Authentication OnYourDataAuthenticationOptionsClassification - // The embedding dependency for vector search. - EmbeddingDependency OnYourDataVectorizationSourceClassification - // Whether queries should be restricted to use of indexed data. InScope *bool @@ -1632,7 +1950,7 @@ type PineconeChatExtensionParameters struct { // PineconeFieldMappingOptions - Optional settings to control how fields are processed when using a configured Pinecone resource. type PineconeFieldMappingOptions struct { - // The names of index fields that should be treated as content. + // REQUIRED; The names of index fields that should be treated as content. ContentFields []string // The separator pattern that content fields should use. @@ -1641,17 +1959,36 @@ type PineconeFieldMappingOptions struct { // The name of the index field to use as a filepath. FilepathField *string - // The names of fields that represent image vector data. - ImageVectorFields []string - // The name of the index field to use as a title. TitleField *string // The name of the index field to use as a URL. URLField *string +} - // The names of fields that represent vector data. - VectorFields []string +// SpeechGenerationOptions - A representation of the request options that control the behavior of a text-to-speech operation. +type SpeechGenerationOptions struct { + // REQUIRED; The text to generate audio for. The maximum length is 4096 characters. + Input *string + + // REQUIRED; The voice to use for text-to-speech. + Voice *SpeechVoice + + // The model to use for this text-to-speech request. + DeploymentName *string + + // The audio output format for the spoken text. By default, the MP3 format will be used. + ResponseFormat *SpeechGenerationResponseFormat + + // The speed of speech for generated audio. Values are valid in the range from 0.25 to 4.0, with 1.0 the default and higher + // values corresponding to faster speech. + Speed *float32 +} + +// SpeechGenerationResponse - A representation of a response for a text-to-speech operation. +type SpeechGenerationResponse struct { + // REQUIRED; The generated audio, generated in the requested audio output format. + Audio []byte } // StopFinishDetails - A structured representation of a stop reason that signifies natural termination by the model. diff --git a/sdk/ai/azopenai/models_serde.go b/sdk/ai/azopenai/models_serde.go index 4cbcbed31e64..a9ee5a7ac544 100644 --- a/sdk/ai/azopenai/models_serde.go +++ b/sdk/ai/azopenai/models_serde.go @@ -63,10 +63,12 @@ func (a *AudioTranscription) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AudioTranscriptionOptions. func (a AudioTranscriptionOptions) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "model", a.DeploymentName) - populateByteArray(objectMap, "file", a.File, runtime.Base64StdFormat) + populateByteArray(objectMap, "file", a.File, func() any { + return runtime.EncodeByteArray(a.File, runtime.Base64StdFormat) + }) populate(objectMap, "filename", a.Filename) populate(objectMap, "language", a.Language) + populate(objectMap, "model", a.DeploymentName) populate(objectMap, "prompt", a.Prompt) populate(objectMap, "response_format", a.ResponseFormat) populate(objectMap, "temperature", a.Temperature) @@ -82,11 +84,10 @@ func (a *AudioTranscriptionOptions) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "model": - err = unpopulate(val, "DeploymentName", &a.DeploymentName) - delete(rawMsg, key) case "file": - err = runtime.DecodeByteArray(string(val), &a.File, runtime.Base64StdFormat) + if val != nil && string(val) != "null" { + err = runtime.DecodeByteArray(string(val), &a.File, runtime.Base64StdFormat) + } delete(rawMsg, key) case "filename": err = unpopulate(val, "Filename", &a.Filename) @@ -94,6 +95,9 @@ func (a *AudioTranscriptionOptions) UnmarshalJSON(data []byte) error { case "language": err = unpopulate(val, "Language", &a.Language) delete(rawMsg, key) + case "model": + err = unpopulate(val, "Model", &a.DeploymentName) + delete(rawMsg, key) case "prompt": err = unpopulate(val, "Prompt", &a.Prompt) delete(rawMsg, key) @@ -220,9 +224,11 @@ func (a *AudioTranslation) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AudioTranslationOptions. func (a AudioTranslationOptions) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "model", a.DeploymentName) - populateByteArray(objectMap, "file", a.File, runtime.Base64StdFormat) + populateByteArray(objectMap, "file", a.File, func() any { + return runtime.EncodeByteArray(a.File, runtime.Base64StdFormat) + }) populate(objectMap, "filename", a.Filename) + populate(objectMap, "model", a.DeploymentName) populate(objectMap, "prompt", a.Prompt) populate(objectMap, "response_format", a.ResponseFormat) populate(objectMap, "temperature", a.Temperature) @@ -238,15 +244,17 @@ func (a *AudioTranslationOptions) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "model": - err = unpopulate(val, "DeploymentName", &a.DeploymentName) - delete(rawMsg, key) case "file": - err = runtime.DecodeByteArray(string(val), &a.File, runtime.Base64StdFormat) + if val != nil && string(val) != "null" { + err = runtime.DecodeByteArray(string(val), &a.File, runtime.Base64StdFormat) + } delete(rawMsg, key) case "filename": err = unpopulate(val, "Filename", &a.Filename) delete(rawMsg, key) + case "model": + err = unpopulate(val, "Model", &a.DeploymentName) + delete(rawMsg, key) case "prompt": err = unpopulate(val, "Prompt", &a.Prompt) delete(rawMsg, key) @@ -412,15 +420,19 @@ func (a *AzureChatExtensionConfiguration) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type AzureChatExtensionsMessageContext. -func (a AzureChatExtensionsMessageContext) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type AzureChatExtensionDataSourceResponseCitation. +func (a AzureChatExtensionDataSourceResponseCitation) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "messages", a.Messages) + populate(objectMap, "chunk_id", a.ChunkID) + populate(objectMap, "content", a.Content) + populate(objectMap, "filepath", a.Filepath) + populate(objectMap, "title", a.Title) + populate(objectMap, "url", a.URL) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type AzureChatExtensionsMessageContext. -func (a *AzureChatExtensionsMessageContext) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureChatExtensionDataSourceResponseCitation. +func (a *AzureChatExtensionDataSourceResponseCitation) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) @@ -428,62 +440,20 @@ func (a *AzureChatExtensionsMessageContext) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "messages": - err = unpopulate(val, "Messages", &a.Messages) + case "chunk_id": + err = unpopulate(val, "ChunkID", &a.ChunkID) delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type AzureChatGroundingEnhancementConfiguration. -func (a AzureChatGroundingEnhancementConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "enabled", a.Enabled) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type AzureChatGroundingEnhancementConfiguration. -func (a *AzureChatGroundingEnhancementConfiguration) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "enabled": - err = unpopulate(val, "Enabled", &a.Enabled) + case "content": + err = unpopulate(val, "Content", &a.Content) delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type AzureChatOCREnhancementConfiguration. -func (a AzureChatOCREnhancementConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "enabled", a.Enabled) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type AzureChatOCREnhancementConfiguration. -func (a *AzureChatOCREnhancementConfiguration) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "enabled": - err = unpopulate(val, "Enabled", &a.Enabled) + case "filepath": + err = unpopulate(val, "Filepath", &a.Filepath) + delete(rawMsg, key) + case "title": + err = unpopulate(val, "Title", &a.Title) + delete(rawMsg, key) + case "url": + err = unpopulate(val, "URL", &a.URL) delete(rawMsg, key) } if err != nil { @@ -493,16 +463,16 @@ func (a *AzureChatOCREnhancementConfiguration) UnmarshalJSON(data []byte) error return nil } -// MarshalJSON implements the json.Marshaller interface for type AzureCognitiveSearchChatExtensionConfiguration. -func (a AzureCognitiveSearchChatExtensionConfiguration) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type AzureChatExtensionsMessageContext. +func (a AzureChatExtensionsMessageContext) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - objectMap["type"] = AzureChatExtensionTypeAzureCognitiveSearch - populate(objectMap, "parameters", a.Parameters) + populate(objectMap, "citations", a.Citations) + populate(objectMap, "intent", a.Intent) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type AzureCognitiveSearchChatExtensionConfiguration. -func (a *AzureCognitiveSearchChatExtensionConfiguration) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureChatExtensionsMessageContext. +func (a *AzureChatExtensionsMessageContext) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) @@ -510,11 +480,11 @@ func (a *AzureCognitiveSearchChatExtensionConfiguration) UnmarshalJSON(data []by for key, val := range rawMsg { var err error switch key { - case "type": - err = unpopulate(val, "configType", &a.configType) + case "citations": + err = unpopulate(val, "Citations", &a.Citations) delete(rawMsg, key) - case "parameters": - err = unpopulate(val, "Parameters", &a.Parameters) + case "intent": + err = unpopulate(val, "Intent", &a.Intent) delete(rawMsg, key) } if err != nil { @@ -524,26 +494,15 @@ func (a *AzureCognitiveSearchChatExtensionConfiguration) UnmarshalJSON(data []by return nil } -// MarshalJSON implements the json.Marshaller interface for type AzureCognitiveSearchChatExtensionParameters. -func (a AzureCognitiveSearchChatExtensionParameters) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type AzureChatGroundingEnhancementConfiguration. +func (a AzureChatGroundingEnhancementConfiguration) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "authentication", a.Authentication) - populate(objectMap, "embeddingDependency", a.EmbeddingDependency) - populate(objectMap, "endpoint", a.Endpoint) - populate(objectMap, "fieldsMapping", a.FieldsMapping) - populate(objectMap, "filter", a.Filter) - populate(objectMap, "inScope", a.InScope) - populate(objectMap, "indexName", a.IndexName) - populate(objectMap, "queryType", a.QueryType) - populate(objectMap, "roleInformation", a.RoleInformation) - populate(objectMap, "semanticConfiguration", a.SemanticConfiguration) - populate(objectMap, "strictness", a.Strictness) - populate(objectMap, "topNDocuments", a.TopNDocuments) + populate(objectMap, "enabled", a.Enabled) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type AzureCognitiveSearchChatExtensionParameters. -func (a *AzureCognitiveSearchChatExtensionParameters) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureChatGroundingEnhancementConfiguration. +func (a *AzureChatGroundingEnhancementConfiguration) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) @@ -551,41 +510,8 @@ func (a *AzureCognitiveSearchChatExtensionParameters) UnmarshalJSON(data []byte) for key, val := range rawMsg { var err error switch key { - case "authentication": - a.Authentication, err = unmarshalOnYourDataAuthenticationOptionsClassification(val) - delete(rawMsg, key) - case "embeddingDependency": - a.EmbeddingDependency, err = unmarshalOnYourDataVectorizationSourceClassification(val) - delete(rawMsg, key) - case "endpoint": - err = unpopulate(val, "Endpoint", &a.Endpoint) - delete(rawMsg, key) - case "fieldsMapping": - err = unpopulate(val, "FieldsMapping", &a.FieldsMapping) - delete(rawMsg, key) - case "filter": - err = unpopulate(val, "Filter", &a.Filter) - delete(rawMsg, key) - case "inScope": - err = unpopulate(val, "InScope", &a.InScope) - delete(rawMsg, key) - case "indexName": - err = unpopulate(val, "IndexName", &a.IndexName) - delete(rawMsg, key) - case "queryType": - err = unpopulate(val, "QueryType", &a.QueryType) - delete(rawMsg, key) - case "roleInformation": - err = unpopulate(val, "RoleInformation", &a.RoleInformation) - delete(rawMsg, key) - case "semanticConfiguration": - err = unpopulate(val, "SemanticConfiguration", &a.SemanticConfiguration) - delete(rawMsg, key) - case "strictness": - err = unpopulate(val, "Strictness", &a.Strictness) - delete(rawMsg, key) - case "topNDocuments": - err = unpopulate(val, "TopNDocuments", &a.TopNDocuments) + case "enabled": + err = unpopulate(val, "Enabled", &a.Enabled) delete(rawMsg, key) } if err != nil { @@ -595,21 +521,15 @@ func (a *AzureCognitiveSearchChatExtensionParameters) UnmarshalJSON(data []byte) return nil } -// MarshalJSON implements the json.Marshaller interface for type AzureCognitiveSearchIndexFieldMappingOptions. -func (a AzureCognitiveSearchIndexFieldMappingOptions) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type AzureChatOCREnhancementConfiguration. +func (a AzureChatOCREnhancementConfiguration) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "contentFields", a.ContentFields) - populate(objectMap, "contentFieldsSeparator", a.ContentFieldsSeparator) - populate(objectMap, "filepathField", a.FilepathField) - populate(objectMap, "imageVectorFields", a.ImageVectorFields) - populate(objectMap, "titleField", a.TitleField) - populate(objectMap, "urlField", a.URLField) - populate(objectMap, "vectorFields", a.VectorFields) + populate(objectMap, "enabled", a.Enabled) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type AzureCognitiveSearchIndexFieldMappingOptions. -func (a *AzureCognitiveSearchIndexFieldMappingOptions) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureChatOCREnhancementConfiguration. +func (a *AzureChatOCREnhancementConfiguration) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) @@ -617,26 +537,8 @@ func (a *AzureCognitiveSearchIndexFieldMappingOptions) UnmarshalJSON(data []byte for key, val := range rawMsg { var err error switch key { - case "contentFields": - err = unpopulate(val, "ContentFields", &a.ContentFields) - delete(rawMsg, key) - case "contentFieldsSeparator": - err = unpopulate(val, "ContentFieldsSeparator", &a.ContentFieldsSeparator) - delete(rawMsg, key) - case "filepathField": - err = unpopulate(val, "FilepathField", &a.FilepathField) - delete(rawMsg, key) - case "imageVectorFields": - err = unpopulate(val, "ImageVectorFields", &a.ImageVectorFields) - delete(rawMsg, key) - case "titleField": - err = unpopulate(val, "TitleField", &a.TitleField) - delete(rawMsg, key) - case "urlField": - err = unpopulate(val, "URLField", &a.URLField) - delete(rawMsg, key) - case "vectorFields": - err = unpopulate(val, "VectorFields", &a.VectorFields) + case "enabled": + err = unpopulate(val, "Enabled", &a.Enabled) delete(rawMsg, key) } if err != nil { @@ -681,15 +583,15 @@ func (a *AzureCosmosDBChatExtensionConfiguration) UnmarshalJSON(data []byte) err func (a AzureCosmosDBChatExtensionParameters) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "authentication", a.Authentication) - populate(objectMap, "containerName", a.ContainerName) - populate(objectMap, "databaseName", a.DatabaseName) - populate(objectMap, "embeddingDependency", a.EmbeddingDependency) - populate(objectMap, "fieldsMapping", a.FieldsMapping) - populate(objectMap, "inScope", a.InScope) - populate(objectMap, "indexName", a.IndexName) - populate(objectMap, "roleInformation", a.RoleInformation) + populate(objectMap, "container_name", a.ContainerName) + populate(objectMap, "database_name", a.DatabaseName) + populate(objectMap, "embedding_dependency", a.EmbeddingDependency) + populate(objectMap, "fields_mapping", a.FieldsMapping) + populate(objectMap, "in_scope", a.InScope) + populate(objectMap, "index_name", a.IndexName) + populate(objectMap, "role_information", a.RoleInformation) populate(objectMap, "strictness", a.Strictness) - populate(objectMap, "topNDocuments", a.TopNDocuments) + populate(objectMap, "top_n_documents", a.TopNDocuments) return json.Marshal(objectMap) } @@ -705,31 +607,31 @@ func (a *AzureCosmosDBChatExtensionParameters) UnmarshalJSON(data []byte) error case "authentication": a.Authentication, err = unmarshalOnYourDataAuthenticationOptionsClassification(val) delete(rawMsg, key) - case "containerName": + case "container_name": err = unpopulate(val, "ContainerName", &a.ContainerName) delete(rawMsg, key) - case "databaseName": + case "database_name": err = unpopulate(val, "DatabaseName", &a.DatabaseName) delete(rawMsg, key) - case "embeddingDependency": + case "embedding_dependency": a.EmbeddingDependency, err = unmarshalOnYourDataVectorizationSourceClassification(val) delete(rawMsg, key) - case "fieldsMapping": + case "fields_mapping": err = unpopulate(val, "FieldsMapping", &a.FieldsMapping) delete(rawMsg, key) - case "inScope": + case "in_scope": err = unpopulate(val, "InScope", &a.InScope) delete(rawMsg, key) - case "indexName": + case "index_name": err = unpopulate(val, "IndexName", &a.IndexName) delete(rawMsg, key) - case "roleInformation": + case "role_information": err = unpopulate(val, "RoleInformation", &a.RoleInformation) delete(rawMsg, key) case "strictness": err = unpopulate(val, "Strictness", &a.Strictness) delete(rawMsg, key) - case "topNDocuments": + case "top_n_documents": err = unpopulate(val, "TopNDocuments", &a.TopNDocuments) delete(rawMsg, key) } @@ -743,7 +645,12 @@ func (a *AzureCosmosDBChatExtensionParameters) UnmarshalJSON(data []byte) error // MarshalJSON implements the json.Marshaller interface for type AzureCosmosDBFieldMappingOptions. func (a AzureCosmosDBFieldMappingOptions) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "vectorFields", a.VectorFields) + populate(objectMap, "content_fields", a.ContentFields) + populate(objectMap, "content_fields_separator", a.ContentFieldsSeparator) + populate(objectMap, "filepath_field", a.FilepathField) + populate(objectMap, "title_field", a.TitleField) + populate(objectMap, "url_field", a.URLField) + populate(objectMap, "vector_fields", a.VectorFields) return json.Marshal(objectMap) } @@ -756,7 +663,22 @@ func (a *AzureCosmosDBFieldMappingOptions) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "vectorFields": + case "content_fields": + err = unpopulate(val, "ContentFields", &a.ContentFields) + delete(rawMsg, key) + case "content_fields_separator": + err = unpopulate(val, "ContentFieldsSeparator", &a.ContentFieldsSeparator) + delete(rawMsg, key) + case "filepath_field": + err = unpopulate(val, "FilepathField", &a.FilepathField) + delete(rawMsg, key) + case "title_field": + err = unpopulate(val, "TitleField", &a.TitleField) + delete(rawMsg, key) + case "url_field": + err = unpopulate(val, "URLField", &a.URLField) + delete(rawMsg, key) + case "vector_fields": err = unpopulate(val, "VectorFields", &a.VectorFields) delete(rawMsg, key) } @@ -931,12 +853,12 @@ func (a AzureMachineLearningIndexChatExtensionParameters) MarshalJSON() ([]byte, objectMap := make(map[string]any) populate(objectMap, "authentication", a.Authentication) populate(objectMap, "filter", a.Filter) - populate(objectMap, "inScope", a.InScope) + populate(objectMap, "in_scope", a.InScope) populate(objectMap, "name", a.Name) - populate(objectMap, "projectResourceId", a.ProjectResourceID) - populate(objectMap, "roleInformation", a.RoleInformation) + populate(objectMap, "project_resource_id", a.ProjectResourceID) + populate(objectMap, "role_information", a.RoleInformation) populate(objectMap, "strictness", a.Strictness) - populate(objectMap, "topNDocuments", a.TopNDocuments) + populate(objectMap, "top_n_documents", a.TopNDocuments) populate(objectMap, "version", a.Version) return json.Marshal(objectMap) } @@ -956,22 +878,22 @@ func (a *AzureMachineLearningIndexChatExtensionParameters) UnmarshalJSON(data [] case "filter": err = unpopulate(val, "Filter", &a.Filter) delete(rawMsg, key) - case "inScope": + case "in_scope": err = unpopulate(val, "InScope", &a.InScope) delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &a.Name) delete(rawMsg, key) - case "projectResourceId": + case "project_resource_id": err = unpopulate(val, "ProjectResourceID", &a.ProjectResourceID) delete(rawMsg, key) - case "roleInformation": + case "role_information": err = unpopulate(val, "RoleInformation", &a.RoleInformation) delete(rawMsg, key) case "strictness": err = unpopulate(val, "Strictness", &a.Strictness) delete(rawMsg, key) - case "topNDocuments": + case "top_n_documents": err = unpopulate(val, "TopNDocuments", &a.TopNDocuments) delete(rawMsg, key) case "version": @@ -985,110 +907,321 @@ func (a *AzureMachineLearningIndexChatExtensionParameters) UnmarshalJSON(data [] return nil } -// MarshalJSON implements the json.Marshaller interface for type ChatChoice. -func (c ChatChoice) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type AzureSearchChatExtensionConfiguration. +func (a AzureSearchChatExtensionConfiguration) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "content_filter_results", c.ContentFilterResults) - populate(objectMap, "delta", c.Delta) - populate(objectMap, "enhancements", c.Enhancements) - populate(objectMap, "finish_details", c.FinishDetails) - populate(objectMap, "finish_reason", c.FinishReason) - populate(objectMap, "index", c.Index) - populate(objectMap, "message", c.Message) + objectMap["type"] = AzureChatExtensionTypeAzureSearch + populate(objectMap, "parameters", a.Parameters) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ChatChoice. -func (c *ChatChoice) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureSearchChatExtensionConfiguration. +func (a *AzureSearchChatExtensionConfiguration) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) + return fmt.Errorf("unmarshalling type %T: %v", a, err) } for key, val := range rawMsg { var err error switch key { - case "content_filter_results": - err = unpopulate(val, "ContentFilterResults", &c.ContentFilterResults) - delete(rawMsg, key) - case "delta": - err = unpopulate(val, "Delta", &c.Delta) - delete(rawMsg, key) - case "enhancements": - err = unpopulate(val, "Enhancements", &c.Enhancements) - delete(rawMsg, key) - case "finish_details": - c.FinishDetails, err = unmarshalChatFinishDetailsClassification(val) - delete(rawMsg, key) - case "finish_reason": - err = unpopulate(val, "FinishReason", &c.FinishReason) - delete(rawMsg, key) - case "index": - err = unpopulate(val, "Index", &c.Index) + case "type": + err = unpopulate(val, "configType", &a.configType) delete(rawMsg, key) - case "message": - err = unpopulate(val, "Message", &c.Message) + case "parameters": + err = unpopulate(val, "Parameters", &a.Parameters) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) + return fmt.Errorf("unmarshalling type %T: %v", a, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ChatCompletionRequestMessageContentPart. -func (c ChatCompletionRequestMessageContentPart) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type AzureSearchChatExtensionParameters. +func (a AzureSearchChatExtensionParameters) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - objectMap["type"] = c.partType + populate(objectMap, "authentication", a.Authentication) + populate(objectMap, "embedding_dependency", a.EmbeddingDependency) + populate(objectMap, "endpoint", a.Endpoint) + populate(objectMap, "fields_mapping", a.FieldsMapping) + populate(objectMap, "filter", a.Filter) + populate(objectMap, "in_scope", a.InScope) + populate(objectMap, "index_name", a.IndexName) + populate(objectMap, "query_type", a.QueryType) + populate(objectMap, "role_information", a.RoleInformation) + populate(objectMap, "semantic_configuration", a.SemanticConfiguration) + populate(objectMap, "strictness", a.Strictness) + populate(objectMap, "top_n_documents", a.TopNDocuments) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ChatCompletionRequestMessageContentPart. -func (c *ChatCompletionRequestMessageContentPart) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureSearchChatExtensionParameters. +func (a *AzureSearchChatExtensionParameters) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) + return fmt.Errorf("unmarshalling type %T: %v", a, err) } for key, val := range rawMsg { var err error switch key { - case "type": - err = unpopulate(val, "partType", &c.partType) + case "authentication": + a.Authentication, err = unmarshalOnYourDataAuthenticationOptionsClassification(val) + delete(rawMsg, key) + case "embedding_dependency": + a.EmbeddingDependency, err = unmarshalOnYourDataVectorizationSourceClassification(val) + delete(rawMsg, key) + case "endpoint": + err = unpopulate(val, "Endpoint", &a.Endpoint) + delete(rawMsg, key) + case "fields_mapping": + err = unpopulate(val, "FieldsMapping", &a.FieldsMapping) + delete(rawMsg, key) + case "filter": + err = unpopulate(val, "Filter", &a.Filter) + delete(rawMsg, key) + case "in_scope": + err = unpopulate(val, "InScope", &a.InScope) + delete(rawMsg, key) + case "index_name": + err = unpopulate(val, "IndexName", &a.IndexName) + delete(rawMsg, key) + case "query_type": + err = unpopulate(val, "QueryType", &a.QueryType) + delete(rawMsg, key) + case "role_information": + err = unpopulate(val, "RoleInformation", &a.RoleInformation) + delete(rawMsg, key) + case "semantic_configuration": + err = unpopulate(val, "SemanticConfiguration", &a.SemanticConfiguration) + delete(rawMsg, key) + case "strictness": + err = unpopulate(val, "Strictness", &a.Strictness) + delete(rawMsg, key) + case "top_n_documents": + err = unpopulate(val, "TopNDocuments", &a.TopNDocuments) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) + return fmt.Errorf("unmarshalling type %T: %v", a, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ChatCompletionRequestMessageContentPartImage. -func (c ChatCompletionRequestMessageContentPartImage) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type AzureSearchIndexFieldMappingOptions. +func (a AzureSearchIndexFieldMappingOptions) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - objectMap["type"] = ChatCompletionRequestMessageContentPartTypeImageURL - populate(objectMap, "image_url", c.ImageURL) + populate(objectMap, "content_fields", a.ContentFields) + populate(objectMap, "content_fields_separator", a.ContentFieldsSeparator) + populate(objectMap, "filepath_field", a.FilepathField) + populate(objectMap, "image_vector_fields", a.ImageVectorFields) + populate(objectMap, "title_field", a.TitleField) + populate(objectMap, "url_field", a.URLField) + populate(objectMap, "vector_fields", a.VectorFields) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ChatCompletionRequestMessageContentPartImage. -func (c *ChatCompletionRequestMessageContentPartImage) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureSearchIndexFieldMappingOptions. +func (a *AzureSearchIndexFieldMappingOptions) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) + return fmt.Errorf("unmarshalling type %T: %v", a, err) } for key, val := range rawMsg { var err error switch key { - case "type": - err = unpopulate(val, "partType", &c.partType) + case "content_fields": + err = unpopulate(val, "ContentFields", &a.ContentFields) delete(rawMsg, key) - case "image_url": - err = unpopulate(val, "ImageURL", &c.ImageURL) + case "content_fields_separator": + err = unpopulate(val, "ContentFieldsSeparator", &a.ContentFieldsSeparator) + delete(rawMsg, key) + case "filepath_field": + err = unpopulate(val, "FilepathField", &a.FilepathField) + delete(rawMsg, key) + case "image_vector_fields": + err = unpopulate(val, "ImageVectorFields", &a.ImageVectorFields) + delete(rawMsg, key) + case "title_field": + err = unpopulate(val, "TitleField", &a.TitleField) + delete(rawMsg, key) + case "url_field": + err = unpopulate(val, "URLField", &a.URLField) + delete(rawMsg, key) + case "vector_fields": + err = unpopulate(val, "VectorFields", &a.VectorFields) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ChatChoice. +func (c ChatChoice) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "content_filter_results", c.ContentFilterResults) + populate(objectMap, "delta", c.Delta) + populate(objectMap, "enhancements", c.Enhancements) + populate(objectMap, "finish_details", c.FinishDetails) + populate(objectMap, "finish_reason", c.FinishReason) + populate(objectMap, "index", c.Index) + populate(objectMap, "logprobs", c.LogProbs) + populate(objectMap, "message", c.Message) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ChatChoice. +func (c *ChatChoice) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "content_filter_results": + err = unpopulate(val, "ContentFilterResults", &c.ContentFilterResults) + delete(rawMsg, key) + case "delta": + err = unpopulate(val, "Delta", &c.Delta) + delete(rawMsg, key) + case "enhancements": + err = unpopulate(val, "Enhancements", &c.Enhancements) + delete(rawMsg, key) + case "finish_details": + c.FinishDetails, err = unmarshalChatFinishDetailsClassification(val) + delete(rawMsg, key) + case "finish_reason": + err = unpopulate(val, "FinishReason", &c.FinishReason) + delete(rawMsg, key) + case "index": + err = unpopulate(val, "Index", &c.Index) + delete(rawMsg, key) + case "logprobs": + err = unpopulate(val, "LogProbs", &c.LogProbs) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &c.Message) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ChatChoiceLogProbabilityInfo. +func (c ChatChoiceLogProbabilityInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "content", c.Content) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ChatChoiceLogProbabilityInfo. +func (c *ChatChoiceLogProbabilityInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "content": + err = unpopulate(val, "Content", &c.Content) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ChatChoiceLogProbs. +func (c ChatChoiceLogProbs) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "content", c.Content) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ChatChoiceLogProbs. +func (c *ChatChoiceLogProbs) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "content": + err = unpopulate(val, "Content", &c.Content) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ChatCompletionRequestMessageContentPart. +func (c ChatCompletionRequestMessageContentPart) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["type"] = c.partType + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ChatCompletionRequestMessageContentPart. +func (c *ChatCompletionRequestMessageContentPart) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "type": + err = unpopulate(val, "partType", &c.partType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ChatCompletionRequestMessageContentPartImage. +func (c ChatCompletionRequestMessageContentPartImage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["type"] = ChatCompletionRequestMessageContentPartTypeImageURL + populate(objectMap, "image_url", c.ImageURL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ChatCompletionRequestMessageContentPartImage. +func (c *ChatCompletionRequestMessageContentPartImage) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "type": + err = unpopulate(val, "partType", &c.partType) + delete(rawMsg, key) + case "image_url": + err = unpopulate(val, "ImageURL", &c.ImageURL) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) } } return nil @@ -1271,6 +1404,33 @@ func (c *ChatCompletionsFunctionToolDefinition) UnmarshalJSON(data []byte) error return nil } +// MarshalJSON implements the json.Marshaller interface for type ChatCompletionsFunctionToolSelection. +func (c ChatCompletionsFunctionToolSelection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", c.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ChatCompletionsFunctionToolSelection. +func (c *ChatCompletionsFunctionToolSelection) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type ChatCompletionsJSONResponseFormat. func (c ChatCompletionsJSONResponseFormat) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1298,18 +1458,77 @@ func (c *ChatCompletionsJSONResponseFormat) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ChatCompletionsNamedFunctionToolSelection. +func (c ChatCompletionsNamedFunctionToolSelection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "function", c.Function) + objectMap["type"] = "function" + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ChatCompletionsNamedFunctionToolSelection. +func (c *ChatCompletionsNamedFunctionToolSelection) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "function": + err = unpopulate(val, "Function", &c.Function) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ChatCompletionsNamedToolSelection. +func (c ChatCompletionsNamedToolSelection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["type"] = c.Type + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ChatCompletionsNamedToolSelection. +func (c *ChatCompletionsNamedToolSelection) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type ChatCompletionsOptions. func (c ChatCompletionsOptions) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "dataSources", c.AzureExtensionsOptions) - populate(objectMap, "model", c.DeploymentName) + populate(objectMap, "data_sources", c.AzureExtensionsOptions) populate(objectMap, "enhancements", c.Enhancements) populate(objectMap, "frequency_penalty", c.FrequencyPenalty) populate(objectMap, "function_call", c.FunctionCall) populate(objectMap, "functions", c.Functions) populate(objectMap, "logit_bias", c.LogitBias) + populate(objectMap, "logprobs", c.LogProbs) populate(objectMap, "max_tokens", c.MaxTokens) populate(objectMap, "messages", c.Messages) + populate(objectMap, "model", c.DeploymentName) populate(objectMap, "n", c.N) populate(objectMap, "presence_penalty", c.PresencePenalty) populate(objectMap, "response_format", c.ResponseFormat) @@ -1318,6 +1537,7 @@ func (c ChatCompletionsOptions) MarshalJSON() ([]byte, error) { populate(objectMap, "temperature", c.Temperature) populate(objectMap, "tool_choice", c.ToolChoice) populate(objectMap, "tools", c.Tools) + populate(objectMap, "top_logprobs", c.TopLogProbs) populate(objectMap, "top_p", c.TopP) populate(objectMap, "user", c.User) return json.Marshal(objectMap) @@ -1332,27 +1552,36 @@ func (c *ChatCompletionsOptions) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "dataSources": + case "data_sources": c.AzureExtensionsOptions, err = unmarshalAzureChatExtensionConfigurationClassificationArray(val) delete(rawMsg, key) - case "model": - err = unpopulate(val, "DeploymentName", &c.DeploymentName) - delete(rawMsg, key) case "enhancements": err = unpopulate(val, "Enhancements", &c.Enhancements) delete(rawMsg, key) case "frequency_penalty": err = unpopulate(val, "FrequencyPenalty", &c.FrequencyPenalty) delete(rawMsg, key) + case "function_call": + err = unpopulate(val, "FunctionCall", &c.FunctionCall) + delete(rawMsg, key) + case "functions": + err = unpopulate(val, "Functions", &c.Functions) + delete(rawMsg, key) case "logit_bias": err = unpopulate(val, "LogitBias", &c.LogitBias) delete(rawMsg, key) + case "logprobs": + err = unpopulate(val, "LogProbs", &c.LogProbs) + delete(rawMsg, key) case "max_tokens": err = unpopulate(val, "MaxTokens", &c.MaxTokens) delete(rawMsg, key) case "messages": c.Messages, err = unmarshalChatRequestMessageClassificationArray(val) delete(rawMsg, key) + case "model": + err = unpopulate(val, "Model", &c.DeploymentName) + delete(rawMsg, key) case "n": err = unpopulate(val, "N", &c.N) delete(rawMsg, key) @@ -1377,6 +1606,9 @@ func (c *ChatCompletionsOptions) UnmarshalJSON(data []byte) error { case "tools": c.Tools, err = unmarshalChatCompletionsToolDefinitionClassificationArray(val) delete(rawMsg, key) + case "top_logprobs": + err = unpopulate(val, "TopLogProbs", &c.TopLogProbs) + delete(rawMsg, key) case "top_p": err = unpopulate(val, "TopP", &c.TopP) delete(rawMsg, key) @@ -1530,18 +1762,180 @@ func (c *ChatFinishDetails) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ChatRequestAssistantMessage. -func (c ChatRequestAssistantMessage) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ChatMessageContentItem. +func (c ChatMessageContentItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["type"] = c.Type + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ChatMessageContentItem. +func (c *ChatMessageContentItem) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ChatMessageImageContentItem. +func (c ChatMessageImageContentItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "image_url", c.ImageURL) + objectMap["type"] = "image_url" + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ChatMessageImageContentItem. +func (c *ChatMessageImageContentItem) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "image_url": + err = unpopulate(val, "ImageURL", &c.ImageURL) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ChatMessageImageURL. +func (c ChatMessageImageURL) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "detail", c.Detail) + populate(objectMap, "url", c.URL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ChatMessageImageURL. +func (c *ChatMessageImageURL) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "detail": + err = unpopulate(val, "Detail", &c.Detail) + delete(rawMsg, key) + case "url": + err = unpopulate(val, "URL", &c.URL) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ChatMessageTextContentItem. +func (c ChatMessageTextContentItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "text", c.Text) + objectMap["type"] = "text" + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ChatMessageTextContentItem. +func (c *ChatMessageTextContentItem) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "text": + err = unpopulate(val, "Text", &c.Text) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ChatRequestAssistantMessage. +func (c ChatRequestAssistantMessage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "content", c.Content) + populate(objectMap, "function_call", c.FunctionCall) + objectMap["role"] = ChatRoleAssistant + populate(objectMap, "name", c.Name) + populate(objectMap, "tool_calls", c.ToolCalls) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ChatRequestAssistantMessage. +func (c *ChatRequestAssistantMessage) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "content": + err = unpopulate(val, "Content", &c.Content) + delete(rawMsg, key) + case "function_call": + err = unpopulate(val, "FunctionCall", &c.FunctionCall) + delete(rawMsg, key) + case "role": + err = unpopulate(val, "role", &c.role) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "tool_calls": + c.ToolCalls, err = unmarshalChatCompletionsToolCallClassificationArray(val) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ChatRequestFunctionMessage. +func (c ChatRequestFunctionMessage) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "content", c.Content) - objectMap["role"] = ChatRoleAssistant + objectMap["role"] = ChatRoleFunction populate(objectMap, "name", c.Name) - populate(objectMap, "tool_calls", c.ToolCalls) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ChatRequestAssistantMessage. -func (c *ChatRequestAssistantMessage) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ChatRequestFunctionMessage. +func (c *ChatRequestFunctionMessage) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", c, err) @@ -1558,9 +1952,6 @@ func (c *ChatRequestAssistantMessage) UnmarshalJSON(data []byte) error { case "name": err = unpopulate(val, "Name", &c.Name) delete(rawMsg, key) - case "tool_calls": - c.ToolCalls, err = unmarshalChatCompletionsToolCallClassificationArray(val) - delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", c, err) @@ -1744,6 +2135,80 @@ func (c *ChatResponseMessage) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ChatTokenLogProbabilityInfo. +func (c ChatTokenLogProbabilityInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "bytes", c.Bytes) + populate(objectMap, "logprob", c.Logprob) + populate(objectMap, "token", c.Token) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ChatTokenLogProbabilityInfo. +func (c *ChatTokenLogProbabilityInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "bytes": + err = unpopulate(val, "Bytes", &c.Bytes) + delete(rawMsg, key) + case "logprob": + err = unpopulate(val, "Logprob", &c.Logprob) + delete(rawMsg, key) + case "token": + err = unpopulate(val, "Token", &c.Token) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ChatTokenLogProbabilityResult. +func (c ChatTokenLogProbabilityResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "bytes", c.Bytes) + populate(objectMap, "logprob", c.Logprob) + populate(objectMap, "token", c.Token) + populate(objectMap, "top_logprobs", c.TopLogProbs) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ChatTokenLogProbabilityResult. +func (c *ChatTokenLogProbabilityResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "bytes": + err = unpopulate(val, "Bytes", &c.Bytes) + delete(rawMsg, key) + case "logprob": + err = unpopulate(val, "Logprob", &c.Logprob) + delete(rawMsg, key) + case "token": + err = unpopulate(val, "Token", &c.Token) + delete(rawMsg, key) + case "top_logprobs": + err = unpopulate(val, "TopLogProbs", &c.TopLogProbs) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type Choice. func (c Choice) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1914,16 +2379,17 @@ func (c *CompletionsLogProbabilityModel) UnmarshalJSON(data []byte) error { func (c CompletionsOptions) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "best_of", c.BestOf) - populate(objectMap, "model", c.DeploymentName) populate(objectMap, "echo", c.Echo) populate(objectMap, "frequency_penalty", c.FrequencyPenalty) populate(objectMap, "logit_bias", c.LogitBias) populate(objectMap, "logprobs", c.LogProbs) populate(objectMap, "max_tokens", c.MaxTokens) + populate(objectMap, "model", c.DeploymentName) populate(objectMap, "n", c.N) populate(objectMap, "presence_penalty", c.PresencePenalty) populate(objectMap, "prompt", c.Prompt) populate(objectMap, "stop", c.Stop) + populate(objectMap, "suffix", c.Suffix) populate(objectMap, "temperature", c.Temperature) populate(objectMap, "top_p", c.TopP) populate(objectMap, "user", c.User) @@ -1942,9 +2408,6 @@ func (c *CompletionsOptions) UnmarshalJSON(data []byte) error { case "best_of": err = unpopulate(val, "BestOf", &c.BestOf) delete(rawMsg, key) - case "model": - err = unpopulate(val, "DeploymentName", &c.DeploymentName) - delete(rawMsg, key) case "echo": err = unpopulate(val, "Echo", &c.Echo) delete(rawMsg, key) @@ -1960,6 +2423,9 @@ func (c *CompletionsOptions) UnmarshalJSON(data []byte) error { case "max_tokens": err = unpopulate(val, "MaxTokens", &c.MaxTokens) delete(rawMsg, key) + case "model": + err = unpopulate(val, "Model", &c.DeploymentName) + delete(rawMsg, key) case "n": err = unpopulate(val, "N", &c.N) delete(rawMsg, key) @@ -1972,6 +2438,9 @@ func (c *CompletionsOptions) UnmarshalJSON(data []byte) error { case "stop": err = unpopulate(val, "Stop", &c.Stop) delete(rawMsg, key) + case "suffix": + err = unpopulate(val, "Suffix", &c.Suffix) + delete(rawMsg, key) case "temperature": err = unpopulate(val, "Temperature", &c.Temperature) delete(rawMsg, key) @@ -2336,15 +2805,15 @@ func (e *ElasticsearchChatExtensionConfiguration) UnmarshalJSON(data []byte) err func (e ElasticsearchChatExtensionParameters) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "authentication", e.Authentication) - populate(objectMap, "embeddingDependency", e.EmbeddingDependency) + populate(objectMap, "embedding_dependency", e.EmbeddingDependency) populate(objectMap, "endpoint", e.Endpoint) - populate(objectMap, "fieldsMapping", e.FieldsMapping) - populate(objectMap, "inScope", e.InScope) - populate(objectMap, "indexName", e.IndexName) - populate(objectMap, "queryType", e.QueryType) - populate(objectMap, "roleInformation", e.RoleInformation) + populate(objectMap, "fields_mapping", e.FieldsMapping) + populate(objectMap, "in_scope", e.InScope) + populate(objectMap, "index_name", e.IndexName) + populate(objectMap, "query_type", e.QueryType) + populate(objectMap, "role_information", e.RoleInformation) populate(objectMap, "strictness", e.Strictness) - populate(objectMap, "topNDocuments", e.TopNDocuments) + populate(objectMap, "top_n_documents", e.TopNDocuments) return json.Marshal(objectMap) } @@ -2360,31 +2829,31 @@ func (e *ElasticsearchChatExtensionParameters) UnmarshalJSON(data []byte) error case "authentication": e.Authentication, err = unmarshalOnYourDataAuthenticationOptionsClassification(val) delete(rawMsg, key) - case "embeddingDependency": + case "embedding_dependency": e.EmbeddingDependency, err = unmarshalOnYourDataVectorizationSourceClassification(val) delete(rawMsg, key) case "endpoint": err = unpopulate(val, "Endpoint", &e.Endpoint) delete(rawMsg, key) - case "fieldsMapping": + case "fields_mapping": err = unpopulate(val, "FieldsMapping", &e.FieldsMapping) delete(rawMsg, key) - case "inScope": + case "in_scope": err = unpopulate(val, "InScope", &e.InScope) delete(rawMsg, key) - case "indexName": + case "index_name": err = unpopulate(val, "IndexName", &e.IndexName) delete(rawMsg, key) - case "queryType": + case "query_type": err = unpopulate(val, "QueryType", &e.QueryType) delete(rawMsg, key) - case "roleInformation": + case "role_information": err = unpopulate(val, "RoleInformation", &e.RoleInformation) delete(rawMsg, key) case "strictness": err = unpopulate(val, "Strictness", &e.Strictness) delete(rawMsg, key) - case "topNDocuments": + case "top_n_documents": err = unpopulate(val, "TopNDocuments", &e.TopNDocuments) delete(rawMsg, key) } @@ -2398,12 +2867,12 @@ func (e *ElasticsearchChatExtensionParameters) UnmarshalJSON(data []byte) error // MarshalJSON implements the json.Marshaller interface for type ElasticsearchIndexFieldMappingOptions. func (e ElasticsearchIndexFieldMappingOptions) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "contentFields", e.ContentFields) - populate(objectMap, "contentFieldsSeparator", e.ContentFieldsSeparator) - populate(objectMap, "filepathField", e.FilepathField) - populate(objectMap, "titleField", e.TitleField) - populate(objectMap, "urlField", e.URLField) - populate(objectMap, "vectorFields", e.VectorFields) + populate(objectMap, "content_fields", e.ContentFields) + populate(objectMap, "content_fields_separator", e.ContentFieldsSeparator) + populate(objectMap, "filepath_field", e.FilepathField) + populate(objectMap, "title_field", e.TitleField) + populate(objectMap, "url_field", e.URLField) + populate(objectMap, "vector_fields", e.VectorFields) return json.Marshal(objectMap) } @@ -2416,22 +2885,22 @@ func (e *ElasticsearchIndexFieldMappingOptions) UnmarshalJSON(data []byte) error for key, val := range rawMsg { var err error switch key { - case "contentFields": + case "content_fields": err = unpopulate(val, "ContentFields", &e.ContentFields) delete(rawMsg, key) - case "contentFieldsSeparator": + case "content_fields_separator": err = unpopulate(val, "ContentFieldsSeparator", &e.ContentFieldsSeparator) delete(rawMsg, key) - case "filepathField": + case "filepath_field": err = unpopulate(val, "FilepathField", &e.FilepathField) delete(rawMsg, key) - case "titleField": + case "title_field": err = unpopulate(val, "TitleField", &e.TitleField) delete(rawMsg, key) - case "urlField": + case "url_field": err = unpopulate(val, "URLField", &e.URLField) delete(rawMsg, key) - case "vectorFields": + case "vector_fields": err = unpopulate(val, "VectorFields", &e.VectorFields) delete(rawMsg, key) } @@ -2507,8 +2976,9 @@ func (e *Embeddings) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type EmbeddingsOptions. func (e EmbeddingsOptions) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "model", e.DeploymentName) populate(objectMap, "input", e.Input) + populate(objectMap, "input_type", e.InputType) + populate(objectMap, "model", e.DeploymentName) populate(objectMap, "user", e.User) return json.Marshal(objectMap) } @@ -2522,12 +2992,15 @@ func (e *EmbeddingsOptions) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "model": - err = unpopulate(val, "DeploymentName", &e.DeploymentName) - delete(rawMsg, key) case "input": err = unpopulate(val, "Input", &e.Input) delete(rawMsg, key) + case "input_type": + err = unpopulate(val, "InputType", &e.InputType) + delete(rawMsg, key) + case "model": + err = unpopulate(val, "Model", &e.DeploymentName) + delete(rawMsg, key) case "user": err = unpopulate(val, "User", &e.User) delete(rawMsg, key) @@ -2667,10 +3140,78 @@ func (f *FunctionDefinition) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type FunctionName. +func (f FunctionName) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", f.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FunctionName. +func (f *FunctionName) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &f.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ImageGenerationContentFilterResults. +func (i ImageGenerationContentFilterResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "hate", i.Hate) + populate(objectMap, "self_harm", i.SelfHarm) + populate(objectMap, "sexual", i.Sexual) + populate(objectMap, "violence", i.Violence) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ImageGenerationContentFilterResults. +func (i *ImageGenerationContentFilterResults) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "hate": + err = unpopulate(val, "Hate", &i.Hate) + delete(rawMsg, key) + case "self_harm": + err = unpopulate(val, "SelfHarm", &i.SelfHarm) + delete(rawMsg, key) + case "sexual": + err = unpopulate(val, "Sexual", &i.Sexual) + delete(rawMsg, key) + case "violence": + err = unpopulate(val, "Violence", &i.Violence) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type ImageGenerationData. func (i ImageGenerationData) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "b64_json", i.Base64Data) + populate(objectMap, "content_filter_results", i.ContentFilterResults) + populate(objectMap, "prompt_filter_results", i.PromptFilterResults) populate(objectMap, "revised_prompt", i.RevisedPrompt) populate(objectMap, "url", i.URL) return json.Marshal(objectMap) @@ -2688,6 +3229,14 @@ func (i *ImageGenerationData) UnmarshalJSON(data []byte) error { case "b64_json": err = unpopulate(val, "Base64Data", &i.Base64Data) delete(rawMsg, key) + case "content_filter_results": + err = unpopulate(val, "ContentFilterResults", &i.ContentFilterResults) + delete(rawMsg, key) + case "prompt_annotations": + fallthrough + case "prompt_filter_results": + err = unpopulate(val, "PromptFilterResults", &i.PromptFilterResults) + delete(rawMsg, key) case "revised_prompt": err = unpopulate(val, "RevisedPrompt", &i.RevisedPrompt) delete(rawMsg, key) @@ -2726,7 +3275,7 @@ func (i *ImageGenerationOptions) UnmarshalJSON(data []byte) error { var err error switch key { case "model": - err = unpopulate(val, "DeploymentName", &i.DeploymentName) + err = unpopulate(val, "Model", &i.DeploymentName) delete(rawMsg, key) case "n": err = unpopulate(val, "N", &i.N) @@ -2757,6 +3306,53 @@ func (i *ImageGenerationOptions) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ImageGenerationPromptFilterResults. +func (i ImageGenerationPromptFilterResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "hate", i.Hate) + populate(objectMap, "jailbreak", i.Jailbreak) + populate(objectMap, "profanity", i.Profanity) + populate(objectMap, "self_harm", i.SelfHarm) + populate(objectMap, "sexual", i.Sexual) + populate(objectMap, "violence", i.Violence) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ImageGenerationPromptFilterResults. +func (i *ImageGenerationPromptFilterResults) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "hate": + err = unpopulate(val, "Hate", &i.Hate) + delete(rawMsg, key) + case "jailbreak": + err = unpopulate(val, "Jailbreak", &i.Jailbreak) + delete(rawMsg, key) + case "profanity": + err = unpopulate(val, "Profanity", &i.Profanity) + delete(rawMsg, key) + case "self_harm": + err = unpopulate(val, "SelfHarm", &i.SelfHarm) + delete(rawMsg, key) + case "sexual": + err = unpopulate(val, "Sexual", &i.Sexual) + delete(rawMsg, key) + case "violence": + err = unpopulate(val, "Violence", &i.Violence) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type ImageGenerations. func (i ImageGenerations) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -2846,6 +3442,37 @@ func (o *OnYourDataAPIKeyAuthenticationOptions) UnmarshalJSON(data []byte) error return nil } +// MarshalJSON implements the json.Marshaller interface for type OnYourDataAccessTokenAuthenticationOptions. +func (o OnYourDataAccessTokenAuthenticationOptions) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "access_token", o.AccessToken) + objectMap["type"] = OnYourDataAuthenticationTypeAccessToken + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OnYourDataAccessTokenAuthenticationOptions. +func (o *OnYourDataAccessTokenAuthenticationOptions) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "access_token": + err = unpopulate(val, "AccessToken", &o.AccessToken) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "configType", &o.configType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type OnYourDataAuthenticationOptions. func (o OnYourDataAuthenticationOptions) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -2876,7 +3503,7 @@ func (o *OnYourDataAuthenticationOptions) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OnYourDataConnectionStringAuthenticationOptions. func (o OnYourDataConnectionStringAuthenticationOptions) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "connectionString", o.ConnectionString) + populate(objectMap, "connection_string", o.ConnectionString) objectMap["type"] = OnYourDataAuthenticationTypeConnectionString return json.Marshal(objectMap) } @@ -2890,7 +3517,7 @@ func (o *OnYourDataConnectionStringAuthenticationOptions) UnmarshalJSON(data []b for key, val := range rawMsg { var err error switch key { - case "connectionString": + case "connection_string": err = unpopulate(val, "ConnectionString", &o.ConnectionString) delete(rawMsg, key) case "type": @@ -2907,7 +3534,7 @@ func (o *OnYourDataConnectionStringAuthenticationOptions) UnmarshalJSON(data []b // MarshalJSON implements the json.Marshaller interface for type OnYourDataDeploymentNameVectorizationSource. func (o OnYourDataDeploymentNameVectorizationSource) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "deploymentName", o.DeploymentName) + populate(objectMap, "deployment_name", o.DeploymentName) objectMap["type"] = OnYourDataVectorizationSourceTypeDeploymentName return json.Marshal(objectMap) } @@ -2921,7 +3548,7 @@ func (o *OnYourDataDeploymentNameVectorizationSource) UnmarshalJSON(data []byte) for key, val := range rawMsg { var err error switch key { - case "deploymentName": + case "deployment_name": err = unpopulate(val, "DeploymentName", &o.DeploymentName) delete(rawMsg, key) case "type": @@ -2935,6 +3562,37 @@ func (o *OnYourDataDeploymentNameVectorizationSource) UnmarshalJSON(data []byte) return nil } +// MarshalJSON implements the json.Marshaller interface for type OnYourDataEncodedAPIKeyAuthenticationOptions. +func (o OnYourDataEncodedAPIKeyAuthenticationOptions) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "encoded_api_key", o.EncodedAPIKey) + objectMap["type"] = OnYourDataAuthenticationTypeEncodedAPIKey + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OnYourDataEncodedAPIKeyAuthenticationOptions. +func (o *OnYourDataEncodedAPIKeyAuthenticationOptions) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "encoded_api_key": + err = unpopulate(val, "EncodedAPIKey", &o.EncodedAPIKey) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "configType", &o.configType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type OnYourDataEndpointVectorizationSource. func (o OnYourDataEndpointVectorizationSource) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -2975,7 +3633,7 @@ func (o OnYourDataKeyAndKeyIDAuthenticationOptions) MarshalJSON() ([]byte, error objectMap := make(map[string]any) objectMap["type"] = OnYourDataAuthenticationTypeKeyAndKeyID populate(objectMap, "key", o.Key) - populate(objectMap, "keyId", o.KeyID) + populate(objectMap, "key_id", o.KeyID) return json.Marshal(objectMap) } @@ -2994,7 +3652,7 @@ func (o *OnYourDataKeyAndKeyIDAuthenticationOptions) UnmarshalJSON(data []byte) case "key": err = unpopulate(val, "Key", &o.Key) delete(rawMsg, key) - case "keyId": + case "key_id": err = unpopulate(val, "KeyID", &o.KeyID) delete(rawMsg, key) } @@ -3008,7 +3666,7 @@ func (o *OnYourDataKeyAndKeyIDAuthenticationOptions) UnmarshalJSON(data []byte) // MarshalJSON implements the json.Marshaller interface for type OnYourDataModelIDVectorizationSource. func (o OnYourDataModelIDVectorizationSource) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "modelId", o.ModelID) + populate(objectMap, "model_id", o.ModelID) objectMap["type"] = OnYourDataVectorizationSourceTypeModelID return json.Marshal(objectMap) } @@ -3022,7 +3680,7 @@ func (o *OnYourDataModelIDVectorizationSource) UnmarshalJSON(data []byte) error for key, val := range rawMsg { var err error switch key { - case "modelId": + case "model_id": err = unpopulate(val, "ModelID", &o.ModelID) delete(rawMsg, key) case "type": @@ -3067,7 +3725,7 @@ func (o *OnYourDataSystemAssignedManagedIdentityAuthenticationOptions) Unmarshal func (o OnYourDataUserAssignedManagedIdentityAuthenticationOptions) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) objectMap["type"] = OnYourDataAuthenticationTypeUserAssignedManagedIdentity - populate(objectMap, "managedIdentityResourceId", o.ManagedIdentityResourceID) + populate(objectMap, "managed_identity_resource_id", o.ManagedIdentityResourceID) return json.Marshal(objectMap) } @@ -3083,7 +3741,7 @@ func (o *OnYourDataUserAssignedManagedIdentityAuthenticationOptions) UnmarshalJS case "type": err = unpopulate(val, "configType", &o.configType) delete(rawMsg, key) - case "managedIdentityResourceId": + case "managed_identity_resource_id": err = unpopulate(val, "ManagedIdentityResourceID", &o.ManagedIdentityResourceID) delete(rawMsg, key) } @@ -3156,14 +3814,14 @@ func (p *PineconeChatExtensionConfiguration) UnmarshalJSON(data []byte) error { func (p PineconeChatExtensionParameters) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "authentication", p.Authentication) - populate(objectMap, "embeddingDependency", p.EmbeddingDependency) + populate(objectMap, "embedding_dependency", p.EmbeddingDependency) populate(objectMap, "environment", p.Environment) - populate(objectMap, "fieldsMapping", p.FieldsMapping) - populate(objectMap, "inScope", p.InScope) - populate(objectMap, "indexName", p.IndexName) - populate(objectMap, "roleInformation", p.RoleInformation) + populate(objectMap, "fields_mapping", p.FieldsMapping) + populate(objectMap, "in_scope", p.InScope) + populate(objectMap, "index_name", p.IndexName) + populate(objectMap, "role_information", p.RoleInformation) populate(objectMap, "strictness", p.Strictness) - populate(objectMap, "topNDocuments", p.TopNDocuments) + populate(objectMap, "top_n_documents", p.TopNDocuments) return json.Marshal(objectMap) } @@ -3179,28 +3837,28 @@ func (p *PineconeChatExtensionParameters) UnmarshalJSON(data []byte) error { case "authentication": p.Authentication, err = unmarshalOnYourDataAuthenticationOptionsClassification(val) delete(rawMsg, key) - case "embeddingDependency": + case "embedding_dependency": p.EmbeddingDependency, err = unmarshalOnYourDataVectorizationSourceClassification(val) delete(rawMsg, key) case "environment": err = unpopulate(val, "Environment", &p.Environment) delete(rawMsg, key) - case "fieldsMapping": + case "fields_mapping": err = unpopulate(val, "FieldsMapping", &p.FieldsMapping) delete(rawMsg, key) - case "inScope": + case "in_scope": err = unpopulate(val, "InScope", &p.InScope) delete(rawMsg, key) - case "indexName": + case "index_name": err = unpopulate(val, "IndexName", &p.IndexName) delete(rawMsg, key) - case "roleInformation": + case "role_information": err = unpopulate(val, "RoleInformation", &p.RoleInformation) delete(rawMsg, key) case "strictness": err = unpopulate(val, "Strictness", &p.Strictness) delete(rawMsg, key) - case "topNDocuments": + case "top_n_documents": err = unpopulate(val, "TopNDocuments", &p.TopNDocuments) delete(rawMsg, key) } @@ -3214,13 +3872,11 @@ func (p *PineconeChatExtensionParameters) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PineconeFieldMappingOptions. func (p PineconeFieldMappingOptions) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "contentFields", p.ContentFields) - populate(objectMap, "contentFieldsSeparator", p.ContentFieldsSeparator) - populate(objectMap, "filepathField", p.FilepathField) - populate(objectMap, "imageVectorFields", p.ImageVectorFields) - populate(objectMap, "titleField", p.TitleField) - populate(objectMap, "urlField", p.URLField) - populate(objectMap, "vectorFields", p.VectorFields) + populate(objectMap, "content_fields", p.ContentFields) + populate(objectMap, "content_fields_separator", p.ContentFieldsSeparator) + populate(objectMap, "filepath_field", p.FilepathField) + populate(objectMap, "title_field", p.TitleField) + populate(objectMap, "url_field", p.URLField) return json.Marshal(objectMap) } @@ -3233,27 +3889,21 @@ func (p *PineconeFieldMappingOptions) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "contentFields": + case "content_fields": err = unpopulate(val, "ContentFields", &p.ContentFields) delete(rawMsg, key) - case "contentFieldsSeparator": + case "content_fields_separator": err = unpopulate(val, "ContentFieldsSeparator", &p.ContentFieldsSeparator) delete(rawMsg, key) - case "filepathField": + case "filepath_field": err = unpopulate(val, "FilepathField", &p.FilepathField) delete(rawMsg, key) - case "imageVectorFields": - err = unpopulate(val, "ImageVectorFields", &p.ImageVectorFields) - delete(rawMsg, key) - case "titleField": + case "title_field": err = unpopulate(val, "TitleField", &p.TitleField) delete(rawMsg, key) - case "urlField": + case "url_field": err = unpopulate(val, "URLField", &p.URLField) delete(rawMsg, key) - case "vectorFields": - err = unpopulate(val, "VectorFields", &p.VectorFields) - delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", p, err) @@ -3262,6 +3912,80 @@ func (p *PineconeFieldMappingOptions) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type SpeechGenerationOptions. +func (s SpeechGenerationOptions) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "input", s.Input) + populate(objectMap, "model", s.DeploymentName) + populate(objectMap, "response_format", s.ResponseFormat) + populate(objectMap, "speed", s.Speed) + populate(objectMap, "voice", s.Voice) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SpeechGenerationOptions. +func (s *SpeechGenerationOptions) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "input": + err = unpopulate(val, "Input", &s.Input) + delete(rawMsg, key) + case "model": + err = unpopulate(val, "Model", &s.DeploymentName) + delete(rawMsg, key) + case "response_format": + err = unpopulate(val, "ResponseFormat", &s.ResponseFormat) + delete(rawMsg, key) + case "speed": + err = unpopulate(val, "Speed", &s.Speed) + delete(rawMsg, key) + case "voice": + err = unpopulate(val, "Voice", &s.Voice) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SpeechGenerationResponse. +func (s SpeechGenerationResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateByteArray(objectMap, "audio", s.Audio, func() any { + return runtime.EncodeByteArray(s.Audio, runtime.Base64StdFormat) + }) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SpeechGenerationResponse. +func (s *SpeechGenerationResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "audio": + if val != nil && string(val) != "null" { + err = runtime.DecodeByteArray(string(val), &s.Audio, runtime.Base64StdFormat) + } + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type StopFinishDetails. func (s StopFinishDetails) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -3313,18 +4037,18 @@ func populateAny(m map[string]any, k string, v any) { } } -func populateByteArray(m map[string]any, k string, b []byte, f runtime.Base64Encoding) { +func populateByteArray[T any](m map[string]any, k string, b []T, convert func() any) { if azcore.IsNullValue(b) { m[k] = nil } else if len(b) == 0 { return } else { - m[k] = runtime.EncodeByteArray(b, f) + m[k] = convert() } } func unpopulate(data json.RawMessage, fn string, v any) error { - if data == nil { + if data == nil || string(data) == "null" { return nil } if err := json.Unmarshal(data, v); err != nil { diff --git a/sdk/ai/azopenai/options.go b/sdk/ai/azopenai/options.go index 6ae2902cb8b1..5774bd76a88e 100644 --- a/sdk/ai/azopenai/options.go +++ b/sdk/ai/azopenai/options.go @@ -8,9 +8,8 @@ package azopenai -// GetAudioTranscriptionAsPlainTextOptions contains the optional parameters for the Client.GetAudioTranscriptionAsPlainText -// method. -type GetAudioTranscriptionAsPlainTextOptions struct { +// GenerateSpeechFromTextOptions contains the optional parameters for the Client.GenerateSpeechFromText method. +type GenerateSpeechFromTextOptions struct { // placeholder for future optional parameters } @@ -26,7 +25,7 @@ type getAudioTranscriptionInternalOptions struct { Language *string // The model to use for this transcription request. - Model *string + DeploymentName *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. @@ -41,19 +40,13 @@ type getAudioTranscriptionInternalOptions struct { Temperature *float32 } -// GetAudioTranslationAsPlainTextOptions contains the optional parameters for the Client.GetAudioTranslationAsPlainText -// method. -type GetAudioTranslationAsPlainTextOptions struct { - // placeholder for future optional parameters -} - // getAudioTranslationInternalOptions contains the optional parameters for the Client.getAudioTranslationInternal method. type getAudioTranslationInternalOptions struct { // The optional filename or descriptive identifier to associate with with the audio data. Filename *string // The model to use for this translation request. - Model *string + DeploymentName *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. @@ -73,12 +66,6 @@ type GetChatCompletionsOptions struct { // placeholder for future optional parameters } -// GetChatCompletionsWithAzureExtensionsOptions contains the optional parameters for the Client.GetChatCompletionsWithAzureExtensions -// method. -type GetChatCompletionsWithAzureExtensionsOptions struct { - // placeholder for future optional parameters -} - // GetCompletionsOptions contains the optional parameters for the Client.GetCompletions method. type GetCompletionsOptions struct { // placeholder for future optional parameters diff --git a/sdk/ai/azopenai/polymorphic_helpers.go b/sdk/ai/azopenai/polymorphic_helpers.go index ce97f0faef93..880df1b2115a 100644 --- a/sdk/ai/azopenai/polymorphic_helpers.go +++ b/sdk/ai/azopenai/polymorphic_helpers.go @@ -11,7 +11,7 @@ package azopenai import "encoding/json" func unmarshalAzureChatExtensionConfigurationClassification(rawMsg json.RawMessage) (AzureChatExtensionConfigurationClassification, error) { - if rawMsg == nil { + if rawMsg == nil || string(rawMsg) == "null" { return nil, nil } var m map[string]any @@ -20,12 +20,12 @@ func unmarshalAzureChatExtensionConfigurationClassification(rawMsg json.RawMessa } var b AzureChatExtensionConfigurationClassification switch m["type"] { - case string(AzureChatExtensionTypeAzureCognitiveSearch): - b = &AzureCognitiveSearchChatExtensionConfiguration{} case string(AzureChatExtensionTypeAzureCosmosDB): b = &AzureCosmosDBChatExtensionConfiguration{} case string(AzureChatExtensionTypeAzureMachineLearningIndex): b = &AzureMachineLearningIndexChatExtensionConfiguration{} + case string(AzureChatExtensionTypeAzureSearch): + b = &AzureSearchChatExtensionConfiguration{} case string(AzureChatExtensionTypeElasticsearch): b = &ElasticsearchChatExtensionConfiguration{} case string(AzureChatExtensionTypePinecone): @@ -40,7 +40,7 @@ func unmarshalAzureChatExtensionConfigurationClassification(rawMsg json.RawMessa } func unmarshalAzureChatExtensionConfigurationClassificationArray(rawMsg json.RawMessage) ([]AzureChatExtensionConfigurationClassification, error) { - if rawMsg == nil { + if rawMsg == nil || string(rawMsg) == "null" { return nil, nil } var rawMessages []json.RawMessage @@ -59,7 +59,7 @@ func unmarshalAzureChatExtensionConfigurationClassificationArray(rawMsg json.Raw } func unmarshalChatCompletionsResponseFormatClassification(rawMsg json.RawMessage) (ChatCompletionsResponseFormatClassification, error) { - if rawMsg == nil { + if rawMsg == nil || string(rawMsg) == "null" { return nil, nil } var m map[string]any @@ -82,7 +82,7 @@ func unmarshalChatCompletionsResponseFormatClassification(rawMsg json.RawMessage } func unmarshalChatCompletionsToolCallClassification(rawMsg json.RawMessage) (ChatCompletionsToolCallClassification, error) { - if rawMsg == nil { + if rawMsg == nil || string(rawMsg) == "null" { return nil, nil } var m map[string]any @@ -108,7 +108,7 @@ func unmarshalChatCompletionsToolCallClassification(rawMsg json.RawMessage) (Cha } func unmarshalChatCompletionsToolCallClassificationArray(rawMsg json.RawMessage) ([]ChatCompletionsToolCallClassification, error) { - if rawMsg == nil { + if rawMsg == nil || string(rawMsg) == "null" { return nil, nil } var rawMessages []json.RawMessage @@ -127,7 +127,7 @@ func unmarshalChatCompletionsToolCallClassificationArray(rawMsg json.RawMessage) } func unmarshalChatCompletionsToolDefinitionClassification(rawMsg json.RawMessage) (ChatCompletionsToolDefinitionClassification, error) { - if rawMsg == nil { + if rawMsg == nil || string(rawMsg) == "null" { return nil, nil } var m map[string]any @@ -148,7 +148,7 @@ func unmarshalChatCompletionsToolDefinitionClassification(rawMsg json.RawMessage } func unmarshalChatCompletionsToolDefinitionClassificationArray(rawMsg json.RawMessage) ([]ChatCompletionsToolDefinitionClassification, error) { - if rawMsg == nil { + if rawMsg == nil || string(rawMsg) == "null" { return nil, nil } var rawMessages []json.RawMessage @@ -167,7 +167,7 @@ func unmarshalChatCompletionsToolDefinitionClassificationArray(rawMsg json.RawMe } func unmarshalChatFinishDetailsClassification(rawMsg json.RawMessage) (ChatFinishDetailsClassification, error) { - if rawMsg == nil { + if rawMsg == nil || string(rawMsg) == "null" { return nil, nil } var m map[string]any @@ -190,7 +190,7 @@ func unmarshalChatFinishDetailsClassification(rawMsg json.RawMessage) (ChatFinis } func unmarshalChatRequestMessageClassification(rawMsg json.RawMessage) (ChatRequestMessageClassification, error) { - if rawMsg == nil { + if rawMsg == nil || string(rawMsg) == "null" { return nil, nil } var m map[string]any @@ -201,6 +201,8 @@ func unmarshalChatRequestMessageClassification(rawMsg json.RawMessage) (ChatRequ switch m["role"] { case string(ChatRoleAssistant): b = &ChatRequestAssistantMessage{} + case string(ChatRoleFunction): + b = &ChatRequestFunctionMessage{} case string(ChatRoleSystem): b = &ChatRequestSystemMessage{} case string(ChatRoleTool): @@ -217,7 +219,7 @@ func unmarshalChatRequestMessageClassification(rawMsg json.RawMessage) (ChatRequ } func unmarshalChatRequestMessageClassificationArray(rawMsg json.RawMessage) ([]ChatRequestMessageClassification, error) { - if rawMsg == nil { + if rawMsg == nil || string(rawMsg) == "null" { return nil, nil } var rawMessages []json.RawMessage @@ -236,7 +238,7 @@ func unmarshalChatRequestMessageClassificationArray(rawMsg json.RawMessage) ([]C } func unmarshalOnYourDataAuthenticationOptionsClassification(rawMsg json.RawMessage) (OnYourDataAuthenticationOptionsClassification, error) { - if rawMsg == nil { + if rawMsg == nil || string(rawMsg) == "null" { return nil, nil } var m map[string]any @@ -245,10 +247,14 @@ func unmarshalOnYourDataAuthenticationOptionsClassification(rawMsg json.RawMessa } var b OnYourDataAuthenticationOptionsClassification switch m["type"] { + case string(OnYourDataAuthenticationTypeAccessToken): + b = &OnYourDataAccessTokenAuthenticationOptions{} case string(OnYourDataAuthenticationTypeAPIKey): b = &OnYourDataAPIKeyAuthenticationOptions{} case string(OnYourDataAuthenticationTypeConnectionString): b = &OnYourDataConnectionStringAuthenticationOptions{} + case string(OnYourDataAuthenticationTypeEncodedAPIKey): + b = &OnYourDataEncodedAPIKeyAuthenticationOptions{} case string(OnYourDataAuthenticationTypeKeyAndKeyID): b = &OnYourDataKeyAndKeyIDAuthenticationOptions{} case string(OnYourDataAuthenticationTypeSystemAssignedManagedIdentity): @@ -265,7 +271,7 @@ func unmarshalOnYourDataAuthenticationOptionsClassification(rawMsg json.RawMessa } func unmarshalOnYourDataVectorizationSourceClassification(rawMsg json.RawMessage) (OnYourDataVectorizationSourceClassification, error) { - if rawMsg == nil { + if rawMsg == nil || string(rawMsg) == "null" { return nil, nil } var m map[string]any diff --git a/sdk/ai/azopenai/response_types.go b/sdk/ai/azopenai/responses.go similarity index 73% rename from sdk/ai/azopenai/response_types.go rename to sdk/ai/azopenai/responses.go index b79526aad61e..1715b29d2e4e 100644 --- a/sdk/ai/azopenai/response_types.go +++ b/sdk/ai/azopenai/responses.go @@ -8,9 +8,12 @@ package azopenai -// GetAudioTranscriptionAsPlainTextResponse contains the response from method Client.GetAudioTranscriptionAsPlainText. -type GetAudioTranscriptionAsPlainTextResponse struct { - Value *string +import "io" + +// GenerateSpeechFromTextResponse contains the response from method Client.GenerateSpeechFromText. +type GenerateSpeechFromTextResponse struct { + // Body contains the streaming response. + Body io.ReadCloser } // getAudioTranscriptionInternalResponse contains the response from method Client.getAudioTranscriptionInternal. @@ -19,11 +22,6 @@ type getAudioTranscriptionInternalResponse struct { AudioTranscription } -// GetAudioTranslationAsPlainTextResponse contains the response from method Client.GetAudioTranslationAsPlainText. -type GetAudioTranslationAsPlainTextResponse struct { - Value *string -} - // getAudioTranslationInternalResponse contains the response from method Client.getAudioTranslationInternal. type getAudioTranslationInternalResponse struct { // Result information for an operation that translated spoken audio into written text. @@ -38,14 +36,6 @@ type GetChatCompletionsResponse struct { ChatCompletions } -// GetChatCompletionsWithAzureExtensionsResponse contains the response from method Client.GetChatCompletionsWithAzureExtensions. -type GetChatCompletionsWithAzureExtensionsResponse struct { - // Representation of the response data from a chat completions request. - // Completions support a wide variety of tasks and generate text that continues from or "completes" - // provided prompt data. - ChatCompletions -} - // GetCompletionsResponse contains the response from method Client.GetCompletions. type GetCompletionsResponse struct { // Representation of the response data from a completions request. diff --git a/sdk/ai/azopenai/genopenapi3.ps1 b/sdk/ai/azopenai/testdata/genopenapi.ps1 similarity index 67% rename from sdk/ai/azopenai/genopenapi3.ps1 rename to sdk/ai/azopenai/testdata/genopenapi.ps1 index 4d3aca353bb0..d328ad410a89 100644 --- a/sdk/ai/azopenai/genopenapi3.ps1 +++ b/sdk/ai/azopenai/testdata/genopenapi.ps1 @@ -1,4 +1,9 @@ Push-Location ./testdata + +if (Test-Path -Path "TempTypeSpecFiles") { + Remove-Item -Recurse -Force TempTypeSpecFiles +} + npm install if ($LASTEXITCODE -ne 0) { diff --git a/sdk/ai/azopenai/testdata/package-lock.json b/sdk/ai/azopenai/testdata/package-lock.json index 6e2d706005fe..2f25d27143ce 100644 --- a/sdk/ai/azopenai/testdata/package-lock.json +++ b/sdk/ai/azopenai/testdata/package-lock.json @@ -8,47 +8,67 @@ "name": "testdata", "version": "0.1.0", "dependencies": { - "@azure-tools/typespec-autorest": "0.34.0", - "@azure-tools/typespec-azure-core": "0.34.0", - "@typespec/compiler": "0.48.0", - "@typespec/openapi3": "0.48.0" + "@azure-tools/typespec-autorest": "0.39.2", + "@azure-tools/typespec-azure-core": "0.39.1", + "@typespec/compiler": "~0.53.1", + "@typespec/openapi3": "~0.53.1" } }, "node_modules/@azure-tools/typespec-autorest": { - "version": "0.34.0", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-autorest/-/typespec-autorest-0.34.0.tgz", - "integrity": "sha512-Fr5obMJzBgVzeK7pKblUKx1o7+p+KT84C1n+yRqqMP1Rqkq7y09iW3Mj3GO0xgs9DR8yMalBgHhvWWvB9l4yDA==", + "version": "0.39.2", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-autorest/-/typespec-autorest-0.39.2.tgz", + "integrity": "sha512-sdYbYKv6uIktMqX573buyMoLiJMTCwk17DN/CeX0NPtmSx1SXLPh9stQFg2H/IMgVS8VmTlVeCYoSKR7krjsGg==", "engines": { - "node": ">=16.0.0" + "node": ">=18.0.0" }, "peerDependencies": { - "@azure-tools/typespec-azure-core": "~0.34.0", - "@typespec/compiler": "~0.48.0", - "@typespec/http": "~0.48.0", - "@typespec/openapi": "~0.48.0", - "@typespec/rest": "~0.48.0", - "@typespec/versioning": "~0.48.0" + "@azure-tools/typespec-azure-core": "~0.39.1", + "@azure-tools/typespec-client-generator-core": "~0.39.0", + "@typespec/compiler": "~0.53.1", + "@typespec/http": "~0.53.0", + "@typespec/openapi": "~0.53.0", + "@typespec/rest": "~0.53.0", + "@typespec/versioning": "~0.53.0" } }, "node_modules/@azure-tools/typespec-azure-core": { - "version": "0.34.0", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-core/-/typespec-azure-core-0.34.0.tgz", - "integrity": "sha512-n3WrIx8bAHsknYXivbhl8WO+uzdB6RZMtx27/vnD+Jpo2krxLm0mMJK6pz2m/npTV4qlbY05OIeokhWQrneypw==", + "version": "0.39.1", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-core/-/typespec-azure-core-0.39.1.tgz", + "integrity": "sha512-b1cN1HXTcEiKIRpk2EatFK/C4NReDaW2h4N3V4C5dxGeeLAnTa1jsQ6lwobH6Zo39CdrjazNXiSbcEq1UZ7kPw==", "engines": { - "node": ">=16.0.0" + "node": ">=18.0.0" }, "peerDependencies": { - "@typespec/compiler": "~0.48.0", - "@typespec/http": "~0.48.0", - "@typespec/rest": "~0.48.0" + "@typespec/compiler": "~0.53.1", + "@typespec/http": "~0.53.0", + "@typespec/rest": "~0.53.0" + } + }, + "node_modules/@azure-tools/typespec-client-generator-core": { + "version": "0.39.1", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-client-generator-core/-/typespec-client-generator-core-0.39.1.tgz", + "integrity": "sha512-EV3N6IN1i/hXGqYKNfXx6+2QAyZnG4IpC9RUk6fqwSQDWX7HtMcfdXqlOaK3Rz2H6BUAc9OnH+Trq/uJCl/RgA==", + "peer": true, + "dependencies": { + "change-case": "~5.3.0", + "pluralize": "^8.0.0" + }, + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@typespec/compiler": "~0.53.1", + "@typespec/http": "~0.53.0", + "@typespec/rest": "~0.53.0", + "@typespec/versioning": "~0.53.0" } }, "node_modules/@babel/code-frame": { - "version": "7.22.13", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.13.tgz", - "integrity": "sha512-XktuhWlJ5g+3TJXc5upd9Ks1HutSArik6jf2eAjYFyIOf4ej3RN+184cZbzDvbPnuTJIUhPKKJE3cIsYTiAT3w==", + "version": "7.23.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.23.5.tgz", + "integrity": "sha512-CgH3s1a96LipHCmSUmYFPwY7MNx8C3avkq7i4Wl3cfa662ldtUe4VM1TPXX70pfmrlWTb6jLqTYrZyT2ZTJBgA==", "dependencies": { - "@babel/highlight": "^7.22.13", + "@babel/highlight": "^7.23.4", "chalk": "^2.4.2" }, "engines": { @@ -56,19 +76,19 @@ } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.22.15", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.15.tgz", - "integrity": "sha512-4E/F9IIEi8WR94324mbDUMo074YTheJmd7eZF5vITTeYchqAi6sYXRLHUVsmkdmY4QjfKTcB2jB7dVP3NaBElQ==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", + "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/highlight": { - "version": "7.22.13", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.13.tgz", - "integrity": "sha512-C/BaXcnnvBCmHTpz/VGZ8jgtE2aYlW4hxDhseJAWZb7gqGM/qtCK6iZUb0TyKFf7BOUsBH7Q7fkRsDRhg1XklQ==", + "version": "7.23.4", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.23.4.tgz", + "integrity": "sha512-acGdbYSfp2WheJoJm/EBBBLh/ID8KDc64ISZ9DYtBmC8/Q204PZJLHyzeB5qMzJ5trcOkybd78M4x2KWsUq++A==", "dependencies": { - "@babel/helper-validator-identifier": "^7.22.5", + "@babel/helper-validator-identifier": "^7.22.20", "chalk": "^2.4.2", "js-tokens": "^4.0.0" }, @@ -108,99 +128,109 @@ "node": ">= 8" } }, + "node_modules/@sindresorhus/merge-streams": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/merge-streams/-/merge-streams-2.3.0.tgz", + "integrity": "sha512-LtoMMhxAlorcGhmFYI+LhPgbPZCkgP6ra1YL604EeF6U98pLlQ3iWIGMdWSC+vWmPBWBNgmDBAhnAobLROJmwg==", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/@typespec/compiler": { - "version": "0.48.0", - "resolved": "https://registry.npmjs.org/@typespec/compiler/-/compiler-0.48.0.tgz", - "integrity": "sha512-+BEeSLl7unxtRpC1L8sbTu5A94WIVQaYSFf0egkJ0panN0wWzcFbk4SJiSa9wxjDTr9fh2elSrRVk2t1XTk2nQ==", + "version": "0.53.1", + "resolved": "https://registry.npmjs.org/@typespec/compiler/-/compiler-0.53.1.tgz", + "integrity": "sha512-qneMDvZsLaL8+3PXzwXMAqgE4YtkUPPBg4oXrbreYa5NTccuvgVaO4cfya/SzG4WePUnmDTbbrP5aWd+VzYwYA==", "dependencies": { - "@babel/code-frame": "~7.22.5", + "@babel/code-frame": "~7.23.5", "ajv": "~8.12.0", - "change-case": "~4.1.2", - "globby": "~13.1.1", + "change-case": "~5.3.0", + "globby": "~14.0.0", "mustache": "~4.2.0", "picocolors": "~1.0.0", - "prettier": "~3.0.1", - "prompts": "~2.4.1", - "semver": "^7.3.8", - "vscode-languageserver": "~8.1.0", - "vscode-languageserver-textdocument": "~1.0.1", - "yaml": "~2.3.1", - "yargs": "~17.7.1" + "prettier": "~3.1.1", + "prompts": "~2.4.2", + "semver": "^7.5.4", + "vscode-languageserver": "~9.0.0", + "vscode-languageserver-textdocument": "~1.0.8", + "yaml": "~2.3.4", + "yargs": "~17.7.2" }, "bin": { "tsp": "cmd/tsp.js", "tsp-server": "cmd/tsp-server.js" }, "engines": { - "node": ">=16.0.0" + "node": ">=18.0.0" } }, "node_modules/@typespec/http": { - "version": "0.48.0", - "resolved": "https://registry.npmjs.org/@typespec/http/-/http-0.48.0.tgz", - "integrity": "sha512-e+0Y0Ky71flUNZSRzCfoOm8XvXsSYGmQgB9VZFDbLl8mQlXwuTfib4tWrU531TCtZHMnylbXx2wAk5+3uC6b9g==", + "version": "0.53.0", + "resolved": "https://registry.npmjs.org/@typespec/http/-/http-0.53.0.tgz", + "integrity": "sha512-Hdwbxr6KgzmJdULbbcwWaSSrWlduuMuEVUVdlytxyo9K+aoUCcPl0thR5Ez2VRh02/IJl3xG4n5wXgOwWb3amA==", "peer": true, "engines": { - "node": ">=16.0.0" + "node": ">=18.0.0" }, "peerDependencies": { - "@typespec/compiler": "~0.48.0" + "@typespec/compiler": "~0.53.0" } }, "node_modules/@typespec/openapi": { - "version": "0.48.0", - "resolved": "https://registry.npmjs.org/@typespec/openapi/-/openapi-0.48.0.tgz", - "integrity": "sha512-KptMNQd/+olEetmNGend6jhMjnFa+Lrhw/M+HCP46HcKH/NDVA/RWtX/KcT4KjxJYrmTlRF9sz19/Efg7u02CA==", + "version": "0.53.0", + "resolved": "https://registry.npmjs.org/@typespec/openapi/-/openapi-0.53.0.tgz", + "integrity": "sha512-FRHb6Wi4Yf1HGm3EnhhXZ0Bw+EIPam6ptxRy7NDRxyMnzHsOphGcv8mDIZk6MPSy8xPasbFNwaRC1TXpxVhQBw==", "peer": true, "engines": { - "node": ">=16.0.0" + "node": ">=18.0.0" }, "peerDependencies": { - "@typespec/compiler": "~0.48.0", - "@typespec/http": "~0.48.0", - "@typespec/rest": "~0.48.0" + "@typespec/compiler": "~0.53.0", + "@typespec/http": "~0.53.0" } }, "node_modules/@typespec/openapi3": { - "version": "0.48.0", - "resolved": "https://registry.npmjs.org/@typespec/openapi3/-/openapi3-0.48.0.tgz", - "integrity": "sha512-2ZiAvN4/LLS8Lt+tju3wKSNeDD8eTXNCaTxHw61jGVvPiCtU7E/HyF+eA2pMlfXAtjlEzpbuQb+rF3eaex1qUA==", + "version": "0.53.2", + "resolved": "https://registry.npmjs.org/@typespec/openapi3/-/openapi3-0.53.2.tgz", + "integrity": "sha512-8uwU3iJbt+WN3WlT9VzC7DN8rzB727zr8BMwZ81XN1/sX8dOJB49F5UiK0L+ychvx15RZ96CvYPCFmmnsOeyCQ==", "dependencies": { - "yaml": "~2.3.1" + "yaml": "~2.3.4" }, "engines": { - "node": ">=16.0.0" + "node": ">=18.0.0" }, "peerDependencies": { - "@typespec/compiler": "~0.48.0", - "@typespec/http": "~0.48.0", - "@typespec/openapi": "~0.48.0", - "@typespec/rest": "~0.48.0", - "@typespec/versioning": "~0.48.0" + "@typespec/compiler": "~0.53.1", + "@typespec/http": "~0.53.0", + "@typespec/openapi": "~0.53.0", + "@typespec/versioning": "~0.53.0" } }, "node_modules/@typespec/rest": { - "version": "0.48.0", - "resolved": "https://registry.npmjs.org/@typespec/rest/-/rest-0.48.0.tgz", - "integrity": "sha512-PM41o2a7qsTi6OIiCE53OB5uh+GTas8YObJjV5Z9JHYtHhQKVQaRHE72qoZQp3919vJNStXTdDEbIjzMIVt3Ow==", + "version": "0.53.0", + "resolved": "https://registry.npmjs.org/@typespec/rest/-/rest-0.53.0.tgz", + "integrity": "sha512-aA75Ol2pRvUjtRqQvFHmFG52pkeif3m+tboLAT00AekTxOPZ3rqQmlE12ne4QF8KjgHA6denqH4f/XyDoRJOJQ==", "peer": true, "engines": { - "node": ">=16.0.0" + "node": ">=18.0.0" }, "peerDependencies": { - "@typespec/compiler": "~0.48.0" + "@typespec/compiler": "~0.53.0", + "@typespec/http": "~0.53.0" } }, "node_modules/@typespec/versioning": { - "version": "0.48.0", - "resolved": "https://registry.npmjs.org/@typespec/versioning/-/versioning-0.48.0.tgz", - "integrity": "sha512-WF26vmMPwizhSnjX0ox23nbp7hthtB4cN/J5w1tlryXyp/BXySHoYsJEMK7fviSpj4WdreVXdM6wmRIG33zqig==", + "version": "0.53.0", + "resolved": "https://registry.npmjs.org/@typespec/versioning/-/versioning-0.53.0.tgz", + "integrity": "sha512-nrrLXCWPDrrClAfpCMzQ3YPTbKQmjPC3LSeMjq+wPiMq+1PW95ulOGD4QiCBop+4wKhMCJHnqqSzVauT1LjdvQ==", "peer": true, "engines": { - "node": ">=16.0.0" + "node": ">=18.0.0" }, "peerDependencies": { - "@typespec/compiler": "~0.48.0" + "@typespec/compiler": "~0.53.0" } }, "node_modules/ajv": { @@ -248,25 +278,6 @@ "node": ">=8" } }, - "node_modules/camel-case": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/camel-case/-/camel-case-4.1.2.tgz", - "integrity": "sha512-gxGWBrTT1JuMx6R+o5PTXMmUnhnVzLQ9SNutD4YqKtI6ap897t3tKECYla6gCWEkplXnlNybEkZg9GEGxKFCgw==", - "dependencies": { - "pascal-case": "^3.1.2", - "tslib": "^2.0.3" - } - }, - "node_modules/capital-case": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/capital-case/-/capital-case-1.0.4.tgz", - "integrity": "sha512-ds37W8CytHgwnhGGTi88pcPyR15qoNkOpYwmMMfnWqqWgESapLqvDx6huFjQ5vqWSn2Z06173XNA7LtMOeUh1A==", - "dependencies": { - "no-case": "^3.0.4", - "tslib": "^2.0.3", - "upper-case-first": "^2.0.2" - } - }, "node_modules/chalk": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", @@ -281,23 +292,9 @@ } }, "node_modules/change-case": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/change-case/-/change-case-4.1.2.tgz", - "integrity": "sha512-bSxY2ws9OtviILG1EiY5K7NNxkqg/JnRnFxLtKQ96JaviiIxi7djMrSd0ECT9AC+lttClmYwKw53BWpOMblo7A==", - "dependencies": { - "camel-case": "^4.1.2", - "capital-case": "^1.0.4", - "constant-case": "^3.0.4", - "dot-case": "^3.0.4", - "header-case": "^2.0.4", - "no-case": "^3.0.4", - "param-case": "^3.0.4", - "pascal-case": "^3.1.2", - "path-case": "^3.0.4", - "sentence-case": "^3.0.4", - "snake-case": "^3.0.4", - "tslib": "^2.0.3" - } + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/change-case/-/change-case-5.3.0.tgz", + "integrity": "sha512-Eykca0fGS/xYlx2fG5NqnGSnsWauhSGiSXYhB1kO6E909GUfo8S54u4UZNS7lMJmgZumZ2SUpWaoLgAcfQRICg==" }, "node_modules/cliui": { "version": "8.0.1", @@ -325,36 +322,6 @@ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==" }, - "node_modules/constant-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/constant-case/-/constant-case-3.0.4.tgz", - "integrity": "sha512-I2hSBi7Vvs7BEuJDr5dDHfzb/Ruj3FyvFyh7KLilAjNQw3Be+xgqUBA2W6scVEcL0hL1dwPRtIqEPVUCKkSsyQ==", - "dependencies": { - "no-case": "^3.0.4", - "tslib": "^2.0.3", - "upper-case": "^2.0.2" - } - }, - "node_modules/dir-glob": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", - "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", - "dependencies": { - "path-type": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/dot-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz", - "integrity": "sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==", - "dependencies": { - "no-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, "node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", @@ -382,9 +349,9 @@ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" }, "node_modules/fast-glob": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz", - "integrity": "sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", + "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", @@ -397,9 +364,9 @@ } }, "node_modules/fastq": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz", - "integrity": "sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==", + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz", + "integrity": "sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==", "dependencies": { "reusify": "^1.0.4" } @@ -435,18 +402,19 @@ } }, "node_modules/globby": { - "version": "13.1.4", - "resolved": "https://registry.npmjs.org/globby/-/globby-13.1.4.tgz", - "integrity": "sha512-iui/IiiW+QrJ1X1hKH5qwlMQyv34wJAYwH1vrf8b9kBA4sNiif3gKsMHa+BrdnOpEudWjpotfa7LrTzB1ERS/g==", + "version": "14.0.1", + "resolved": "https://registry.npmjs.org/globby/-/globby-14.0.1.tgz", + "integrity": "sha512-jOMLD2Z7MAhyG8aJpNOpmziMOP4rPLcc95oQPKXBazW82z+CEgPFBQvEpRUa1KeIMUJo4Wsm+q6uzO/Q/4BksQ==", "dependencies": { - "dir-glob": "^3.0.1", - "fast-glob": "^3.2.11", - "ignore": "^5.2.0", - "merge2": "^1.4.1", - "slash": "^4.0.0" + "@sindresorhus/merge-streams": "^2.1.0", + "fast-glob": "^3.3.2", + "ignore": "^5.2.4", + "path-type": "^5.0.0", + "slash": "^5.1.0", + "unicorn-magic": "^0.1.0" }, "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -460,19 +428,10 @@ "node": ">=4" } }, - "node_modules/header-case": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/header-case/-/header-case-2.0.4.tgz", - "integrity": "sha512-H/vuk5TEEVZwrR0lp2zed9OCo1uAILMlx0JEMgC26rzyJJ3N1v6XkwHHXJQdR2doSjcGPM6OKPYoJgf0plJ11Q==", - "dependencies": { - "capital-case": "^1.0.4", - "tslib": "^2.0.3" - } - }, "node_modules/ignore": { - "version": "5.2.4", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", - "integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==", + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.1.tgz", + "integrity": "sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==", "engines": { "node": ">= 4" } @@ -530,14 +489,6 @@ "node": ">=6" } }, - "node_modules/lower-case": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz", - "integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==", - "dependencies": { - "tslib": "^2.0.3" - } - }, "node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -577,48 +528,15 @@ "mustache": "bin/mustache" } }, - "node_modules/no-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz", - "integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==", - "dependencies": { - "lower-case": "^2.0.2", - "tslib": "^2.0.3" - } - }, - "node_modules/param-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/param-case/-/param-case-3.0.4.tgz", - "integrity": "sha512-RXlj7zCYokReqWpOPH9oYivUzLYZ5vAPIfEmCTNViosC78F8F0H9y7T7gG2M39ymgutxF5gcFEsyZQSph9Bp3A==", - "dependencies": { - "dot-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, - "node_modules/pascal-case": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/pascal-case/-/pascal-case-3.1.2.tgz", - "integrity": "sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==", - "dependencies": { - "no-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, - "node_modules/path-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/path-case/-/path-case-3.0.4.tgz", - "integrity": "sha512-qO4qCFjXqVTrcbPt/hQfhTQ+VhFsqNKOPtytgNKkKxSoEp3XPUQ8ObFuePylOIok5gjn69ry8XiULxCwot3Wfg==", - "dependencies": { - "dot-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, "node_modules/path-type": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", - "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-5.0.0.tgz", + "integrity": "sha512-5HviZNaZcfqP95rwpv+1HDgUamezbqdSYTyzjTvwtJSnIH+3vnbmWsItli8OFEndS984VT55M3jduxZbX351gg==", "engines": { - "node": ">=8" + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/picocolors": { @@ -637,10 +555,19 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/pluralize": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-8.0.0.tgz", + "integrity": "sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==", + "peer": true, + "engines": { + "node": ">=4" + } + }, "node_modules/prettier": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.3.tgz", - "integrity": "sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.1.1.tgz", + "integrity": "sha512-22UbSzg8luF4UuZtzgiUOfcGM8s4tjBv6dJRT7j275NXsy2jb4aJa4NNveul5x4eqlF1wuhuR2RElK71RvmVaw==", "bin": { "prettier": "bin/prettier.cjs" }, @@ -751,41 +678,22 @@ "node": ">=10" } }, - "node_modules/sentence-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/sentence-case/-/sentence-case-3.0.4.tgz", - "integrity": "sha512-8LS0JInaQMCRoQ7YUytAo/xUu5W2XnQxV2HI/6uM6U7CITS1RqPElr30V6uIqyMKM9lJGRVFy5/4CuzcixNYSg==", - "dependencies": { - "no-case": "^3.0.4", - "tslib": "^2.0.3", - "upper-case-first": "^2.0.2" - } - }, "node_modules/sisteransi": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==" }, "node_modules/slash": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz", - "integrity": "sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-5.1.0.tgz", + "integrity": "sha512-ZA6oR3T/pEyuqwMgAKT0/hAv8oAXckzbkmR0UkUosQ+Mc4RxGoJkRmwHgHufaenlyAgE1Mxgpdcrf75y6XcnDg==", "engines": { - "node": ">=12" + "node": ">=14.16" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/snake-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/snake-case/-/snake-case-3.0.4.tgz", - "integrity": "sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg==", - "dependencies": { - "dot-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, "node_modules/string-width": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", @@ -832,25 +740,15 @@ "node": ">=8.0" } }, - "node_modules/tslib": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", - "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" - }, - "node_modules/upper-case": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/upper-case/-/upper-case-2.0.2.tgz", - "integrity": "sha512-KgdgDGJt2TpuwBUIjgG6lzw2GWFRCW9Qkfkiv0DxqHHLYJHmtmdUIKcZd8rHgFSjopVTlw6ggzCm1b8MFQwikg==", - "dependencies": { - "tslib": "^2.0.3" - } - }, - "node_modules/upper-case-first": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/upper-case-first/-/upper-case-first-2.0.2.tgz", - "integrity": "sha512-514ppYHBaKwfJRK/pNC6c/OxfGa0obSnAl106u97Ed0I625Nin96KAjttZF6ZL3e1XLtphxnqrOi9iWgm+u+bg==", - "dependencies": { - "tslib": "^2.0.3" + "node_modules/unicorn-magic": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/unicorn-magic/-/unicorn-magic-0.1.0.tgz", + "integrity": "sha512-lRfVq8fE8gz6QMBuDM6a+LO3IAzTi05H6gCVaUpir2E1Rwpo4ZUog45KpNXKC/Mn3Yb9UDuHumeFTo9iV/D9FQ==", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/uri-js": { @@ -862,31 +760,31 @@ } }, "node_modules/vscode-jsonrpc": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.1.0.tgz", - "integrity": "sha512-6TDy/abTQk+zDGYazgbIPc+4JoXdwC8NHU9Pbn4UJP1fehUyZmM4RHp5IthX7A6L5KS30PRui+j+tbbMMMafdw==", + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.2.0.tgz", + "integrity": "sha512-C+r0eKJUIfiDIfwJhria30+TYWPtuHJXHtI7J0YlOmKAo7ogxP20T0zxB7HZQIFhIyvoBPwWskjxrvAtfjyZfA==", "engines": { "node": ">=14.0.0" } }, "node_modules/vscode-languageserver": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-8.1.0.tgz", - "integrity": "sha512-eUt8f1z2N2IEUDBsKaNapkz7jl5QpskN2Y0G01T/ItMxBxw1fJwvtySGB9QMecatne8jFIWJGWI61dWjyTLQsw==", + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-9.0.1.tgz", + "integrity": "sha512-woByF3PDpkHFUreUa7Hos7+pUWdeWMXRd26+ZX2A8cFx6v/JPTtd4/uN0/jB6XQHYaOlHbio03NTHCqrgG5n7g==", "dependencies": { - "vscode-languageserver-protocol": "3.17.3" + "vscode-languageserver-protocol": "3.17.5" }, "bin": { "installServerIntoExtension": "bin/installServerIntoExtension" } }, "node_modules/vscode-languageserver-protocol": { - "version": "3.17.3", - "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.3.tgz", - "integrity": "sha512-924/h0AqsMtA5yK22GgMtCYiMdCOtWTSGgUOkgEDX+wk2b0x4sAfLiO4NxBxqbiVtz7K7/1/RgVrVI0NClZwqA==", + "version": "3.17.5", + "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.5.tgz", + "integrity": "sha512-mb1bvRJN8SVznADSGWM9u/b07H7Ecg0I3OgXDuLdn307rl/J3A9YD6/eYOssqhecL27hK1IPZAsaqh00i/Jljg==", "dependencies": { - "vscode-jsonrpc": "8.1.0", - "vscode-languageserver-types": "3.17.3" + "vscode-jsonrpc": "8.2.0", + "vscode-languageserver-types": "3.17.5" } }, "node_modules/vscode-languageserver-textdocument": { @@ -895,9 +793,9 @@ "integrity": "sha512-1bonkGqQs5/fxGT5UchTgjGVnfysL0O8v1AYMBjqTbWQTFn721zaPGDYFkOKtfDgFiSgXM3KwaG3FMGfW4Ed9Q==" }, "node_modules/vscode-languageserver-types": { - "version": "3.17.3", - "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.3.tgz", - "integrity": "sha512-SYU4z1dL0PyIMd4Vj8YOqFvHu7Hz/enbWtpfnVbJHU4Nd1YNYx8u0ennumc6h48GQNeOLxmwySmnADouT/AuZA==" + "version": "3.17.5", + "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.5.tgz", + "integrity": "sha512-Ld1VelNuX9pdF39h2Hgaeb5hEZM2Z3jUrrMgWQAu82jMtZp7p3vJT3BzToKtZI7NgQssZje5o0zryOrhQvzQAg==" }, "node_modules/wrap-ansi": { "version": "7.0.0", @@ -959,9 +857,9 @@ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" }, "node_modules/yaml": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.2.tgz", - "integrity": "sha512-N/lyzTPaJasoDmfV7YTrYCI0G/3ivm/9wdG0aHuheKowWQwGTsK0Eoiw6utmzAnI6pkJa0DUVygvp3spqqEKXg==", + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.4.tgz", + "integrity": "sha512-8aAvwVUSHpfEqTQ4w/KMlf3HcRdt50E5ODIQJBw1fQ5RL34xabzxtUlzTXVqc4rkZsPbvrXKWnABCD7kWSmocA==", "engines": { "node": ">= 14" } diff --git a/sdk/ai/azopenai/testdata/package.json b/sdk/ai/azopenai/testdata/package.json index d40aa8a7d787..f654d18538fb 100644 --- a/sdk/ai/azopenai/testdata/package.json +++ b/sdk/ai/azopenai/testdata/package.json @@ -7,10 +7,10 @@ "build": "tsp compile ./TempTypeSpecFiles/OpenAI.Inference" }, "dependencies": { - "@azure-tools/typespec-autorest": "0.34.0", - "@azure-tools/typespec-azure-core": "0.34.0", - "@typespec/compiler": "0.48.0", - "@typespec/openapi3": "0.48.0" + "@azure-tools/typespec-autorest": "0.39.2", + "@azure-tools/typespec-azure-core": "0.39.1", + "@typespec/compiler": "~0.53.1", + "@typespec/openapi3": "~0.53.1" }, "private": true } diff --git a/sdk/ai/azopenai/testdata/tsp-location.yaml b/sdk/ai/azopenai/testdata/tsp-location.yaml index bbba798eeef7..7096283ed080 100644 --- a/sdk/ai/azopenai/testdata/tsp-location.yaml +++ b/sdk/ai/azopenai/testdata/tsp-location.yaml @@ -1,4 +1,3 @@ -#location: https://github.com/Azure/azure-rest-api-specs/tree/1393b6e34d7370733e3e2236c4df686280a96f36/specification/cognitiveservices/OpenAI.Inference directory: specification/cognitiveservices/OpenAI.Inference -commit: 1d8c41300b9125c544799363022a6788b3e67544 +commit: ea14e94556d26c36830a6c1ff058f71cb00da567 repo: Azure/azure-rest-api-specs diff --git a/sdk/ai/azopenai/testdata/tspconfig.yaml b/sdk/ai/azopenai/testdata/tspconfig.yaml index 8abb60e25a59..351fc693da8a 100644 --- a/sdk/ai/azopenai/testdata/tspconfig.yaml +++ b/sdk/ai/azopenai/testdata/tspconfig.yaml @@ -4,8 +4,8 @@ parameters: "dependencies": default: "" emit: - - "@typespec/openapi3" + - "@azure-tools/typespec-autorest" options: - "@typespec/openapi3": + "@azure-tools/typespec-autorest": emitter-output-dir: "{project-root}/generated" - output-file: "openapi3.json" + output-file: "openapi.json" diff --git a/sdk/ai/azopenai/time_unix.go b/sdk/ai/azopenai/time_unix.go index a07a9be4bae1..33a90a81ba42 100644 --- a/sdk/ai/azopenai/time_unix.go +++ b/sdk/ai/azopenai/time_unix.go @@ -12,7 +12,6 @@ import ( "encoding/json" "fmt" "reflect" - "strings" "time" "github.com/Azure/azure-sdk-for-go/sdk/azcore" @@ -50,7 +49,7 @@ func populateTimeUnix(m map[string]any, k string, t *time.Time) { } func unpopulateTimeUnix(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { + if data == nil || string(data) == "null" { return nil } var aux timeUnix diff --git a/sdk/ai/azopenai/version.go b/sdk/ai/azopenai/version.go index 3f09eece9564..1d676be5a3c2 100644 --- a/sdk/ai/azopenai/version.go +++ b/sdk/ai/azopenai/version.go @@ -7,5 +7,5 @@ package azopenai const ( - version = "v0.4.1" + version = "v0.5.0" )