diff --git a/sdk/ai/azopenai/CHANGELOG.md b/sdk/ai/azopenai/CHANGELOG.md index 08a790aa9982..4cfb7fe91743 100644 --- a/sdk/ai/azopenai/CHANGELOG.md +++ b/sdk/ai/azopenai/CHANGELOG.md @@ -1,6 +1,6 @@ # Release History -## 0.3.0 (2023-09-25) +## 0.3.0 (2023-09-26) ### Features Added - Support for Whisper audio APIs for transcription and translation using `GetAudioTranscription` and `GetAudioTranslation`. diff --git a/sdk/ai/azopenai/autorest.md b/sdk/ai/azopenai/autorest.md index 9ebcfbc58157..00af5456e2d2 100644 --- a/sdk/ai/azopenai/autorest.md +++ b/sdk/ai/azopenai/autorest.md @@ -201,6 +201,17 @@ directive: fix($.AudioTranslationOptions.properties.response_format); fix($.AudioTranslation.properties.task); + + - from: + - options.go + - models_serde.go + - models.go + where: $ + transform: | + return $ + .replace(/AvgLogprob \*float32/g, "AvgLogProb *float32") + .replace(/(a|c)\.AvgLogprob/g, "$1.AvgLogProb") + # # [END] Whisper # @@ -253,10 +264,16 @@ directive: where: $ transform: | return $ - // InnerError is actually a recursive type, no need for this innererrorinnererror type + // remove some types that were generated to support the recursive error. .replace(/\/\/ AzureCoreFoundationsInnerErrorInnererror.+?\n}/s, "") // also, remove its marshalling functions - .replace(/\/\/ (Unmarshal|Marshal)JSON implements[^\n]+?AzureCoreFoundationsInnerErrorInnererror.+?\n}/sg, "") + .replace(/\/\/ (Unmarshal|Marshal)JSON implements[^\n]+?for type AzureCoreFoundationsInnerErrorInnererror.+?\n}/sg, "") + .replace(/\/\/ AzureCoreFoundationsErrorInnererror.+?\n}/s, "") + .replace(/\/\/ (Unmarshal|Marshal)JSON implements[^\n]+?for type AzureCoreFoundationsErrorInnererror.+?\n}/sg, "") + .replace(/\/\/ AzureCoreFoundationsErrorResponseError.+?\n}/s, "") + .replace(/\/\/ (Unmarshal|Marshal)JSON implements[^\n]+?for type AzureCoreFoundationsErrorResponseError.+?\n}/sg, "") + .replace(/\/\/ AzureCoreFoundationsErrorResponse.+?\n}/s, "") + .replace(/\/\/ (Unmarshal|Marshal)JSON implements[^\n]+?for type AzureCoreFoundationsErrorResponse.+?\n}/sg, "") // Remove any references to the type and replace them with InnerError. .replace(/Innererror \*(AzureCoreFoundationsInnerErrorInnererror|AzureCoreFoundationsErrorInnererror)/g, "InnerError *InnerError") diff --git a/sdk/ai/azopenai/models.go b/sdk/ai/azopenai/models.go index 2c1557e73150..ad5ae38e29d9 100644 --- a/sdk/ai/azopenai/models.go +++ b/sdk/ai/azopenai/models.go @@ -61,7 +61,7 @@ type AudioTranscriptionOptions struct { // sentences. type AudioTranscriptionSegment struct { // REQUIRED; The average log probability associated with this audio segment. - AvgLogprob *float32 + AvgLogProb *float32 // REQUIRED; The compression ratio of this audio segment. CompressionRatio *float32 @@ -140,7 +140,7 @@ type AudioTranslationOptions struct { // sentences. type AudioTranslationSegment struct { // REQUIRED; The average log probability associated with this audio segment. - AvgLogprob *float32 + AvgLogProb *float32 // REQUIRED; The compression ratio of this audio segment. CompressionRatio *float32 @@ -298,40 +298,6 @@ type Error struct { Target *string } -// ErrorInnererror - An object containing more specific information than the current object about the -// error. -type ErrorInnererror struct { - // One of a server-defined set of error codes. - Code *string - - // Inner error. - InnerError *InnerError -} - -// ErrorResponse - A response containing error details. -type ErrorResponse struct { - // REQUIRED; The error object. - Error *ErrorResponseError -} - -// ErrorResponseError - The error object. -type ErrorResponseError struct { - // REQUIRED; One of a server-defined set of error codes. - Code *string - - // REQUIRED; A human-readable representation of the error. - Message *string - - // An array of details about specific errors that led to this reported error. - Details []Error - - // An object containing more specific information than the current object about the error. - InnerError *InnerError - - // The target of the error. - Target *string -} - // InnerError - An object containing more specific information about the error. As per Microsoft One API // guidelines - // https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. diff --git a/sdk/ai/azopenai/models_serde.go b/sdk/ai/azopenai/models_serde.go index 8fad187ff4f4..d0edd14b26e5 100644 --- a/sdk/ai/azopenai/models_serde.go +++ b/sdk/ai/azopenai/models_serde.go @@ -110,7 +110,7 @@ func (a *AudioTranscriptionOptions) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AudioTranscriptionSegment. func (a AudioTranscriptionSegment) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "avg_logprob", a.AvgLogprob) + populate(objectMap, "avg_logprob", a.AvgLogProb) populate(objectMap, "compression_ratio", a.CompressionRatio) populate(objectMap, "end", a.End) populate(objectMap, "id", a.ID) @@ -133,7 +133,7 @@ func (a *AudioTranscriptionSegment) UnmarshalJSON(data []byte) error { var err error switch key { case "avg_logprob": - err = unpopulate(val, "AvgLogprob", &a.AvgLogprob) + err = unpopulate(val, "AvgLogprob", &a.AvgLogProb) delete(rawMsg, key) case "compression_ratio": err = unpopulate(val, "CompressionRatio", &a.CompressionRatio) @@ -259,7 +259,7 @@ func (a *AudioTranslationOptions) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AudioTranslationSegment. func (a AudioTranslationSegment) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "avg_logprob", a.AvgLogprob) + populate(objectMap, "avg_logprob", a.AvgLogProb) populate(objectMap, "compression_ratio", a.CompressionRatio) populate(objectMap, "end", a.End) populate(objectMap, "id", a.ID) @@ -282,7 +282,7 @@ func (a *AudioTranslationSegment) UnmarshalJSON(data []byte) error { var err error switch key { case "avg_logprob": - err = unpopulate(val, "AvgLogprob", &a.AvgLogprob) + err = unpopulate(val, "AvgLogprob", &a.AvgLogProb) delete(rawMsg, key) case "compression_ratio": err = unpopulate(val, "CompressionRatio", &a.CompressionRatio) @@ -581,107 +581,6 @@ func (a *Error) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ErrorInnererror. -func (a ErrorInnererror) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "code", a.Code) - populate(objectMap, "innererror", a.InnerError) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorInnererror. -func (a *ErrorInnererror) 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 "code": - err = unpopulate(val, "Code", &a.Code) - delete(rawMsg, key) - case "innererror": - err = unpopulate(val, "Innererror", &a.InnerError) - 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 ErrorResponse. -func (a ErrorResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "error", a.Error) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponse. -func (a *ErrorResponse) 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 "error": - err = unpopulate(val, "Error", &a.Error) - 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 ErrorResponseError. -func (a ErrorResponseError) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "code", a.Code) - populate(objectMap, "details", a.Details) - populate(objectMap, "innererror", a.InnerError) - populate(objectMap, "message", a.Message) - populate(objectMap, "target", a.Target) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponseError. -func (a *ErrorResponseError) 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 "code": - err = unpopulate(val, "Code", &a.Code) - delete(rawMsg, key) - case "details": - err = unpopulate(val, "Details", &a.Details) - delete(rawMsg, key) - case "innererror": - err = unpopulate(val, "Innererror", &a.InnerError) - delete(rawMsg, key) - case "message": - err = unpopulate(val, "Message", &a.Message) - delete(rawMsg, key) - case "target": - err = unpopulate(val, "Target", &a.Target) - 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 InnerError. func (a InnerError) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any)