diff --git a/src/libs/Mistral/Generated/Mistral.AudioTranscriptionsClient.CreateStreamingTranscriptionSse.g.cs b/src/libs/Mistral/Generated/Mistral.AudioTranscriptionsClient.CreateStreamingTranscriptionSse.g.cs index f7e7f82..fc79069 100644 --- a/src/libs/Mistral/Generated/Mistral.AudioTranscriptionsClient.CreateStreamingTranscriptionSse.g.cs +++ b/src/libs/Mistral/Generated/Mistral.AudioTranscriptionsClient.CreateStreamingTranscriptionSse.g.cs @@ -567,512 +567,5 @@ request.Filename is null yield return __response; } } - - /// - /// Create Streaming Transcription (SSE) - /// - /// - /// - /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// Url of a file to be transcribed
- /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// ID of a file uploaded to /v1/files
- /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// Language of the audio, e.g. 'en'. Providing the language can boost accuracy.
- /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// Default Value: true - /// - /// - /// Default Value: false - /// - /// - /// Default Value: [] - /// - /// - /// Granularities of timestamps to include in the response. - /// - /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. - /// The token to cancel the operation with - /// - public async global::System.Collections.Generic.IAsyncEnumerable CreateStreamingTranscriptionSseAsync( - string model, - global::System.IO.Stream? file = default, - string? filename = default, - string? fileUrl = default, - string? fileId = default, - string? language = default, - double? temperature = default, - bool? stream = default, - bool? diarize = default, - global::System.Collections.Generic.IList? contextBias = default, - global::System.Collections.Generic.IList? timestampGranularities = default, - global::Mistral.AutoSDKRequestOptions? requestOptions = default, - [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) - { - - var request = new global::Mistral.AudioTranscriptionRequestStream - { - Model = model, - File = global::System.Array.Empty(), - Filename = filename, - FileUrl = fileUrl, - FileId = fileId, - Language = language, - Temperature = temperature, - Stream = stream, - Diarize = diarize, - ContextBias = contextBias, - TimestampGranularities = timestampGranularities, - }; - PrepareArguments( - client: HttpClient); - PrepareCreateStreamingTranscriptionSseArguments( - httpClient: HttpClient, - request: request); - - - var __authorizations = global::Mistral.EndPointSecurityResolver.ResolveAuthorizations( - availableAuthorizations: Authorizations, - securityRequirements: s_CreateStreamingTranscriptionSseSecurityRequirements, - operationName: "CreateStreamingTranscriptionSseAsync"); - - using var __timeoutCancellationTokenSource = global::Mistral.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( - clientOptions: Options, - requestOptions: requestOptions, - cancellationToken: cancellationToken); - var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; - var __effectiveReadResponseAsString = global::Mistral.AutoSDKRequestOptionsSupport.GetReadResponseAsString( - clientOptions: Options, - requestOptions: requestOptions, - fallbackValue: ReadResponseAsString); - var __maxAttempts = global::Mistral.AutoSDKRequestOptionsSupport.GetMaxAttempts( - clientOptions: Options, - requestOptions: requestOptions, - supportsRetry: false); - - global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() - { - - var __pathBuilder = new global::Mistral.PathBuilder( - path: "/v1/audio/transcriptions#stream", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - __path = global::Mistral.AutoSDKRequestOptionsSupport.AppendQueryParameters( - path: __path, - clientParameters: Options.QueryParameters, - requestParameters: requestOptions?.QueryParameters); - var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); -#if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; -#endif - - foreach (var __authorization in __authorizations) - { - if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2" || - __authorization.Type == "OpenIdConnect") - { - __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( - scheme: __authorization.Name, - parameter: __authorization.Value); - } - else if (__authorization.Type == "ApiKey" && - __authorization.Location == "Header") - { - __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } - } - - var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Model ?? string.Empty), - name: "\"model\""); - - if (file != default) - { - - var __contentFile = new global::System.Net.Http.StreamContent(file); - __contentFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( - request.Filename is null - ? "application/octet-stream" - : (global::System.IO.Path.GetExtension(request.Filename) ?? string.Empty).ToLowerInvariant() switch - { - ".aac" => "audio/aac", - ".flac" => "audio/flac", - ".gif" => "image/gif", - ".jpeg" => "image/jpeg", - ".jpg" => "image/jpeg", - ".json" => "application/json", - ".m4a" => "audio/mp4", - ".mp3" => "audio/mpeg", - ".mp4" => "video/mp4", - ".mpeg" => "audio/mpeg", - ".mpga" => "audio/mpeg", - ".oga" => "audio/ogg", - ".ogg" => "audio/ogg", - ".opus" => "audio/ogg", - ".pdf" => "application/pdf", - ".png" => "image/png", - ".txt" => "text/plain", - ".wav" => "audio/wav", - ".weba" => "audio/webm", - ".webm" => "video/webm", - ".webp" => "image/webp", - _ => "application/octet-stream", - }); - __httpRequestContent.Add( - content: __contentFile, - name: "\"file\"", - fileName: request.Filename != null ? $"\"{request.Filename}\"" : string.Empty); - if (__contentFile.Headers.ContentDisposition != null) - { - __contentFile.Headers.ContentDisposition.FileNameStar = null; - } - - } - if (request.FileUrl != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.FileUrl ?? string.Empty), - name: "\"file_url\""); - - } - if (request.FileId != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.FileId ?? string.Empty), - name: "\"file_id\""); - - } - if (request.Language != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Language ?? string.Empty), - name: "\"language\""); - - } - if (request.Temperature != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Temperature, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), - name: "\"temperature\""); - - } - if (request.Stream != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Stream, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), - name: "\"stream\""); - - } - if (request.Diarize != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Diarize, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), - name: "\"diarize\""); - - } - if (request.ContextBias != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.ContextBias, x => x))}]"), - name: "\"context_bias\""); - - } - if (request.TimestampGranularities != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.TimestampGranularities, x => x.ToValueString()))}]"), - name: "\"timestamp_granularities\""); - - } - - __httpRequest.Content = __httpRequestContent; - - global::Mistral.AutoSDKRequestOptionsSupport.ApplyHeaders( - request: __httpRequest, - clientHeaders: Options.Headers, - requestHeaders: requestOptions?.Headers); - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateStreamingTranscriptionSseRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); - - return __httpRequest; - } - - global::System.Net.Http.HttpRequestMessage? __httpRequest = null; - global::System.Net.Http.HttpResponseMessage? __response = null; - var __attemptNumber = 0; - try - { - for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) - { - __attemptNumber = __attempt; - __httpRequest = __CreateHttpRequest(); - await global::Mistral.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( - clientOptions: Options, - context: global::Mistral.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CreateStreamingTranscriptionSse", - methodName: "CreateStreamingTranscriptionSseAsync", - pathTemplate: "\"/v1/audio/transcriptions#stream\"", - httpMethod: "POST", - baseUri: BaseUri, - request: __httpRequest!, - response: null, - exception: null, - clientOptions: Options, - requestOptions: requestOptions, - attempt: __attempt, - maxAttempts: __maxAttempts, - willRetry: false, - retryDelay: null, - retryReason: global::System.String.Empty, - cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); - try - { - __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead, - cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); - } - catch (global::System.Net.Http.HttpRequestException __exception) - { - var __retryDelay = global::Mistral.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: null, - attempt: __attempt); - var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; - await global::Mistral.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Mistral.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CreateStreamingTranscriptionSse", - methodName: "CreateStreamingTranscriptionSseAsync", - pathTemplate: "\"/v1/audio/transcriptions#stream\"", - httpMethod: "POST", - baseUri: BaseUri, - request: __httpRequest!, - response: null, - exception: __exception, - clientOptions: Options, - requestOptions: requestOptions, - attempt: __attempt, - maxAttempts: __maxAttempts, - willRetry: __willRetry, - retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, - retryReason: "exception", - cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); - if (!__willRetry) - { - throw; - } - - __httpRequest.Dispose(); - __httpRequest = null; - await global::Mistral.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - retryDelay: __retryDelay, - cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); - continue; - } - - if (__response != null && - __attempt < __maxAttempts && - global::Mistral.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) - { - var __retryDelay = global::Mistral.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: __response, - attempt: __attempt); - await global::Mistral.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Mistral.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CreateStreamingTranscriptionSse", - methodName: "CreateStreamingTranscriptionSseAsync", - pathTemplate: "\"/v1/audio/transcriptions#stream\"", - httpMethod: "POST", - baseUri: BaseUri, - request: __httpRequest!, - response: __response, - exception: null, - clientOptions: Options, - requestOptions: requestOptions, - attempt: __attempt, - maxAttempts: __maxAttempts, - willRetry: true, - retryDelay: __retryDelay, - retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), - cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); - __response.Dispose(); - __response = null; - __httpRequest.Dispose(); - __httpRequest = null; - await global::Mistral.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - retryDelay: __retryDelay, - cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); - continue; - } - - break; - } - - if (__response == null) - { - throw new global::System.InvalidOperationException("No response received."); - } - - using (__response) - { - - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateStreamingTranscriptionSseResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - if (__response.IsSuccessStatusCode) - { - await global::Mistral.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( - clientOptions: Options, - context: global::Mistral.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CreateStreamingTranscriptionSse", - methodName: "CreateStreamingTranscriptionSseAsync", - pathTemplate: "\"/v1/audio/transcriptions#stream\"", - httpMethod: "POST", - baseUri: BaseUri, - request: __httpRequest!, - response: __response, - exception: null, - clientOptions: Options, - requestOptions: requestOptions, - attempt: __attemptNumber, - maxAttempts: __maxAttempts, - willRetry: false, - retryDelay: null, - retryReason: global::System.String.Empty, - cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); - } - else - { - await global::Mistral.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Mistral.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CreateStreamingTranscriptionSse", - methodName: "CreateStreamingTranscriptionSseAsync", - pathTemplate: "\"/v1/audio/transcriptions#stream\"", - httpMethod: "POST", - baseUri: BaseUri, - request: __httpRequest!, - response: __response, - exception: null, - clientOptions: Options, - requestOptions: requestOptions, - attempt: __attemptNumber, - maxAttempts: __maxAttempts, - willRetry: false, - retryDelay: null, - retryReason: global::System.String.Empty, - cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); - } - - try - { - __response.EnsureSuccessStatusCode(); - } - catch (global::System.Net.Http.HttpRequestException __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( - #if NET5_0_OR_GREATER - __effectiveCancellationToken - #endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } - - throw new global::Mistral.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - using var __stream = await __response.Content.ReadAsStreamAsync( - #if NET5_0_OR_GREATER - __effectiveCancellationToken - #endif - ).ConfigureAwait(false); - - await foreach (var __sseEvent in global::System.Net.ServerSentEvents.SseParser - .Create(__stream).EnumerateAsync(__effectiveCancellationToken)) - { - var __content = __sseEvent.Data; - if (__content == "[DONE]") - { - yield break; - } - - var __streamedResponse = global::Mistral.TranscriptionStreamEvents.FromJson(__content, JsonSerializerContext) ?? - throw new global::Mistral.ApiException( - message: $"Response deserialization failed for \"{__content}\" ", - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - - yield return __streamedResponse; - } - - } - } - finally - { - __httpRequest?.Dispose(); - } - } } } \ No newline at end of file diff --git a/src/libs/Mistral/Generated/Mistral.AudioTranscriptionsClient.CreateTranscription.g.cs b/src/libs/Mistral/Generated/Mistral.AudioTranscriptionsClient.CreateTranscription.g.cs index 1af6a7f..ae015b5 100644 --- a/src/libs/Mistral/Generated/Mistral.AudioTranscriptionsClient.CreateTranscription.g.cs +++ b/src/libs/Mistral/Generated/Mistral.AudioTranscriptionsClient.CreateTranscription.g.cs @@ -621,1074 +621,5 @@ request.Filename is null requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } - - /// - /// Create Transcription - /// - /// - /// ID of the model to be used. - /// - /// - /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// Url of a file to be transcribed
- /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// ID of a file uploaded to /v1/files
- /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// Language of the audio, e.g. 'en'. Providing the language can boost accuracy.
- /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// Default Value: false - /// - /// - /// Default Value: false - /// - /// - /// Default Value: [] - /// - /// - /// Granularities of timestamps to include in the response. - /// - /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. - /// The token to cancel the operation with - /// - public async global::System.Threading.Tasks.Task CreateTranscriptionAsync( - string model, - global::System.IO.Stream? file = default, - string? filename = default, - string? fileUrl = default, - string? fileId = default, - string? language = default, - double? temperature = default, - bool? stream = default, - bool? diarize = default, - global::System.Collections.Generic.IList? contextBias = default, - global::System.Collections.Generic.IList? timestampGranularities = default, - global::Mistral.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default) - { - - var request = new global::Mistral.AudioTranscriptionRequest - { - Model = model, - File = global::System.Array.Empty(), - Filename = filename, - FileUrl = fileUrl, - FileId = fileId, - Language = language, - Temperature = temperature, - Stream = stream, - Diarize = diarize, - ContextBias = contextBias, - TimestampGranularities = timestampGranularities, - }; - PrepareArguments( - client: HttpClient); - PrepareCreateTranscriptionArguments( - httpClient: HttpClient, - request: request); - - - var __authorizations = global::Mistral.EndPointSecurityResolver.ResolveAuthorizations( - availableAuthorizations: Authorizations, - securityRequirements: s_CreateTranscriptionSecurityRequirements, - operationName: "CreateTranscriptionAsync"); - - using var __timeoutCancellationTokenSource = global::Mistral.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( - clientOptions: Options, - requestOptions: requestOptions, - cancellationToken: cancellationToken); - var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; - var __effectiveReadResponseAsString = global::Mistral.AutoSDKRequestOptionsSupport.GetReadResponseAsString( - clientOptions: Options, - requestOptions: requestOptions, - fallbackValue: ReadResponseAsString); - var __maxAttempts = global::Mistral.AutoSDKRequestOptionsSupport.GetMaxAttempts( - clientOptions: Options, - requestOptions: requestOptions, - supportsRetry: false); - - global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() - { - - var __pathBuilder = new global::Mistral.PathBuilder( - path: "/v1/audio/transcriptions", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - __path = global::Mistral.AutoSDKRequestOptionsSupport.AppendQueryParameters( - path: __path, - clientParameters: Options.QueryParameters, - requestParameters: requestOptions?.QueryParameters); - var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); -#if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; -#endif - - foreach (var __authorization in __authorizations) - { - if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2" || - __authorization.Type == "OpenIdConnect") - { - __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( - scheme: __authorization.Name, - parameter: __authorization.Value); - } - else if (__authorization.Type == "ApiKey" && - __authorization.Location == "Header") - { - __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } - } - - var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Model ?? string.Empty), - name: "\"model\""); - - if (file != default) - { - - var __contentFile = new global::System.Net.Http.StreamContent(file); - __contentFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( - request.Filename is null - ? "application/octet-stream" - : (global::System.IO.Path.GetExtension(request.Filename) ?? string.Empty).ToLowerInvariant() switch - { - ".aac" => "audio/aac", - ".flac" => "audio/flac", - ".gif" => "image/gif", - ".jpeg" => "image/jpeg", - ".jpg" => "image/jpeg", - ".json" => "application/json", - ".m4a" => "audio/mp4", - ".mp3" => "audio/mpeg", - ".mp4" => "video/mp4", - ".mpeg" => "audio/mpeg", - ".mpga" => "audio/mpeg", - ".oga" => "audio/ogg", - ".ogg" => "audio/ogg", - ".opus" => "audio/ogg", - ".pdf" => "application/pdf", - ".png" => "image/png", - ".txt" => "text/plain", - ".wav" => "audio/wav", - ".weba" => "audio/webm", - ".webm" => "video/webm", - ".webp" => "image/webp", - _ => "application/octet-stream", - }); - __httpRequestContent.Add( - content: __contentFile, - name: "\"file\"", - fileName: request.Filename != null ? $"\"{request.Filename}\"" : string.Empty); - if (__contentFile.Headers.ContentDisposition != null) - { - __contentFile.Headers.ContentDisposition.FileNameStar = null; - } - - } - if (request.FileUrl != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.FileUrl ?? string.Empty), - name: "\"file_url\""); - - } - if (request.FileId != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.FileId ?? string.Empty), - name: "\"file_id\""); - - } - if (request.Language != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Language ?? string.Empty), - name: "\"language\""); - - } - if (request.Temperature != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Temperature, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), - name: "\"temperature\""); - - } - if (request.Stream != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Stream, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), - name: "\"stream\""); - - } - if (request.Diarize != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Diarize, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), - name: "\"diarize\""); - - } - if (request.ContextBias != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.ContextBias, x => x))}]"), - name: "\"context_bias\""); - - } - if (request.TimestampGranularities != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.TimestampGranularities, x => x.ToValueString()))}]"), - name: "\"timestamp_granularities\""); - - } - - __httpRequest.Content = __httpRequestContent; - - global::Mistral.AutoSDKRequestOptionsSupport.ApplyHeaders( - request: __httpRequest, - clientHeaders: Options.Headers, - requestHeaders: requestOptions?.Headers); - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateTranscriptionRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); - - return __httpRequest; - } - - global::System.Net.Http.HttpRequestMessage? __httpRequest = null; - global::System.Net.Http.HttpResponseMessage? __response = null; - var __attemptNumber = 0; - try - { - for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) - { - __attemptNumber = __attempt; - __httpRequest = __CreateHttpRequest(); - await global::Mistral.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( - clientOptions: Options, - context: global::Mistral.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CreateTranscription", - methodName: "CreateTranscriptionAsync", - pathTemplate: "\"/v1/audio/transcriptions\"", - httpMethod: "POST", - baseUri: BaseUri, - request: __httpRequest!, - response: null, - exception: null, - clientOptions: Options, - requestOptions: requestOptions, - attempt: __attempt, - maxAttempts: __maxAttempts, - willRetry: false, - retryDelay: null, - retryReason: global::System.String.Empty, - cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); - try - { - __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); - } - catch (global::System.Net.Http.HttpRequestException __exception) - { - var __retryDelay = global::Mistral.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: null, - attempt: __attempt); - var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; - await global::Mistral.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Mistral.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CreateTranscription", - methodName: "CreateTranscriptionAsync", - pathTemplate: "\"/v1/audio/transcriptions\"", - httpMethod: "POST", - baseUri: BaseUri, - request: __httpRequest!, - response: null, - exception: __exception, - clientOptions: Options, - requestOptions: requestOptions, - attempt: __attempt, - maxAttempts: __maxAttempts, - willRetry: __willRetry, - retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, - retryReason: "exception", - cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); - if (!__willRetry) - { - throw; - } - - __httpRequest.Dispose(); - __httpRequest = null; - await global::Mistral.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - retryDelay: __retryDelay, - cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); - continue; - } - - if (__response != null && - __attempt < __maxAttempts && - global::Mistral.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) - { - var __retryDelay = global::Mistral.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: __response, - attempt: __attempt); - await global::Mistral.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Mistral.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CreateTranscription", - methodName: "CreateTranscriptionAsync", - pathTemplate: "\"/v1/audio/transcriptions\"", - httpMethod: "POST", - baseUri: BaseUri, - request: __httpRequest!, - response: __response, - exception: null, - clientOptions: Options, - requestOptions: requestOptions, - attempt: __attempt, - maxAttempts: __maxAttempts, - willRetry: true, - retryDelay: __retryDelay, - retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), - cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); - __response.Dispose(); - __response = null; - __httpRequest.Dispose(); - __httpRequest = null; - await global::Mistral.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - retryDelay: __retryDelay, - cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); - continue; - } - - break; - } - - if (__response == null) - { - throw new global::System.InvalidOperationException("No response received."); - } - - using (__response) - { - - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateTranscriptionResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - if (__response.IsSuccessStatusCode) - { - await global::Mistral.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( - clientOptions: Options, - context: global::Mistral.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CreateTranscription", - methodName: "CreateTranscriptionAsync", - pathTemplate: "\"/v1/audio/transcriptions\"", - httpMethod: "POST", - baseUri: BaseUri, - request: __httpRequest!, - response: __response, - exception: null, - clientOptions: Options, - requestOptions: requestOptions, - attempt: __attemptNumber, - maxAttempts: __maxAttempts, - willRetry: false, - retryDelay: null, - retryReason: global::System.String.Empty, - cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); - } - else - { - await global::Mistral.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Mistral.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CreateTranscription", - methodName: "CreateTranscriptionAsync", - pathTemplate: "\"/v1/audio/transcriptions\"", - httpMethod: "POST", - baseUri: BaseUri, - request: __httpRequest!, - response: __response, - exception: null, - clientOptions: Options, - requestOptions: requestOptions, - attempt: __attemptNumber, - maxAttempts: __maxAttempts, - willRetry: false, - retryDelay: null, - retryReason: global::System.String.Empty, - cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); - } - - if (__effectiveReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( - #if NET5_0_OR_GREATER - __effectiveCancellationToken - #endif - ).ConfigureAwait(false); - - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessCreateTranscriptionResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try - { - __response.EnsureSuccessStatusCode(); - - return - global::Mistral.TranscriptionResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - } - catch (global::System.Exception __ex) - { - throw new global::Mistral.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( - #if NET5_0_OR_GREATER - __effectiveCancellationToken - #endif - ).ConfigureAwait(false); - - return - await global::Mistral.TranscriptionResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( - #if NET5_0_OR_GREATER - __effectiveCancellationToken - #endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } - - throw new global::Mistral.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - } - - } - } - finally - { - __httpRequest?.Dispose(); - } - } - /// - /// Create Transcription - /// - /// - /// ID of the model to be used. - /// - /// - /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// Url of a file to be transcribed
- /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// ID of a file uploaded to /v1/files
- /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// Language of the audio, e.g. 'en'. Providing the language can boost accuracy.
- /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// Default Value: false - /// - /// - /// Default Value: false - /// - /// - /// Default Value: [] - /// - /// - /// Granularities of timestamps to include in the response. - /// - /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. - /// The token to cancel the operation with - /// - public async global::System.Threading.Tasks.Task> CreateTranscriptionAsResponseAsync( - string model, - global::System.IO.Stream? file = default, - string? filename = default, - string? fileUrl = default, - string? fileId = default, - string? language = default, - double? temperature = default, - bool? stream = default, - bool? diarize = default, - global::System.Collections.Generic.IList? contextBias = default, - global::System.Collections.Generic.IList? timestampGranularities = default, - global::Mistral.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default) - { - - var request = new global::Mistral.AudioTranscriptionRequest - { - Model = model, - File = global::System.Array.Empty(), - Filename = filename, - FileUrl = fileUrl, - FileId = fileId, - Language = language, - Temperature = temperature, - Stream = stream, - Diarize = diarize, - ContextBias = contextBias, - TimestampGranularities = timestampGranularities, - }; - PrepareArguments( - client: HttpClient); - PrepareCreateTranscriptionArguments( - httpClient: HttpClient, - request: request); - - - var __authorizations = global::Mistral.EndPointSecurityResolver.ResolveAuthorizations( - availableAuthorizations: Authorizations, - securityRequirements: s_CreateTranscriptionSecurityRequirements, - operationName: "CreateTranscriptionAsync"); - - using var __timeoutCancellationTokenSource = global::Mistral.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( - clientOptions: Options, - requestOptions: requestOptions, - cancellationToken: cancellationToken); - var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; - var __effectiveReadResponseAsString = global::Mistral.AutoSDKRequestOptionsSupport.GetReadResponseAsString( - clientOptions: Options, - requestOptions: requestOptions, - fallbackValue: ReadResponseAsString); - var __maxAttempts = global::Mistral.AutoSDKRequestOptionsSupport.GetMaxAttempts( - clientOptions: Options, - requestOptions: requestOptions, - supportsRetry: false); - - global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() - { - - var __pathBuilder = new global::Mistral.PathBuilder( - path: "/v1/audio/transcriptions", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - __path = global::Mistral.AutoSDKRequestOptionsSupport.AppendQueryParameters( - path: __path, - clientParameters: Options.QueryParameters, - requestParameters: requestOptions?.QueryParameters); - var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); -#if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; -#endif - - foreach (var __authorization in __authorizations) - { - if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2" || - __authorization.Type == "OpenIdConnect") - { - __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( - scheme: __authorization.Name, - parameter: __authorization.Value); - } - else if (__authorization.Type == "ApiKey" && - __authorization.Location == "Header") - { - __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } - } - - var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Model ?? string.Empty), - name: "\"model\""); - - if (file != default) - { - - var __contentFile = new global::System.Net.Http.StreamContent(file); - __contentFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( - request.Filename is null - ? "application/octet-stream" - : (global::System.IO.Path.GetExtension(request.Filename) ?? string.Empty).ToLowerInvariant() switch - { - ".aac" => "audio/aac", - ".flac" => "audio/flac", - ".gif" => "image/gif", - ".jpeg" => "image/jpeg", - ".jpg" => "image/jpeg", - ".json" => "application/json", - ".m4a" => "audio/mp4", - ".mp3" => "audio/mpeg", - ".mp4" => "video/mp4", - ".mpeg" => "audio/mpeg", - ".mpga" => "audio/mpeg", - ".oga" => "audio/ogg", - ".ogg" => "audio/ogg", - ".opus" => "audio/ogg", - ".pdf" => "application/pdf", - ".png" => "image/png", - ".txt" => "text/plain", - ".wav" => "audio/wav", - ".weba" => "audio/webm", - ".webm" => "video/webm", - ".webp" => "image/webp", - _ => "application/octet-stream", - }); - __httpRequestContent.Add( - content: __contentFile, - name: "\"file\"", - fileName: request.Filename != null ? $"\"{request.Filename}\"" : string.Empty); - if (__contentFile.Headers.ContentDisposition != null) - { - __contentFile.Headers.ContentDisposition.FileNameStar = null; - } - - } - if (request.FileUrl != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.FileUrl ?? string.Empty), - name: "\"file_url\""); - - } - if (request.FileId != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.FileId ?? string.Empty), - name: "\"file_id\""); - - } - if (request.Language != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Language ?? string.Empty), - name: "\"language\""); - - } - if (request.Temperature != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Temperature, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), - name: "\"temperature\""); - - } - if (request.Stream != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Stream, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), - name: "\"stream\""); - - } - if (request.Diarize != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Diarize, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), - name: "\"diarize\""); - - } - if (request.ContextBias != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.ContextBias, x => x))}]"), - name: "\"context_bias\""); - - } - if (request.TimestampGranularities != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.TimestampGranularities, x => x.ToValueString()))}]"), - name: "\"timestamp_granularities\""); - - } - - __httpRequest.Content = __httpRequestContent; - - global::Mistral.AutoSDKRequestOptionsSupport.ApplyHeaders( - request: __httpRequest, - clientHeaders: Options.Headers, - requestHeaders: requestOptions?.Headers); - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateTranscriptionRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); - - return __httpRequest; - } - - global::System.Net.Http.HttpRequestMessage? __httpRequest = null; - global::System.Net.Http.HttpResponseMessage? __response = null; - var __attemptNumber = 0; - try - { - for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) - { - __attemptNumber = __attempt; - __httpRequest = __CreateHttpRequest(); - await global::Mistral.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( - clientOptions: Options, - context: global::Mistral.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CreateTranscription", - methodName: "CreateTranscriptionAsync", - pathTemplate: "\"/v1/audio/transcriptions\"", - httpMethod: "POST", - baseUri: BaseUri, - request: __httpRequest!, - response: null, - exception: null, - clientOptions: Options, - requestOptions: requestOptions, - attempt: __attempt, - maxAttempts: __maxAttempts, - willRetry: false, - retryDelay: null, - retryReason: global::System.String.Empty, - cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); - try - { - __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); - } - catch (global::System.Net.Http.HttpRequestException __exception) - { - var __retryDelay = global::Mistral.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: null, - attempt: __attempt); - var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; - await global::Mistral.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Mistral.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CreateTranscription", - methodName: "CreateTranscriptionAsync", - pathTemplate: "\"/v1/audio/transcriptions\"", - httpMethod: "POST", - baseUri: BaseUri, - request: __httpRequest!, - response: null, - exception: __exception, - clientOptions: Options, - requestOptions: requestOptions, - attempt: __attempt, - maxAttempts: __maxAttempts, - willRetry: __willRetry, - retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, - retryReason: "exception", - cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); - if (!__willRetry) - { - throw; - } - - __httpRequest.Dispose(); - __httpRequest = null; - await global::Mistral.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - retryDelay: __retryDelay, - cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); - continue; - } - - if (__response != null && - __attempt < __maxAttempts && - global::Mistral.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) - { - var __retryDelay = global::Mistral.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: __response, - attempt: __attempt); - await global::Mistral.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Mistral.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CreateTranscription", - methodName: "CreateTranscriptionAsync", - pathTemplate: "\"/v1/audio/transcriptions\"", - httpMethod: "POST", - baseUri: BaseUri, - request: __httpRequest!, - response: __response, - exception: null, - clientOptions: Options, - requestOptions: requestOptions, - attempt: __attempt, - maxAttempts: __maxAttempts, - willRetry: true, - retryDelay: __retryDelay, - retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), - cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); - __response.Dispose(); - __response = null; - __httpRequest.Dispose(); - __httpRequest = null; - await global::Mistral.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - retryDelay: __retryDelay, - cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); - continue; - } - - break; - } - - if (__response == null) - { - throw new global::System.InvalidOperationException("No response received."); - } - - using (__response) - { - - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateTranscriptionResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - if (__response.IsSuccessStatusCode) - { - await global::Mistral.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( - clientOptions: Options, - context: global::Mistral.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CreateTranscription", - methodName: "CreateTranscriptionAsync", - pathTemplate: "\"/v1/audio/transcriptions\"", - httpMethod: "POST", - baseUri: BaseUri, - request: __httpRequest!, - response: __response, - exception: null, - clientOptions: Options, - requestOptions: requestOptions, - attempt: __attemptNumber, - maxAttempts: __maxAttempts, - willRetry: false, - retryDelay: null, - retryReason: global::System.String.Empty, - cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); - } - else - { - await global::Mistral.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Mistral.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "CreateTranscription", - methodName: "CreateTranscriptionAsync", - pathTemplate: "\"/v1/audio/transcriptions\"", - httpMethod: "POST", - baseUri: BaseUri, - request: __httpRequest!, - response: __response, - exception: null, - clientOptions: Options, - requestOptions: requestOptions, - attempt: __attemptNumber, - maxAttempts: __maxAttempts, - willRetry: false, - retryDelay: null, - retryReason: global::System.String.Empty, - cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); - } - - if (__effectiveReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( - #if NET5_0_OR_GREATER - __effectiveCancellationToken - #endif - ).ConfigureAwait(false); - - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessCreateTranscriptionResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try - { - __response.EnsureSuccessStatusCode(); - - var __value = global::Mistral.TranscriptionResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - return new global::Mistral.AutoSDKHttpResponse( - statusCode: __response.StatusCode, - headers: global::Mistral.AutoSDKHttpResponse.CreateHeaders(__response), - requestUri: __response.RequestMessage?.RequestUri, - body: __value); - } - catch (global::System.Exception __ex) - { - throw new global::Mistral.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( - #if NET5_0_OR_GREATER - __effectiveCancellationToken - #endif - ).ConfigureAwait(false); - - var __value = await global::Mistral.TranscriptionResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - return new global::Mistral.AutoSDKHttpResponse( - statusCode: __response.StatusCode, - headers: global::Mistral.AutoSDKHttpResponse.CreateHeaders(__response), - requestUri: __response.RequestMessage?.RequestUri, - body: __value); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( - #if NET5_0_OR_GREATER - __effectiveCancellationToken - #endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } - - throw new global::Mistral.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - } - - } - } - finally - { - __httpRequest?.Dispose(); - } - } } } \ No newline at end of file diff --git a/src/libs/Mistral/Generated/Mistral.IAudioTranscriptionsClient.CreateStreamingTranscriptionSse.g.cs b/src/libs/Mistral/Generated/Mistral.IAudioTranscriptionsClient.CreateStreamingTranscriptionSse.g.cs index 82506c6..ab20e77 100644 --- a/src/libs/Mistral/Generated/Mistral.IAudioTranscriptionsClient.CreateStreamingTranscriptionSse.g.cs +++ b/src/libs/Mistral/Generated/Mistral.IAudioTranscriptionsClient.CreateStreamingTranscriptionSse.g.cs @@ -70,60 +70,5 @@ public partial interface IAudioTranscriptionsClient global::System.Collections.Generic.IList? timestampGranularities = default, global::Mistral.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); - - /// - /// Create Streaming Transcription (SSE) - /// - /// - /// - /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// Url of a file to be transcribed
- /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// ID of a file uploaded to /v1/files
- /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// Language of the audio, e.g. 'en'. Providing the language can boost accuracy.
- /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// Default Value: true - /// - /// - /// Default Value: false - /// - /// - /// Default Value: [] - /// - /// - /// Granularities of timestamps to include in the response. - /// - /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. - /// The token to cancel the operation with - /// - global::System.Collections.Generic.IAsyncEnumerable CreateStreamingTranscriptionSseAsync( - string model, - global::System.IO.Stream? file = default, - string? filename = default, - string? fileUrl = default, - string? fileId = default, - string? language = default, - double? temperature = default, - bool? stream = default, - bool? diarize = default, - global::System.Collections.Generic.IList? contextBias = default, - global::System.Collections.Generic.IList? timestampGranularities = default, - global::Mistral.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mistral/Generated/Mistral.IAudioTranscriptionsClient.CreateTranscription.g.cs b/src/libs/Mistral/Generated/Mistral.IAudioTranscriptionsClient.CreateTranscription.g.cs index 2eb872d..6c023db 100644 --- a/src/libs/Mistral/Generated/Mistral.IAudioTranscriptionsClient.CreateTranscription.g.cs +++ b/src/libs/Mistral/Generated/Mistral.IAudioTranscriptionsClient.CreateTranscription.g.cs @@ -84,118 +84,5 @@ public partial interface IAudioTranscriptionsClient global::System.Collections.Generic.IList? timestampGranularities = default, global::Mistral.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); - - /// - /// Create Transcription - /// - /// - /// ID of the model to be used. - /// - /// - /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// Url of a file to be transcribed
- /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// ID of a file uploaded to /v1/files
- /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// Language of the audio, e.g. 'en'. Providing the language can boost accuracy.
- /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// Default Value: false - /// - /// - /// Default Value: false - /// - /// - /// Default Value: [] - /// - /// - /// Granularities of timestamps to include in the response. - /// - /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. - /// The token to cancel the operation with - /// - global::System.Threading.Tasks.Task CreateTranscriptionAsync( - string model, - global::System.IO.Stream? file = default, - string? filename = default, - string? fileUrl = default, - string? fileId = default, - string? language = default, - double? temperature = default, - bool? stream = default, - bool? diarize = default, - global::System.Collections.Generic.IList? contextBias = default, - global::System.Collections.Generic.IList? timestampGranularities = default, - global::Mistral.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default); - /// - /// Create Transcription - /// - /// - /// ID of the model to be used. - /// - /// - /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// Url of a file to be transcribed
- /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// ID of a file uploaded to /v1/files
- /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// Language of the audio, e.g. 'en'. Providing the language can boost accuracy.
- /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 - /// - /// - /// Default Value: false - /// - /// - /// Default Value: false - /// - /// - /// Default Value: [] - /// - /// - /// Granularities of timestamps to include in the response. - /// - /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. - /// The token to cancel the operation with - /// - global::System.Threading.Tasks.Task> CreateTranscriptionAsResponseAsync( - string model, - global::System.IO.Stream? file = default, - string? filename = default, - string? fileUrl = default, - string? fileId = default, - string? language = default, - double? temperature = default, - bool? stream = default, - bool? diarize = default, - global::System.Collections.Generic.IList? contextBias = default, - global::System.Collections.Generic.IList? timestampGranularities = default, - global::Mistral.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mistral/Generated/Mistral.OptionsSupport.g.cs b/src/libs/Mistral/Generated/Mistral.OptionsSupport.g.cs index 54e42ea..f57efca 100644 --- a/src/libs/Mistral/Generated/Mistral.OptionsSupport.g.cs +++ b/src/libs/Mistral/Generated/Mistral.OptionsSupport.g.cs @@ -150,6 +150,84 @@ public interface IAutoSDKAuthorizationProvider global::Mistral.AutoSDKHookContext context); } + /// + /// Marker keys stamped onto outgoing + /// instances so consumer s — and any + /// other transport-layer code that runs after AutoSDK's send pipeline — can observe whether + /// the resolved Authorization is call-scoped and opt out of overwriting it with a + /// rotation-aware account-level credential. + /// + public static class AutoSDKHttpRequestOptions + { + /// + /// Key under which records the marker. Exposed + /// for handlers that target frameworks older than .NET 5 and need to read the value + /// through the legacy HttpRequestMessage.Properties bag. + /// + public const string AuthorizationOverrideKey = "AutoSDK.AuthorizationOverride"; + +#if NET5_0_OR_GREATER + /// + /// Strongly-typed for + /// the call-scoped Authorization marker on .NET 5+ targets. Consumers should prefer this + /// over the legacy HttpRequestMessage.Properties bag where available. + /// + public static readonly global::System.Net.Http.HttpRequestOptionsKey AuthorizationOverride = + new global::System.Net.Http.HttpRequestOptionsKey(AuthorizationOverrideKey); +#endif + + /// + /// Stamps the call-scoped Authorization marker on . AutoSDK's + /// built-in calls this whenever the + /// resolved auth came from a per-request override or a client-level + /// . Hand-written SDK extensions that set a + /// non-default Authorization header (e.g. a session-scoped bearer returned by an + /// upstream poll) should call this too so downstream rotation handlers know to skip the + /// overwrite. + /// + /// + public static void StampAuthorizationOverride( + global::System.Net.Http.HttpRequestMessage? request) + { + if (request is null) + { + return; + } + +#if NET5_0_OR_GREATER + request.Options.Set(AuthorizationOverride, true); +#else +#pragma warning disable CS0618 // HttpRequestMessage.Properties is obsolete in NET5+, but the only option below it. + request.Properties[AuthorizationOverrideKey] = true; +#pragma warning restore CS0618 +#endif + } + + /// + /// Returns true when previously marked the + /// request as carrying a call-scoped Authorization. + /// + /// + public static bool HasAuthorizationOverride( + global::System.Net.Http.HttpRequestMessage? request) + { + if (request is null) + { + return false; + } + +#if NET5_0_OR_GREATER + return request.Options.TryGetValue(AuthorizationOverride, out var value) && value; +#else +#pragma warning disable CS0618 + return request.Properties.TryGetValue(AuthorizationOverrideKey, out var raw) && + raw is bool flag && + flag; +#pragma warning restore CS0618 +#endif + } + } + /// /// Built-in that consults /// before every outgoing @@ -176,6 +254,7 @@ public sealed class AutoSDKAuthorizationProviderHook : global::Mistral.AutoSDKHo ApplyAuthorization(context.Request, perRequest[index]); } + global::Mistral.AutoSDKHttpRequestOptions.StampAuthorizationOverride(context.Request); return; } @@ -195,6 +274,8 @@ public sealed class AutoSDKAuthorizationProviderHook : global::Mistral.AutoSDKHo { ApplyAuthorization(context.Request, resolved[index]); } + + global::Mistral.AutoSDKHttpRequestOptions.StampAuthorizationOverride(context.Request); } private static void ApplyAuthorization(