diff --git a/src/libs/Together/Generated/Together.AllOf.2.g.cs b/src/libs/Together/Generated/Together.AllOf.2.g.cs index fb945e7a..68828cc7 100644 --- a/src/libs/Together/Generated/Together.AllOf.2.g.cs +++ b/src/libs/Together/Generated/Together.AllOf.2.g.cs @@ -6,7 +6,7 @@ namespace Together /// /// /// - public readonly partial struct AllOf<[global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T1, [global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T2> : global::System.IEquatable> + public readonly partial struct AllOf : global::System.IEquatable> { /// /// @@ -25,6 +25,26 @@ namespace Together #endif public bool IsValue1 => Value1 != null; + /// + /// + /// + public bool TryPickValue1( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out T1? value) + { + value = Value1; + return IsValue1; + } + + /// + /// + /// + public T1 PickValue1() => IsValue1 + ? Value1! + : throw new global::System.InvalidOperationException($"Expected union variant 'Value1' but the value was {ToString()}."); + /// /// /// @@ -41,6 +61,26 @@ namespace Together [global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(Value2))] #endif public bool IsValue2 => Value2 != null; + + /// + /// + /// + public bool TryPickValue2( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out T2? value) + { + value = Value2; + return IsValue2; + } + + /// + /// + /// + public T2 PickValue2() => IsValue2 + ? Value2! + : throw new global::System.InvalidOperationException($"Expected union variant 'Value2' but the value was {ToString()}."); /// /// /// @@ -59,6 +99,11 @@ public AllOf(T1? value) Value1 = value; } + /// + /// + /// + public static AllOf FromValue1(T1? value) => new AllOf(value); + /// /// /// @@ -77,6 +122,11 @@ public AllOf(T2? value) Value2 = value; } + /// + /// + /// + public static AllOf FromValue2(T2? value) => new AllOf(value); + /// /// /// @@ -105,42 +155,17 @@ Value1 as object Value2?.ToString() ; - private static bool RequiresValue<[global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] TValue>() => RequirementCache.Value; - - private static bool DetermineRequiresValue([global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] global::System.Type type) + private static bool RequiresValue() { + var type = typeof(TValue); if (global::System.Nullable.GetUnderlyingType(type) != null) { return false; } - if (type.IsValueType || - type == typeof(string) || - type.IsArray) - { - return true; - } - - foreach (var property in type.GetProperties(global::System.Reflection.BindingFlags.Instance | global::System.Reflection.BindingFlags.Public)) - { - foreach (var attributeData in property.CustomAttributes) - { - var attributeTypeName = attributeData.AttributeType.FullName; - if (attributeTypeName == "System.Text.Json.Serialization.JsonRequiredAttribute" || - attributeTypeName == "Newtonsoft.Json.JsonRequiredAttribute" || - attributeTypeName == "System.Runtime.CompilerServices.RequiredMemberAttribute") - { - return true; - } - } - } - - return false; - } - - private static class RequirementCache<[global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] TValue> - { - public static readonly bool Value = DetermineRequiresValue(typeof(TValue)); + return type.IsValueType || + type == typeof(string) || + type.IsArray; } @@ -182,6 +207,30 @@ public bool Validate() /// public void Match( global::System.Action? value1 = null, + + global::System.Action? value2 = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (IsValue1) + { + value1?.Invoke(Value1!); + } + else if (IsValue2) + { + value2?.Invoke(Value2!); + } + } + + /// + /// + /// + public void Switch( + global::System.Action? value1 = null, global::System.Action? value2 = null, bool validate = true) { diff --git a/src/libs/Together/Generated/Together.AnyOf.2.g.cs b/src/libs/Together/Generated/Together.AnyOf.2.g.cs index 10bedb78..6db50676 100644 --- a/src/libs/Together/Generated/Together.AnyOf.2.g.cs +++ b/src/libs/Together/Generated/Together.AnyOf.2.g.cs @@ -25,6 +25,26 @@ namespace Together #endif public bool IsValue1 => Value1 != null; + /// + /// + /// + public bool TryPickValue1( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out T1? value) + { + value = Value1; + return IsValue1; + } + + /// + /// + /// + public T1 PickValue1() => IsValue1 + ? Value1! + : throw new global::System.InvalidOperationException($"Expected union variant 'Value1' but the value was {ToString()}."); + /// /// /// @@ -41,6 +61,26 @@ namespace Together [global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(Value2))] #endif public bool IsValue2 => Value2 != null; + + /// + /// + /// + public bool TryPickValue2( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out T2? value) + { + value = Value2; + return IsValue2; + } + + /// + /// + /// + public T2 PickValue2() => IsValue2 + ? Value2! + : throw new global::System.InvalidOperationException($"Expected union variant 'Value2' but the value was {ToString()}."); /// /// /// @@ -59,6 +99,11 @@ public AnyOf(T1? value) Value1 = value; } + /// + /// + /// + public static AnyOf FromValue1(T1? value) => new AnyOf(value); + /// /// /// @@ -77,6 +122,11 @@ public AnyOf(T2? value) Value2 = value; } + /// + /// + /// + public static AnyOf FromValue2(T2? value) => new AnyOf(value); + /// /// /// @@ -143,6 +193,30 @@ public bool Validate() /// public void Match( global::System.Action? value1 = null, + + global::System.Action? value2 = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (IsValue1) + { + value1?.Invoke(Value1!); + } + else if (IsValue2) + { + value2?.Invoke(Value2!); + } + } + + /// + /// + /// + public void Switch( + global::System.Action? value1 = null, global::System.Action? value2 = null, bool validate = true) { diff --git a/src/libs/Together/Generated/Together.AudioClient.AudioSpeech.g.cs b/src/libs/Together/Generated/Together.AudioClient.AudioSpeech.g.cs index bf51ff11..b245e32e 100644 --- a/src/libs/Together/Generated/Together.AudioClient.AudioSpeech.g.cs +++ b/src/libs/Together/Generated/Together.AudioClient.AudioSpeech.g.cs @@ -14,6 +14,7 @@ public partial class AudioClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,6 +41,7 @@ partial void ProcessAudioSpeechResponse( /// Generate audio from input text /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -60,6 +62,7 @@ partial void ProcessAudioSpeechResponse( public async global::System.Collections.Generic.IAsyncEnumerable AudioSpeechAsync( global::Together.AudioSpeechRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -76,22 +79,44 @@ partial void ProcessAudioSpeechResponse( securityRequirements: s_AudioSpeechSecurityRequirements, operationName: "AudioSpeechAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/audio/speech", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/audio/speech", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -101,95 +126,272 @@ partial void ProcessAudioSpeechResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareAudioSpeechRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareAudioSpeechRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessAudioSpeechResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; try { - __response.EnsureSuccessStatusCode(); - } - catch (global::System.Net.Http.HttpRequestException __ex) - { - string? __content = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AudioSpeech", + methodName: "AudioSpeechAsync", + pathTemplate: "\"/audio/speech\"", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AudioSpeech", + methodName: "AudioSpeechAsync", + pathTemplate: "\"/audio/speech\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AudioSpeech", + methodName: "AudioSpeechAsync", + pathTemplate: "\"/audio/speech\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; } - catch (global::System.Exception) + + if (__response == null) { + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) + using (__response) { - 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 - cancellationToken -#endif - ).ConfigureAwait(false); - - await foreach (var __sseEvent in global::System.Net.ServerSentEvents.SseParser - .Create(__stream).EnumerateAsync(cancellationToken)) - { - var __content = __sseEvent.Data; - if (__content == "[DONE]") + ProcessResponse( + client: HttpClient, + response: __response); + ProcessAudioSpeechResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AudioSpeech", + methodName: "AudioSpeechAsync", + pathTemplate: "\"/audio/speech\"", + 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 { - yield break; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AudioSpeech", + methodName: "AudioSpeechAsync", + pathTemplate: "\"/audio/speech\"", + 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); } - var __streamedResponse = global::Together.AudioSpeechStreamResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::Together.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), - }; + 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) + { + } - yield return __streamedResponse; + throw new global::Together.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::Together.AudioSpeechStreamResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::Together.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(); } } /// @@ -204,22 +406,23 @@ partial void ProcessAudioSpeechResponse( /// Input text to generate the audio for /// /// - /// The voice to use for generating the audio. The voices supported are different for each model. For eg - for canopylabs/orpheus-3b-0.1-ft, one of the voices supported is tara, for hexgrad/Kokoro-82M, one of the voices supported is af_alloy and for cartesia/sonic, one of the voices supported is "friendly sidekick". You can view the voices supported for each model using the /v1/voices endpoint sending the model name as the query parameter. [View all supported voices here](https://docs.together.ai/docs/text-to-speech#supported-voices). + /// The voice to use for generating the audio. The voices supported are different for each model. For eg - for canopylabs/orpheus-3b-0.1-ft, one of the voices supported is tara, for hexgrad/Kokoro-82M, one of the voices supported is af_alloy and for cartesia/sonic, one of the voices supported is "friendly sidekick". You can view the voices supported for each model using the /v1/voices endpoint sending the model name as the query parameter. [View all supported voices here](https://docs.together.ai/docs/text-to-speech#supported-voices). `hexgrad/Kokoro-82M` additionally supports voice mixing, where two or more voices are combined into a single blended voice by joining their names with `+` (e.g. `af_bella+af_heart`). Optional per-voice weights can be provided in parentheses (e.g. `af_bella(2)+af_heart(1)`). Other models require a single voice name. /// /// /// The format of audio output. Supported formats are mp3, wav, raw if streaming is false. If streaming is true, the only supported format is raw.
/// Default Value: wav /// /// - /// Language of input text.
- /// Default Value: en + /// Language or locale of input text. Accepts ISO 639-1 language codes (e.g., `en`, `fr`, `es`, `zh`) as well as locale codes for region-specific variants. Locale codes must be lowercase (e.g., `zh-hk` for Cantonese).
+ /// Default Value: en
+ /// Example: en /// /// - /// Audio encoding of response
+ /// Audio encoding of response. Only applicable when response_format is raw or pcm. Cartesia models respect this parameter and support all values. Orpheus, Kokoro, and Minimax models always return pcm_s16le regardless of this setting.
/// Default Value: pcm_f32le /// /// - /// Sampling rate to use for the output audio. The default sampling rate for canopylabs/orpheus-3b-0.1-ft and hexgrad/Kokoro-82M is 24000 and for cartesia/sonic is 44100.
+ /// Sampling rate in Hz for the output audio. Cartesia and Minimax models respect this parameter. Orpheus and Kokoro models always output at 24000 Hz regardless of this setting.
/// Default Value: 44100 /// /// @@ -230,6 +433,10 @@ partial void ProcessAudioSpeechResponse( /// If true, output is streamed for several characters at a time instead of waiting for the full response. The stream terminates with `data: [DONE]`. If false, return the encoded audio as octet stream
/// Default Value: false /// + /// + /// Additional model-specific parameters that fine-tune speech generation behavior. + /// + /// 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 AudioSpeechAsync( @@ -237,11 +444,13 @@ partial void ProcessAudioSpeechResponse( string input, string voice, global::Together.AudioSpeechRequestResponseFormat? responseFormat = default, - global::Together.AudioSpeechRequestLanguage? language = default, + string? language = default, global::Together.AudioSpeechRequestResponseEncoding? responseEncoding = default, int? sampleRate = default, int? bitRate = default, bool? stream = default, + global::Together.AudioSpeechRequestExtraParams? extraParams = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.AudioSpeechRequest @@ -255,10 +464,12 @@ partial void ProcessAudioSpeechResponse( SampleRate = sampleRate, BitRate = bitRate, Stream = stream, + ExtraParams = extraParams, }; var __enumerable = AudioSpeechAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken); await foreach (var __response in __enumerable) diff --git a/src/libs/Together/Generated/Together.AudioClient.AudioTranscriptions.g.cs b/src/libs/Together/Generated/Together.AudioClient.AudioTranscriptions.g.cs index 69e7a4ec..c2d4d2f0 100644 --- a/src/libs/Together/Generated/Together.AudioClient.AudioTranscriptions.g.cs +++ b/src/libs/Together/Generated/Together.AudioClient.AudioTranscriptions.g.cs @@ -14,6 +14,7 @@ public partial class AudioClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,6 +46,7 @@ partial void ProcessAudioTranscriptionsResponseContent( /// Transcribes audio into text ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -63,6 +65,43 @@ partial void ProcessAudioTranscriptionsResponseContent( public async global::System.Threading.Tasks.Task AudioTranscriptionsAsync( global::Together.AudioTranscriptionRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await AudioTranscriptionsAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Create audio transcription request
+ /// Transcribes audio into text + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// file = open("audio.wav", "rb")
+ /// response = client.audio.transcriptions.create(
+ /// model="openai/whisper-large-v3",
+ /// file=file,
+ /// )
+ /// print(response.text) + ///
+ public async global::System.Threading.Tasks.Task> AudioTranscriptionsAsResponseAsync( + + global::Together.AudioTranscriptionRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -79,22 +118,44 @@ partial void ProcessAudioTranscriptionsResponseContent( securityRequirements: s_AudioTranscriptionsSecurityRequirements, operationName: "AudioTranscriptionsAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/audio/transcriptions", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/audio/transcriptions", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -104,301 +165,499 @@ partial void ProcessAudioTranscriptionsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - using var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.File.ToString() ?? string.Empty), - name: "\"file\""); - if (request.Model != default) - { - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent($"{request.Model?.ToValueString()}"), - name: "\"model\""); - } - if (request.Language != default) - { + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.File.ToString() ?? string.Empty), + name: "\"file\""); - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent($"{request.Language}"), - name: "\"language\""); - } - if (request.Prompt != default) - { + if (request.Model != default) + { - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent($"{request.Prompt}"), - name: "\"prompt\""); - } - if (request.ResponseFormat != default) - { + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.Model).HasValue ? (request.Model).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"model\""); - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent($"{request.ResponseFormat?.ToValueString()}"), - name: "\"response_format\""); - } - if (request.Temperature != default) - { + } + if (request.Language != default) + { - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent($"{request.Temperature}"), - name: "\"temperature\""); - } - if (request.TimestampGranularities != default) - { + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Language ?? string.Empty), + name: "\"language\""); - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.TimestampGranularities?.ToString() ?? string.Empty), - name: "\"timestamp_granularities\""); - } - if (request.Diarize != default) - { + } + if (request.Prompt != default) + { - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent($"{request.Diarize}"), - name: "\"diarize\""); - } - if (request.MinSpeakers != default) - { + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), + name: "\"prompt\""); - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent($"{request.MinSpeakers}"), - name: "\"min_speakers\""); - } - if (request.MaxSpeakers != default) - { + } + if (request.ResponseFormat != default) + { - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent($"{request.MaxSpeakers}"), - name: "\"max_speakers\""); - } - __httpRequest.Content = __httpRequestContent; + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.ResponseFormat).HasValue ? (request.ResponseFormat).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"response_format\""); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareAudioTranscriptionsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + } + if (request.Temperature != default) + { - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Temperature, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"temperature\""); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessAudioTranscriptionsResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // BadRequest - if ((int)__response.StatusCode == 400) - { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - global::Together.ErrorData? __value_400 = null; - try - { - if (ReadResponseAsString) - { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); - } - else - { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + } + if (request.TimestampGranularities != default) + { - __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.TimestampGranularities.ToString() ?? string.Empty), + name: "\"timestamp_granularities\""); - throw new global::Together.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + } + 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.MinSpeakers != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.MinSpeakers, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"min_speakers\""); + + } + if (request.MaxSpeakers != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.MaxSpeakers, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"max_speakers\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareAudioTranscriptionsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; } - // Unauthorized - if ((int)__response.StatusCode == 401) + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_401 = null; - global::System.Exception? __exception_401 = null; - global::Together.ErrorData? __value_401 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AudioTranscriptions", + methodName: "AudioTranscriptionsAsync", + pathTemplate: "\"/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 { - __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - - __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AudioTranscriptions", + methodName: "AudioTranscriptionsAsync", + pathTemplate: "\"/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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_401 = __ex; - } - throw new global::Together.ApiException( - message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_401, - statusCode: __response.StatusCode) - { - ResponseBody = __content_401, - ResponseObject = __value_401, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // RateLimit - if ((int)__response.StatusCode == 429) - { - string? __content_429 = null; - global::System.Exception? __exception_429 = null; - global::Together.ErrorData? __value_429 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_429 = global::Together.ErrorData.FromJson(__content_429, JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AudioTranscriptions", + methodName: "AudioTranscriptionsAsync", + pathTemplate: "\"/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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_429 = global::Together.ErrorData.FromJson(__content_429, JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_429 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_429, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_429, - ResponseObject = __value_429, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessAudioTranscriptionsResponseContent( + response: __response); + ProcessAudioTranscriptionsResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try - { - __response.EnsureSuccessStatusCode(); - - return - global::Together.AudioTranscriptionResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - } - catch (global::System.Exception __ex) + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AudioTranscriptions", + methodName: "AudioTranscriptionsAsync", + pathTemplate: "\"/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 - { - try + else { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - - return - await global::Together.AudioTranscriptionResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AudioTranscriptions", + methodName: "AudioTranscriptionsAsync", + pathTemplate: "\"/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); } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + // BadRequest + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Together.ErrorData? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Together.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unauthorized + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Together.ErrorData? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Together.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseObject = __value_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // RateLimit + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Together.ErrorData? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Together.ErrorData.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Together.ErrorData.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Together.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseObject = __value_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessAudioTranscriptionsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.AudioTranscriptionResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.AudioTranscriptionResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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 audio transcription request
/// Transcribes audio into text ///
/// - /// Audio file upload or public HTTP/HTTPS URL. Supported formats .wav, .mp3, .m4a, .webm, .flac. + /// Audio file upload or public HTTP/HTTPS URL. Supported formats .wav, .mp3, .m4a, .webm, .flac, .ogg, .opus, .aac. /// /// /// Model to use for transcription
@@ -410,7 +669,7 @@ partial void ProcessAudioTranscriptionsResponseContent( /// Example: en /// /// - /// Optional text to bias decoding. + /// Optional text to bias decoding. Supported only on Whisper-family models (e.g. `openai/whisper-large-v3`). Other STT models (e.g. `nvidia/parakeet-tdt-0.6b-v3`) accept the field for API compatibility but ignore it. /// /// /// The format of the response
@@ -447,6 +706,7 @@ partial void ProcessAudioTranscriptionsResponseContent( /// /// Maximum number of speakers expected in the audio. Used to improve diarization accuracy when the approximate number of speakers is known. /// + /// 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 AudioTranscriptionsAsync( @@ -460,6 +720,7 @@ partial void ProcessAudioTranscriptionsResponseContent( bool? diarize = default, int? minSpeakers = default, int? maxSpeakers = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.AudioTranscriptionRequest @@ -478,6 +739,7 @@ partial void ProcessAudioTranscriptionsResponseContent( return await AudioTranscriptionsAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Together/Generated/Together.AudioClient.AudioTranslations.g.cs b/src/libs/Together/Generated/Together.AudioClient.AudioTranslations.g.cs index 61b51acd..bf868f43 100644 --- a/src/libs/Together/Generated/Together.AudioClient.AudioTranslations.g.cs +++ b/src/libs/Together/Generated/Together.AudioClient.AudioTranslations.g.cs @@ -14,6 +14,7 @@ public partial class AudioClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,6 +46,7 @@ partial void ProcessAudioTranslationsResponseContent( /// Translates audio into English /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -65,6 +67,45 @@ partial void ProcessAudioTranslationsResponseContent( public async global::System.Threading.Tasks.Task AudioTranslationsAsync( global::Together.AudioTranslationRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await AudioTranslationsAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Create audio translation request
+ /// Translates audio into English + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// file = open("audio.wav", "rb")
+ /// response = client.audio.translations.create(
+ /// model="openai/whisper-large-v3",
+ /// file=file,
+ /// language="es",
+ /// )
+ /// print(response.text) + ///
+ public async global::System.Threading.Tasks.Task> AudioTranslationsAsResponseAsync( + + global::Together.AudioTranslationRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -81,22 +122,44 @@ partial void ProcessAudioTranslationsResponseContent( securityRequirements: s_AudioTranslationsSecurityRequirements, operationName: "AudioTranslationsAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/audio/translations", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/audio/translations", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -106,280 +169,475 @@ partial void ProcessAudioTranslationsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - using var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.File.ToString() ?? string.Empty), - name: "\"file\""); - if (request.Model != default) - { - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent($"{request.Model?.ToValueString()}"), - name: "\"model\""); - } - if (request.Language != default) - { + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.File.ToString() ?? string.Empty), + name: "\"file\""); - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent($"{request.Language}"), - name: "\"language\""); - } - if (request.Prompt != default) - { + if (request.Model != default) + { - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent($"{request.Prompt}"), - name: "\"prompt\""); - } - if (request.ResponseFormat != default) - { + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.Model).HasValue ? (request.Model).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"model\""); - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent($"{request.ResponseFormat?.ToValueString()}"), - name: "\"response_format\""); - } - if (request.Temperature != default) - { + } + if (request.Language != default) + { - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent($"{request.Temperature}"), - name: "\"temperature\""); - } - if (request.TimestampGranularities != default) - { + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Language ?? string.Empty), + name: "\"language\""); - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.TimestampGranularities?.ToString() ?? string.Empty), - name: "\"timestamp_granularities\""); - } - __httpRequest.Content = __httpRequestContent; + } + if (request.Prompt != default) + { - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareAudioTranslationsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), + name: "\"prompt\""); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + } + if (request.ResponseFormat != default) + { - ProcessResponse( - client: HttpClient, - response: __response); - ProcessAudioTranslationsResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // BadRequest - if ((int)__response.StatusCode == 400) - { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - global::Together.ErrorData? __value_400 = null; - try - { - if (ReadResponseAsString) - { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); - } - else - { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.ResponseFormat).HasValue ? (request.ResponseFormat).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"response_format\""); - __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } + } + if (request.Temperature != default) + { - throw new global::Together.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + __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.TimestampGranularities != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.TimestampGranularities.ToString() ?? string.Empty), + name: "\"timestamp_granularities\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareAudioTranslationsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; } - // Unauthorized - if ((int)__response.StatusCode == 401) + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_401 = null; - global::System.Exception? __exception_401 = null; - global::Together.ErrorData? __value_401 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AudioTranslations", + methodName: "AudioTranslationsAsync", + pathTemplate: "\"/audio/translations\"", + 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 { - __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - - __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AudioTranslations", + methodName: "AudioTranslationsAsync", + pathTemplate: "\"/audio/translations\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_401 = __ex; - } - throw new global::Together.ApiException( - message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_401, - statusCode: __response.StatusCode) - { - ResponseBody = __content_401, - ResponseObject = __value_401, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // RateLimit - if ((int)__response.StatusCode == 429) - { - string? __content_429 = null; - global::System.Exception? __exception_429 = null; - global::Together.ErrorData? __value_429 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_429 = global::Together.ErrorData.FromJson(__content_429, JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AudioTranslations", + methodName: "AudioTranslationsAsync", + pathTemplate: "\"/audio/translations\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_429 = global::Together.ErrorData.FromJson(__content_429, JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_429 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_429, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_429, - ResponseObject = __value_429, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessAudioTranslationsResponseContent( + response: __response); + ProcessAudioTranslationsResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.AudioTranslationResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AudioTranslations", + methodName: "AudioTranslationsAsync", + pathTemplate: "\"/audio/translations\"", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AudioTranslations", + methodName: "AudioTranslationsAsync", + pathTemplate: "\"/audio/translations\"", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // BadRequest + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Together.ErrorData? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Together.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unauthorized + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Together.ErrorData? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Together.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseObject = __value_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // RateLimit + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Together.ErrorData? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Together.ErrorData.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Together.ErrorData.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Together.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseObject = __value_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessAudioTranslationsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.AudioTranslationResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.AudioTranslationResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - return - await global::Together.AudioTranslationResponse.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } - - throw new global::Together.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 audio translation request
/// Translates audio into English ///
/// - /// Audio file upload or public HTTP/HTTPS URL. Supported formats .wav, .mp3, .m4a, .webm, .flac. + /// Audio file upload or public HTTP/HTTPS URL. Supported formats .wav, .mp3, .m4a, .webm, .flac, .ogg, .opus, .aac. /// /// /// Model to use for translation
@@ -391,7 +649,7 @@ partial void ProcessAudioTranslationsResponseContent( /// Example: en /// /// - /// Optional text to bias decoding. + /// Optional text to bias decoding. Supported only on Whisper-family models (e.g. `openai/whisper-large-v3`). Other STT models (e.g. `nvidia/parakeet-tdt-0.6b-v3`) accept the field for API compatibility but ignore it. /// /// /// The format of the response
@@ -406,6 +664,7 @@ partial void ProcessAudioTranslationsResponseContent( /// Default Value: segment
/// Example: [word, segment] /// + /// 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 AudioTranslationsAsync( @@ -416,6 +675,7 @@ partial void ProcessAudioTranslationsResponseContent( global::Together.AudioTranslationRequestResponseFormat? responseFormat = default, float? temperature = default, global::Together.OneOf>? timestampGranularities = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.AudioTranslationRequest @@ -431,6 +691,7 @@ partial void ProcessAudioTranslationsResponseContent( return await AudioTranslationsAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Together/Generated/Together.AudioClient.RealtimeTranscription.g.cs b/src/libs/Together/Generated/Together.AudioClient.RealtimeTranscription.g.cs index 73c9aa03..136df8f3 100644 --- a/src/libs/Together/Generated/Together.AudioClient.RealtimeTranscription.g.cs +++ b/src/libs/Together/Generated/Together.AudioClient.RealtimeTranscription.g.cs @@ -14,6 +14,7 @@ public partial class AudioClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -52,12 +53,53 @@ partial void ProcessRealtimeTranscriptionResponse( /// "audio": "<base64_encoded_audio_chunk>"
/// }
/// ```
- /// - `input_audio_buffer.commit`: Signal end of audio stream
+ /// - `input_audio_buffer.commit`: Signal end of audio stream. When VAD is enabled, the server automatically detects speech boundaries and emits `completed` events. When VAD is disabled, you must send `commit` to trigger transcription of the buffered audio.
/// ```json
/// {
/// "type": "input_audio_buffer.commit"
/// }
/// ```
+ /// - `transcription_session.updated`: Update session configuration, including Voice Activity Detection (VAD) parameters. Send this after receiving `session.created`. Can also be sent at any time during the session to change VAD settings.
+ /// ```json
+ /// {
+ /// "type": "transcription_session.updated",
+ /// "session": {
+ /// "turn_detection": {
+ /// "type": "server_vad",
+ /// "threshold": 0.3,
+ /// "min_silence_duration_ms": 500,
+ /// "min_speech_duration_ms": 250,
+ /// "max_speech_duration_s": 5.0,
+ /// "speech_pad_ms": 250
+ /// }
+ /// }
+ /// }
+ /// ```
+ /// To disable VAD entirely (manual commit mode), set `turn_detection` to `null`:
+ /// ```json
+ /// {
+ /// "type": "transcription_session.updated",
+ /// "session": {
+ /// "turn_detection": null
+ /// }
+ /// }
+ /// ```
+ /// **Voice Activity Detection (VAD)**
+ /// VAD controls how the server automatically detects speech segments in the audio stream. When enabled (the default), the server uses Silero VAD to identify speech regions and emits transcription events as each segment completes. When disabled, you must manually call `input_audio_buffer.commit` to trigger transcription.
+ /// VAD can be configured in two ways:
+ /// 1. **Query parameters** at connection time: `turn_detection=server_vad&threshold=0.3&min_silence_duration_ms=500`
+ /// 2. **Session message** after connection: Send `transcription_session.updated` with a `turn_detection` object (see above)
+ /// To disable VAD at connection time, use `turn_detection=none` as a query parameter.
+ /// **VAD Parameters:**
+ /// All parameters are optional. Omitted fields use their defaults.
+ /// | Parameter | Type | Default | Description |
+ /// |-----------|------|---------|-------------|
+ /// | `type` | string | `server_vad` | VAD mode. Use `server_vad` to enable, or set `turn_detection` to `null` to disable. |
+ /// | `threshold` | float | `0.3` | Speech probability threshold (0.0–1.0). Audio frames with probability above this value are classified as speech. Lower values detect more speech but may increase false positives. For low-SNR audio (e.g., 8kHz phone calls), values of 0.01–0.2 may work better. |
+ /// | `min_silence_duration_ms` | int | `500` | Minimum silence duration in milliseconds before ending a speech segment. Higher values merge nearby speech bursts into single segments. For phone calls with mid-sentence pauses, 2000–5000ms prevents over-segmentation. |
+ /// | `min_speech_duration_ms` | int | `250` | Minimum speech segment duration in milliseconds. Segments shorter than this are discarded. Filters out brief noise bursts or clicks. |
+ /// | `max_speech_duration_s` | float | `5.0` | Maximum speech segment duration in seconds. Segments longer than this are force-split at the longest internal silence gap. Useful for continuous speech without natural pauses. |
+ /// | `speech_pad_ms` | int | `250` | Padding in milliseconds added to the start and end of each detected segment. Prevents clipping speech edges. When padding would cause adjacent segments to overlap, the gap is split at the midpoint instead. |
/// **Server Events:**
/// - `session.created`: Initial session confirmation (sent first)
/// ```json
@@ -71,6 +113,22 @@ partial void ProcessRealtimeTranscriptionResponse( /// }
/// }
/// ```
+ /// - `transcription_session.updated`: Confirms session configuration was applied. Sent in response to a client `transcription_session.updated` message.
+ /// ```json
+ /// {
+ /// "type": "transcription_session.updated",
+ /// "session": {
+ /// "turn_detection": {
+ /// "type": "server_vad",
+ /// "threshold": 0.3,
+ /// "min_silence_duration_ms": 500,
+ /// "min_speech_duration_ms": 250,
+ /// "max_speech_duration_s": 5.0,
+ /// "speech_pad_ms": 250
+ /// }
+ /// }
+ /// }
+ /// ```
/// - `conversation.item.input_audio_transcription.delta`: Partial transcription results
/// ```json
/// {
@@ -109,6 +167,7 @@ partial void ProcessRealtimeTranscriptionResponse( /// /// Default Value: pcm_s16le_16000 /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -162,6 +221,200 @@ partial void ProcessRealtimeTranscriptionResponse( public async global::System.Threading.Tasks.Task RealtimeTranscriptionAsync( string model, global::Together.RealtimeTranscriptionInputAudioFormat inputAudioFormat = global::Together.RealtimeTranscriptionInputAudioFormat.PcmS16le16000, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + await RealtimeTranscriptionAsResponseAsync( + model: model, + inputAudioFormat: inputAudioFormat, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + } + /// + /// Real-time audio transcription via WebSocket
+ /// Establishes a WebSocket connection for real-time audio transcription. This endpoint uses WebSocket protocol (wss://api.together.ai/v1/realtime) for bidirectional streaming communication.
+ /// **Connection Setup:**
+ /// - Protocol: WebSocket (wss://)
+ /// - Authentication: Pass API key as Bearer token in Authorization header
+ /// - Parameters: Sent as query parameters (model, input_audio_format)
+ /// **Client Events:**
+ /// - `input_audio_buffer.append`: Send audio chunks as base64-encoded data
+ /// ```json
+ /// {
+ /// "type": "input_audio_buffer.append",
+ /// "audio": "<base64_encoded_audio_chunk>"
+ /// }
+ /// ```
+ /// - `input_audio_buffer.commit`: Signal end of audio stream. When VAD is enabled, the server automatically detects speech boundaries and emits `completed` events. When VAD is disabled, you must send `commit` to trigger transcription of the buffered audio.
+ /// ```json
+ /// {
+ /// "type": "input_audio_buffer.commit"
+ /// }
+ /// ```
+ /// - `transcription_session.updated`: Update session configuration, including Voice Activity Detection (VAD) parameters. Send this after receiving `session.created`. Can also be sent at any time during the session to change VAD settings.
+ /// ```json
+ /// {
+ /// "type": "transcription_session.updated",
+ /// "session": {
+ /// "turn_detection": {
+ /// "type": "server_vad",
+ /// "threshold": 0.3,
+ /// "min_silence_duration_ms": 500,
+ /// "min_speech_duration_ms": 250,
+ /// "max_speech_duration_s": 5.0,
+ /// "speech_pad_ms": 250
+ /// }
+ /// }
+ /// }
+ /// ```
+ /// To disable VAD entirely (manual commit mode), set `turn_detection` to `null`:
+ /// ```json
+ /// {
+ /// "type": "transcription_session.updated",
+ /// "session": {
+ /// "turn_detection": null
+ /// }
+ /// }
+ /// ```
+ /// **Voice Activity Detection (VAD)**
+ /// VAD controls how the server automatically detects speech segments in the audio stream. When enabled (the default), the server uses Silero VAD to identify speech regions and emits transcription events as each segment completes. When disabled, you must manually call `input_audio_buffer.commit` to trigger transcription.
+ /// VAD can be configured in two ways:
+ /// 1. **Query parameters** at connection time: `turn_detection=server_vad&threshold=0.3&min_silence_duration_ms=500`
+ /// 2. **Session message** after connection: Send `transcription_session.updated` with a `turn_detection` object (see above)
+ /// To disable VAD at connection time, use `turn_detection=none` as a query parameter.
+ /// **VAD Parameters:**
+ /// All parameters are optional. Omitted fields use their defaults.
+ /// | Parameter | Type | Default | Description |
+ /// |-----------|------|---------|-------------|
+ /// | `type` | string | `server_vad` | VAD mode. Use `server_vad` to enable, or set `turn_detection` to `null` to disable. |
+ /// | `threshold` | float | `0.3` | Speech probability threshold (0.0–1.0). Audio frames with probability above this value are classified as speech. Lower values detect more speech but may increase false positives. For low-SNR audio (e.g., 8kHz phone calls), values of 0.01–0.2 may work better. |
+ /// | `min_silence_duration_ms` | int | `500` | Minimum silence duration in milliseconds before ending a speech segment. Higher values merge nearby speech bursts into single segments. For phone calls with mid-sentence pauses, 2000–5000ms prevents over-segmentation. |
+ /// | `min_speech_duration_ms` | int | `250` | Minimum speech segment duration in milliseconds. Segments shorter than this are discarded. Filters out brief noise bursts or clicks. |
+ /// | `max_speech_duration_s` | float | `5.0` | Maximum speech segment duration in seconds. Segments longer than this are force-split at the longest internal silence gap. Useful for continuous speech without natural pauses. |
+ /// | `speech_pad_ms` | int | `250` | Padding in milliseconds added to the start and end of each detected segment. Prevents clipping speech edges. When padding would cause adjacent segments to overlap, the gap is split at the midpoint instead. |
+ /// **Server Events:**
+ /// - `session.created`: Initial session confirmation (sent first)
+ /// ```json
+ /// {
+ /// "type": "session.created",
+ /// "session": {
+ /// "id": "session-id",
+ /// "object": "realtime.session",
+ /// "modalities": ["audio"],
+ /// "model": "openai/whisper-large-v3"
+ /// }
+ /// }
+ /// ```
+ /// - `transcription_session.updated`: Confirms session configuration was applied. Sent in response to a client `transcription_session.updated` message.
+ /// ```json
+ /// {
+ /// "type": "transcription_session.updated",
+ /// "session": {
+ /// "turn_detection": {
+ /// "type": "server_vad",
+ /// "threshold": 0.3,
+ /// "min_silence_duration_ms": 500,
+ /// "min_speech_duration_ms": 250,
+ /// "max_speech_duration_s": 5.0,
+ /// "speech_pad_ms": 250
+ /// }
+ /// }
+ /// }
+ /// ```
+ /// - `conversation.item.input_audio_transcription.delta`: Partial transcription results
+ /// ```json
+ /// {
+ /// "type": "conversation.item.input_audio_transcription.delta",
+ /// "delta": "The quick brown"
+ /// }
+ /// ```
+ /// - `conversation.item.input_audio_transcription.completed`: Final transcription
+ /// ```json
+ /// {
+ /// "type": "conversation.item.input_audio_transcription.completed",
+ /// "transcript": "The quick brown fox jumps over the lazy dog"
+ /// }
+ /// ```
+ /// - `conversation.item.input_audio_transcription.failed`: Error occurred
+ /// ```json
+ /// {
+ /// "type": "conversation.item.input_audio_transcription.failed",
+ /// "error": {
+ /// "message": "Error description",
+ /// "type": "invalid_request_error",
+ /// "param": null,
+ /// "code": "invalid_api_key"
+ /// }
+ /// }
+ /// ```
+ /// **Error Codes:**
+ /// - `invalid_api_key`: Invalid API key provided (401)
+ /// - `missing_api_key`: Authorization header missing (401)
+ /// - `model_not_available`: Invalid or unavailable model (400)
+ /// - Unsupported audio format errors (400) + ///
+ /// + /// The Whisper model to use for transcription + /// + /// + /// Default Value: pcm_s16le_16000 + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// import asyncio
+ /// import websockets
+ /// import json
+ /// import base64
+ /// import os
+ /// async def transcribe_audio():
+ /// api_key = os.environ.get("TOGETHER_API_KEY")
+ /// url = "wss://api.together.ai/v1/realtime?model=openai/whisper-large-v3&input_audio_format=pcm_s16le_16000"
+ /// headers = {
+ /// "Authorization": f"Bearer {api_key}"
+ /// }
+ /// async with websockets.connect(url, additional_headers=headers) as ws:
+ /// # Read audio file
+ /// with open("audio.wav", "rb") as f:
+ /// audio_data = f.read()
+ /// # Send audio in chunks with delay to simulate real-time
+ /// chunk_size = 8192
+ /// bytes_per_second = 16000 * 2 # 16kHz * 2 bytes (16-bit)
+ /// delay_per_chunk = chunk_size / bytes_per_second
+ /// for i in range(0, len(audio_data), chunk_size):
+ /// chunk = audio_data[i:i+chunk_size]
+ /// base64_chunk = base64.b64encode(chunk).decode('utf-8')
+ /// await ws.send(json.dumps({
+ /// "type": "input_audio_buffer.append",
+ /// "audio": base64_chunk
+ /// }))
+ /// # Simulate real-time streaming
+ /// if i + chunk_size < len(audio_data):
+ /// await asyncio.sleep(delay_per_chunk)
+ /// # Commit the audio buffer
+ /// await ws.send(json.dumps({
+ /// "type": "input_audio_buffer.commit"
+ /// }))
+ /// # Receive transcription results
+ /// async for message in ws:
+ /// data = json.loads(message)
+ /// if data["type"] == "conversation.item.input_audio_transcription.delta":
+ /// print(f"Partial: {data['delta']}")
+ /// elif data["type"] == "conversation.item.input_audio_transcription.completed":
+ /// print(f"Final: {data['transcript']}")
+ /// break
+ /// elif data["type"] == "conversation.item.input_audio_transcription.failed":
+ /// error = data.get("error", {})
+ /// print(f"Error: {error.get('message')}")
+ /// break
+ /// asyncio.run(transcribe_audio()) + ///
+ public async global::System.Threading.Tasks.Task RealtimeTranscriptionAsResponseAsync( + string model, + global::Together.RealtimeTranscriptionInputAudioFormat inputAudioFormat = global::Together.RealtimeTranscriptionInputAudioFormat.PcmS16le16000, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -177,26 +430,48 @@ partial void ProcessRealtimeTranscriptionResponse( securityRequirements: s_RealtimeTranscriptionSecurityRequirements, operationName: "RealtimeTranscriptionAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/realtime", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddRequiredParameter("model", model) - .AddRequiredParameter("input_audio_format", inputAudioFormat.ToValueString()) - ; - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/realtime", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddRequiredParameter("model", model) + .AddRequiredParameter("input_audio_format", inputAudioFormat.ToValueString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -206,130 +481,315 @@ partial void ProcessRealtimeTranscriptionResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareRealtimeTranscriptionRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - model: model, - inputAudioFormat: inputAudioFormat); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareRealtimeTranscriptionRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + model: model!, + inputAudioFormat: inputAudioFormat!); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessRealtimeTranscriptionResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 101) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_101 = null; - global::System.Exception? __exception_101 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RealtimeTranscription", + methodName: "RealtimeTranscriptionAsync", + pathTemplate: "\"/realtime\"", + httpMethod: "GET", + 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 { - __content_101 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_101 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RealtimeTranscription", + methodName: "RealtimeTranscriptionAsync", + pathTemplate: "\"/realtime\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RealtimeTranscription", + methodName: "RealtimeTranscriptionAsync", + pathTemplate: "\"/realtime\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_101 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_101 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_101, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_101, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - - try + response: __response); + ProcessRealtimeTranscriptionResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RealtimeTranscription", + methodName: "RealtimeTranscriptionAsync", + pathTemplate: "\"/realtime\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RealtimeTranscription", + methodName: "RealtimeTranscriptionAsync", + pathTemplate: "\"/realtime\"", + httpMethod: "GET", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + // + if ((int)__response.StatusCode == 101) + { + string? __content_101 = null; + global::System.Exception? __exception_101 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_101 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_101 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_101 = __ex; + } + + throw new global::Together.ApiException( + message: __content_101 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_101, + statusCode: __response.StatusCode) + { + ResponseBody = __content_101, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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(); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri); + } + 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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.AudioClient.RealtimeTts.g.cs b/src/libs/Together/Generated/Together.AudioClient.RealtimeTts.g.cs index ffb5ae9f..0f229fe1 100644 --- a/src/libs/Together/Generated/Together.AudioClient.RealtimeTts.g.cs +++ b/src/libs/Together/Generated/Together.AudioClient.RealtimeTts.g.cs @@ -14,6 +14,7 @@ public partial class AudioClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -28,13 +29,15 @@ partial void PrepareRealtimeTtsArguments( global::System.Net.Http.HttpClient httpClient, ref global::Together.RealtimeTtsModel? model, ref string? voice, - ref int? maxPartialLength); + ref int? maxPartialLength, + ref string? language); partial void PrepareRealtimeTtsRequest( global::System.Net.Http.HttpClient httpClient, global::System.Net.Http.HttpRequestMessage httpRequestMessage, global::Together.RealtimeTtsModel? model, string? voice, - int? maxPartialLength); + int? maxPartialLength, + string? language); partial void ProcessRealtimeTtsResponse( global::System.Net.Http.HttpClient httpClient, global::System.Net.Http.HttpResponseMessage httpResponseMessage); @@ -45,14 +48,17 @@ partial void ProcessRealtimeTtsResponse( /// **Connection Setup:**
/// - Protocol: WebSocket (wss://)
/// - Authentication: Pass API key as Bearer token in Authorization header
- /// - Parameters: Sent as query parameters (model, voice, max_partial_length)
+ /// - Parameters: Sent as query parameters (model, voice, max_partial_length, language)
/// **Client Events:**
- /// - `tts_session.updated`: Update session parameters like voice
+ /// - `tts_session.updated`: Update session parameters like voice. The `session` object also accepts an `extra_params` field for additional model-specific parameters that fine-tune speech generation behavior, such as `pronunciation_dict` (a list of pronunciation rules for specific characters or symbols, where each entry uses the format `"<source>/<replacement>"` (e.g., `["omg/oh my god"]`) to override how the model pronounces matching tokens).
/// ```json
/// {
/// "type": "tts_session.updated",
/// "session": {
- /// "voice": "tara"
+ /// "voice": "tara",
+ /// "extra_params": {
+ /// "pronunciation_dict": ["omg/oh my god"]
+ /// }
/// }
/// }
/// ```
@@ -130,9 +136,9 @@ partial void ProcessRealtimeTtsResponse( /// - The partial text exceeds `max_partial_length` characters (default: 250)
/// - The `input_text_buffer.commit` event is received
/// **Audio Format:**
- /// - Format: WAV (PCM s16le)
+ /// - Format: Raw PCM (s16le, mono)
/// - Sample Rate: 24000 Hz
- /// - Encoding: Base64
+ /// - Encoding: Base64 (per delta event)
/// - Delivered via `conversation.item.audio_output.delta` events
/// **Error Codes:**
/// - `invalid_api_key`: Invalid API key provided (401)
@@ -153,6 +159,12 @@ partial void ProcessRealtimeTtsResponse( /// even without a sentence ending. Helps reduce latency for long text without punctuation.
/// Default Value: 250 /// + /// + /// Language or locale of input text. Accepts ISO 639-1 language codes (e.g., `en`, `fr`, `es`, `zh`) as well as locale codes for region-specific variants. Locale codes must be lowercase (e.g., `zh-hk` for Cantonese). Can also be set via `tts_session.updated` event.
+ /// Default Value: en
+ /// Example: en + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -163,7 +175,7 @@ partial void ProcessRealtimeTtsResponse( /// import os
/// async def generate_speech():
/// api_key = os.environ.get("TOGETHER_API_KEY")
- /// url = "wss://api.together.ai/v1/audio/speech/websocket?model=hexgrad/Kokoro-82M&voice=tara"
+ /// url = "wss://api.together.ai/v1/audio/speech/websocket?model=hexgrad/Kokoro-82M&voice=af_heart"
/// headers = {
/// "Authorization": f"Bearer {api_key}"
/// }
@@ -171,6 +183,9 @@ partial void ProcessRealtimeTtsResponse( /// # Wait for session created
/// session_msg = await ws.recv()
/// session_data = json.loads(session_msg)
+ /// if session_data.get("type") != "session.created":
+ /// print(f"Failed to start session: {session_data}")
+ /// return
/// print(f"Session created: {session_data['session']['id']}")
/// # Send text for TTS
/// text_chunks = [
@@ -206,10 +221,10 @@ partial void ProcessRealtimeTtsResponse( /// error = data.get("error", {})
/// print(f"Error: {error.get('message')}")
/// break
- /// # Save the audio to a file
- /// with open("output.wav", "wb") as f:
+ /// # Save the raw PCM samples to a file
+ /// with open("output.pcm", "wb") as f:
/// f.write(audio_data)
- /// print("Audio saved to output.wav")
+ /// print("Audio saved to output.pcm")
/// # Run send and receive concurrently
/// await asyncio.gather(send_text(), receive_audio())
/// asyncio.run(generate_speech()) @@ -218,6 +233,212 @@ partial void ProcessRealtimeTtsResponse( global::Together.RealtimeTtsModel? model = default, string? voice = default, int? maxPartialLength = default, + string? language = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + await RealtimeTtsAsResponseAsync( + model: model, + voice: voice, + maxPartialLength: maxPartialLength, + language: language, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + } + /// + /// Real-time text-to-speech via WebSocket
+ /// Establishes a WebSocket connection for real-time text-to-speech generation. This endpoint uses WebSocket protocol (wss://api.together.ai/v1/audio/speech/websocket) for bidirectional streaming communication.
+ /// **Connection Setup:**
+ /// - Protocol: WebSocket (wss://)
+ /// - Authentication: Pass API key as Bearer token in Authorization header
+ /// - Parameters: Sent as query parameters (model, voice, max_partial_length, language)
+ /// **Client Events:**
+ /// - `tts_session.updated`: Update session parameters like voice. The `session` object also accepts an `extra_params` field for additional model-specific parameters that fine-tune speech generation behavior, such as `pronunciation_dict` (a list of pronunciation rules for specific characters or symbols, where each entry uses the format `"<source>/<replacement>"` (e.g., `["omg/oh my god"]`) to override how the model pronounces matching tokens).
+ /// ```json
+ /// {
+ /// "type": "tts_session.updated",
+ /// "session": {
+ /// "voice": "tara",
+ /// "extra_params": {
+ /// "pronunciation_dict": ["omg/oh my god"]
+ /// }
+ /// }
+ /// }
+ /// ```
+ /// - `input_text_buffer.append`: Send text chunks for TTS generation
+ /// ```json
+ /// {
+ /// "type": "input_text_buffer.append",
+ /// "text": "Hello, this is a test."
+ /// }
+ /// ```
+ /// - `input_text_buffer.clear`: Clear the buffered text
+ /// ```json
+ /// {
+ /// "type": "input_text_buffer.clear"
+ /// }
+ /// ```
+ /// - `input_text_buffer.commit`: Signal end of text input and process remaining text
+ /// ```json
+ /// {
+ /// "type": "input_text_buffer.commit"
+ /// }
+ /// ```
+ /// **Server Events:**
+ /// - `session.created`: Initial session confirmation (sent first)
+ /// ```json
+ /// {
+ /// "event_id": "evt_123456",
+ /// "type": "session.created",
+ /// "session": {
+ /// "id": "session-id",
+ /// "object": "realtime.tts.session",
+ /// "modalities": ["text", "audio"],
+ /// "model": "hexgrad/Kokoro-82M",
+ /// "voice": "tara"
+ /// }
+ /// }
+ /// ```
+ /// - `conversation.item.input_text.received`: Acknowledgment that text was received
+ /// ```json
+ /// {
+ /// "type": "conversation.item.input_text.received",
+ /// "text": "Hello, this is a test."
+ /// }
+ /// ```
+ /// - `conversation.item.audio_output.delta`: Audio chunks as base64-encoded data
+ /// ```json
+ /// {
+ /// "type": "conversation.item.audio_output.delta",
+ /// "item_id": "tts_1",
+ /// "delta": "<base64_encoded_audio_chunk>"
+ /// }
+ /// ```
+ /// - `conversation.item.audio_output.done`: Audio generation complete for an item
+ /// ```json
+ /// {
+ /// "type": "conversation.item.audio_output.done",
+ /// "item_id": "tts_1"
+ /// }
+ /// ```
+ /// - `conversation.item.tts.failed`: Error occurred
+ /// ```json
+ /// {
+ /// "type": "conversation.item.tts.failed",
+ /// "error": {
+ /// "message": "Error description",
+ /// "type": "invalid_request_error",
+ /// "param": null,
+ /// "code": "invalid_api_key"
+ /// }
+ /// }
+ /// ```
+ /// **Text Processing:**
+ /// - Partial text (no sentence ending) is held in buffer until:
+ /// - We believe that the text is complete enough to be processed for TTS generation
+ /// - The partial text exceeds `max_partial_length` characters (default: 250)
+ /// - The `input_text_buffer.commit` event is received
+ /// **Audio Format:**
+ /// - Format: Raw PCM (s16le, mono)
+ /// - Sample Rate: 24000 Hz
+ /// - Encoding: Base64 (per delta event)
+ /// - Delivered via `conversation.item.audio_output.delta` events
+ /// **Error Codes:**
+ /// - `invalid_api_key`: Invalid API key provided (401)
+ /// - `missing_api_key`: Authorization header missing (401)
+ /// - `model_not_available`: Invalid or unavailable model (400)
+ /// - Invalid text format errors (400) + ///
+ /// + /// The TTS model to use for speech generation. Can also be set via `tts_session.updated` event.
+ /// Default Value: hexgrad/Kokoro-82M + /// + /// + /// The voice to use for speech generation. Default is 'tara'.
+ /// Available voices vary by model. Can also be updated via `tts_session.updated` event. + /// + /// + /// Maximum number of characters in partial text before forcing TTS generation
+ /// even without a sentence ending. Helps reduce latency for long text without punctuation.
+ /// Default Value: 250 + /// + /// + /// Language or locale of input text. Accepts ISO 639-1 language codes (e.g., `en`, `fr`, `es`, `zh`) as well as locale codes for region-specific variants. Locale codes must be lowercase (e.g., `zh-hk` for Cantonese). Can also be set via `tts_session.updated` event.
+ /// Default Value: en
+ /// Example: en + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// import asyncio
+ /// import websockets
+ /// import json
+ /// import base64
+ /// import os
+ /// async def generate_speech():
+ /// api_key = os.environ.get("TOGETHER_API_KEY")
+ /// url = "wss://api.together.ai/v1/audio/speech/websocket?model=hexgrad/Kokoro-82M&voice=af_heart"
+ /// headers = {
+ /// "Authorization": f"Bearer {api_key}"
+ /// }
+ /// async with websockets.connect(url, additional_headers=headers) as ws:
+ /// # Wait for session created
+ /// session_msg = await ws.recv()
+ /// session_data = json.loads(session_msg)
+ /// if session_data.get("type") != "session.created":
+ /// print(f"Failed to start session: {session_data}")
+ /// return
+ /// print(f"Session created: {session_data['session']['id']}")
+ /// # Send text for TTS
+ /// text_chunks = [
+ /// "Hello, this is a test.",
+ /// "This is the second sentence.",
+ /// "And this is the final one."
+ /// ]
+ /// async def send_text():
+ /// for chunk in text_chunks:
+ /// await ws.send(json.dumps({
+ /// "type": "input_text_buffer.append",
+ /// "text": chunk
+ /// }))
+ /// await asyncio.sleep(0.5) # Simulate typing
+ /// # Commit to process any remaining text
+ /// await ws.send(json.dumps({
+ /// "type": "input_text_buffer.commit"
+ /// }))
+ /// async def receive_audio():
+ /// audio_data = bytearray()
+ /// async for message in ws:
+ /// data = json.loads(message)
+ /// if data["type"] == "conversation.item.input_text.received":
+ /// print(f"Text received: {data['text']}")
+ /// elif data["type"] == "conversation.item.audio_output.delta":
+ /// # Decode base64 audio chunk
+ /// audio_chunk = base64.b64decode(data['delta'])
+ /// audio_data.extend(audio_chunk)
+ /// print(f"Received audio chunk for item {data['item_id']}")
+ /// elif data["type"] == "conversation.item.audio_output.done":
+ /// print(f"Audio generation complete for item {data['item_id']}")
+ /// elif data["type"] == "conversation.item.tts.failed":
+ /// error = data.get("error", {})
+ /// print(f"Error: {error.get('message')}")
+ /// break
+ /// # Save the raw PCM samples to a file
+ /// with open("output.pcm", "wb") as f:
+ /// f.write(audio_data)
+ /// print("Audio saved to output.pcm")
+ /// # Run send and receive concurrently
+ /// await asyncio.gather(send_text(), receive_audio())
+ /// asyncio.run(generate_speech()) + ///
+ public async global::System.Threading.Tasks.Task RealtimeTtsAsResponseAsync( + global::Together.RealtimeTtsModel? model = default, + string? voice = default, + int? maxPartialLength = default, + string? language = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -226,7 +447,8 @@ partial void ProcessRealtimeTtsResponse( httpClient: HttpClient, model: ref model, voice: ref voice, - maxPartialLength: ref maxPartialLength); + maxPartialLength: ref maxPartialLength, + language: ref language); var __authorizations = global::Together.EndPointSecurityResolver.ResolveAuthorizations( @@ -234,27 +456,50 @@ partial void ProcessRealtimeTtsResponse( securityRequirements: s_RealtimeTtsSecurityRequirements, operationName: "RealtimeTtsAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/audio/speech/websocket", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("model", model?.ToValueString()) - .AddOptionalParameter("voice", voice) - .AddOptionalParameter("max_partial_length", maxPartialLength?.ToString()) - ; - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/audio/speech/websocket", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("model", model?.ToValueString()) + .AddOptionalParameter("voice", voice) + .AddOptionalParameter("max_partial_length", maxPartialLength?.ToString()) + .AddOptionalParameter("language", language) + ; + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -264,131 +509,317 @@ partial void ProcessRealtimeTtsResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareRealtimeTtsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - model: model, - voice: voice, - maxPartialLength: maxPartialLength); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareRealtimeTtsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + model: model, + voice: voice, + maxPartialLength: maxPartialLength, + language: language); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessRealtimeTtsResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 101) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_101 = null; - global::System.Exception? __exception_101 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RealtimeTts", + methodName: "RealtimeTtsAsync", + pathTemplate: "\"/audio/speech/websocket\"", + httpMethod: "GET", + 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 { - __content_101 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_101 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RealtimeTts", + methodName: "RealtimeTtsAsync", + pathTemplate: "\"/audio/speech/websocket\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RealtimeTts", + methodName: "RealtimeTtsAsync", + pathTemplate: "\"/audio/speech/websocket\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_101 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_101 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_101, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_101, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - - try - { - __response.EnsureSuccessStatusCode(); - - } - catch (global::System.Exception __ex) + response: __response); + ProcessRealtimeTtsResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RealtimeTts", + methodName: "RealtimeTtsAsync", + pathTemplate: "\"/audio/speech/websocket\"", + httpMethod: "GET", + 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 - { - try + else { - __response.EnsureSuccessStatusCode(); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RealtimeTts", + methodName: "RealtimeTtsAsync", + pathTemplate: "\"/audio/speech/websocket\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + // + if ((int)__response.StatusCode == 101) + { + string? __content_101 = null; + global::System.Exception? __exception_101 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_101 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_101 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_101 = __ex; + } + + throw new global::Together.ApiException( + message: __content_101 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_101, + statusCode: __response.StatusCode) + { + ResponseBody = __content_101, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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(); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri); + } + 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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.AudioClient.g.cs b/src/libs/Together/Generated/Together.AudioClient.g.cs index 519002cf..9e0dc373 100644 --- a/src/libs/Together/Generated/Together.AudioClient.g.cs +++ b/src/libs/Together/Generated/Together.AudioClient.g.cs @@ -12,7 +12,7 @@ public sealed partial class AudioClient : global::Together.IAudioClient, global: /// /// /// - public const string DefaultBaseUrl = "https://api.together.xyz/v1"; + public const string DefaultBaseUrl = "https://api.together.ai/v1"; private bool _disposeHttpClient = true; @@ -30,6 +30,12 @@ public sealed partial class AudioClient : global::Together.IAudioClient, global: #if DEBUG = true; #endif + + /// + public global::Together.AutoSDKClientOptions Options { get; } + + + internal global::Together.AutoSDKServerConfiguration AutoSDKServerConfiguration { get; set; } = new global::Together.AutoSDKServerConfiguration(); /// /// /// @@ -49,13 +55,62 @@ public AudioClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the AudioClient with explicit options but no base URL override. + /// Skips passing baseUri so the default base URL from the OpenAPI spec applies. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public AudioClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, + bool disposeHttpClient = true) : this( + httpClient, + baseUri: null, + authorizations, + options, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the AudioClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public AudioClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Together.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; + AutoSDKServerConfiguration.ExplicitBaseUri = baseUri ?? httpClient?.BaseAddress; + Initialized(HttpClient); } diff --git a/src/libs/Together/Generated/Together.AutoSDKHttpResponse.g.cs b/src/libs/Together/Generated/Together.AutoSDKHttpResponse.g.cs new file mode 100644 index 00000000..d5971c34 --- /dev/null +++ b/src/libs/Together/Generated/Together.AutoSDKHttpResponse.g.cs @@ -0,0 +1,121 @@ + +#nullable enable + +namespace Together +{ + /// + /// Represents a successful HTTP response with status code and headers. + /// + public partial class AutoSDKHttpResponse + { + /// + /// Initializes a new instance of the class. + /// + public AutoSDKHttpResponse( + global::System.Net.HttpStatusCode statusCode, + global::System.Collections.Generic.Dictionary> headers) + : this( + statusCode: statusCode, + headers: headers, + requestUri: null) + { + } + + /// + /// Initializes a new instance of the class. + /// + public AutoSDKHttpResponse( + global::System.Net.HttpStatusCode statusCode, + global::System.Collections.Generic.Dictionary> headers, + global::System.Uri? requestUri) + { + StatusCode = statusCode; + Headers = headers ?? throw new global::System.ArgumentNullException(nameof(headers)); + RequestUri = requestUri; + } + + /// + /// Gets the HTTP status code. + /// + public global::System.Net.HttpStatusCode StatusCode { get; } + /// + /// Gets the response headers. + /// + public global::System.Collections.Generic.Dictionary> Headers { get; } + /// + /// Gets the final request URI associated with the response. + /// + public global::System.Uri? RequestUri { get; } + + internal static global::System.Collections.Generic.Dictionary> CreateHeaders( + global::System.Net.Http.HttpResponseMessage response) + { + response = response ?? throw new global::System.ArgumentNullException(nameof(response)); + + var headers = global::System.Linq.Enumerable.ToDictionary( + response.Headers, + static header => header.Key, + static header => (global::System.Collections.Generic.IEnumerable)global::System.Linq.Enumerable.ToArray(header.Value), + global::System.StringComparer.OrdinalIgnoreCase); + + if (response.Content?.Headers == null) + { + return headers; + } + + foreach (var header in response.Content.Headers) + { + if (headers.TryGetValue(header.Key, out var existingValues)) + { + headers[header.Key] = global::System.Linq.Enumerable.ToArray( + global::System.Linq.Enumerable.Concat(existingValues, header.Value)); + } + else + { + headers[header.Key] = global::System.Linq.Enumerable.ToArray(header.Value); + } + } + + return headers; + } + } + + /// + /// Represents a successful HTTP response with status code, headers, and body. + /// + public partial class AutoSDKHttpResponse : AutoSDKHttpResponse + { + /// + /// Initializes a new instance of the class. + /// + public AutoSDKHttpResponse( + global::System.Net.HttpStatusCode statusCode, + global::System.Collections.Generic.Dictionary> headers, + T body) + : this( + statusCode: statusCode, + headers: headers, + requestUri: null, + body: body) + { + } + + /// + /// Initializes a new instance of the class. + /// + public AutoSDKHttpResponse( + global::System.Net.HttpStatusCode statusCode, + global::System.Collections.Generic.Dictionary> headers, + global::System.Uri? requestUri, + T body) + : base(statusCode, headers, requestUri) + { + Body = body; + } + + /// + /// Gets the response body. + /// + public T Body { get; } + } +} \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.BatchesClient.CreateBatches.g.cs b/src/libs/Together/Generated/Together.BatchesClient.CreateBatches.g.cs index ec47dfa5..2d999b02 100644 --- a/src/libs/Together/Generated/Together.BatchesClient.CreateBatches.g.cs +++ b/src/libs/Together/Generated/Together.BatchesClient.CreateBatches.g.cs @@ -14,6 +14,7 @@ public partial class BatchesClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,6 +46,7 @@ partial void ProcessCreateBatchesResponseContent( /// Create a new batch job with the given input file and endpoint /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -60,6 +62,40 @@ partial void ProcessCreateBatchesResponseContent( public async global::System.Threading.Tasks.Task CreateBatchesAsync( global::Together.CreateBatchRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreateBatchesAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Create a batch job
+ /// Create a new batch job with the given input file and endpoint + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// batch = client.batches.create(input_file_id="file_id", endpoint="/v1/chat/completions")
+ /// print(batch.job) + ///
+ public async global::System.Threading.Tasks.Task> CreateBatchesAsResponseAsync( + + global::Together.CreateBatchRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -76,22 +112,44 @@ partial void ProcessCreateBatchesResponseContent( securityRequirements: s_CreateBatchesSecurityRequirements, operationName: "CreateBatchesAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/batches", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/batches", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -101,277 +159,465 @@ partial void ProcessCreateBatchesResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateBatchesRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateBatchesRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateBatchesResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Bad Request - if ((int)__response.StatusCode == 400) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - global::Together.BatchErrorResponse? __value_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createBatches", + methodName: "CreateBatchesAsync", + pathTemplate: "\"/batches\"", + 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 { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = global::Together.BatchErrorResponse.FromJson(__content_400, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createBatches", + methodName: "CreateBatchesAsync", + pathTemplate: "\"/batches\"", + 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; + } - __value_400 = global::Together.BatchErrorResponse.FromJson(__content_400, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } - throw new global::Together.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Unauthorized - if ((int)__response.StatusCode == 401) - { - string? __content_401 = null; - global::System.Exception? __exception_401 = null; - global::Together.BatchErrorResponse? __value_401 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_401 = global::Together.BatchErrorResponse.FromJson(__content_401, JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createBatches", + methodName: "CreateBatchesAsync", + pathTemplate: "\"/batches\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_401 = global::Together.BatchErrorResponse.FromJson(__content_401, JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_401 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_401, - statusCode: __response.StatusCode) - { - ResponseBody = __content_401, - ResponseObject = __value_401, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Too Many Requests - if ((int)__response.StatusCode == 429) - { - string? __content_429 = null; - global::System.Exception? __exception_429 = null; - global::Together.BatchErrorResponse? __value_429 = null; - try + using (__response) { - if (ReadResponseAsString) - { - __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_429 = global::Together.BatchErrorResponse.FromJson(__content_429, JsonSerializerContext); - } - else - { - __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_429 = global::Together.BatchErrorResponse.FromJson(__content_429, JsonSerializerContext); - } + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateBatchesResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createBatches", + methodName: "CreateBatchesAsync", + pathTemplate: "\"/batches\"", + 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); } - catch (global::System.Exception __ex) + else { - __exception_429 = __ex; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createBatches", + methodName: "CreateBatchesAsync", + pathTemplate: "\"/batches\"", + 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); } + // Bad Request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Together.BatchErrorResponse? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Together.BatchErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - throw new global::Together.ApiException( - message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_429, - statusCode: __response.StatusCode) - { - ResponseBody = __content_429, - ResponseObject = __value_429, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Internal Server Error - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - global::Together.BatchErrorResponse? __value_500 = null; - try - { - if (ReadResponseAsString) - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.BatchErrorResponse.FromJson(__content_500, JsonSerializerContext); - } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __value_400 = global::Together.BatchErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } - __value_500 = global::Together.BatchErrorResponse.FromJson(__content_500, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_500 = __ex; - } + throw new global::Together.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unauthorized + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Together.BatchErrorResponse? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Together.BatchErrorResponse.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) - { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } + __value_401 = global::Together.BatchErrorResponse.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + throw new global::Together.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseObject = __value_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Too Many Requests + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Together.BatchErrorResponse? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Together.BatchErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessCreateBatchesResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __value_429 = global::Together.BatchErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } - try - { - __response.EnsureSuccessStatusCode(); + throw new global::Together.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseObject = __value_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal Server Error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Together.BatchErrorResponse? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Together.BatchErrorResponse.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - global::Together.BatchJobWithWarning.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - } - catch (global::System.Exception __ex) - { - throw new global::Together.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 - cancellationToken -#endif - ).ConfigureAwait(false); + __value_500 = global::Together.BatchErrorResponse.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } - return - await global::Together.BatchJobWithWarning.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessCreateBatchesResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.BatchJobWithWarning.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.BatchJobWithWarning.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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 a batch job
/// Create a new batch job with the given input file and endpoint ///
/// - /// The endpoint to use for batch processing
+ /// The endpoint to use for batch processing. Each line of the uploaded input file is dispatched against this endpoint.
+ /// - `/v1/chat/completions` — chat completion batches
+ /// - `/v1/audio/transcriptions` — audio transcription batches (e.g. `openai/whisper-large-v3`)
+ /// - `/v1/audio/translations` — audio translation batches
/// Example: /v1/chat/completions /// /// @@ -390,14 +636,16 @@ partial void ProcessCreateBatchesResponseContent( /// Model to use for processing batch requests
/// Example: Qwen/Qwen3.5-9B /// + /// 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 CreateBatchesAsync( - string endpoint, + global::Together.CreateBatchRequestEndpoint endpoint, string inputFileId, string? completionWindow = default, int? priority = default, string? modelId = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.CreateBatchRequest @@ -411,6 +659,7 @@ partial void ProcessCreateBatchesResponseContent( return await CreateBatchesAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Together/Generated/Together.BatchesClient.CreateBatchesByIdCancel.g.cs b/src/libs/Together/Generated/Together.BatchesClient.CreateBatchesByIdCancel.g.cs index fa9ecbb7..89f73a2a 100644 --- a/src/libs/Together/Generated/Together.BatchesClient.CreateBatchesByIdCancel.g.cs +++ b/src/libs/Together/Generated/Together.BatchesClient.CreateBatchesByIdCancel.g.cs @@ -14,6 +14,7 @@ public partial class BatchesClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,6 +49,7 @@ partial void ProcessCreateBatchesByIdCancelResponseContent( /// The ID of the batch job to cancel
/// Example: batch_job_abc123def456 /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -62,6 +64,41 @@ partial void ProcessCreateBatchesByIdCancelResponseContent( /// public async global::System.Threading.Tasks.Task CreateBatchesByIdCancelAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreateBatchesByIdCancelAsResponseAsync( + id: id, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Cancel a batch job
+ /// Cancel a batch job by ID + ///
+ /// + /// The ID of the batch job to cancel
+ /// Example: batch_job_abc123def456 + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// batch = client.batches.cancel("batch_id")
+ /// print(batch) + ///
+ public async global::System.Threading.Tasks.Task> CreateBatchesByIdCancelAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -76,22 +113,44 @@ partial void ProcessCreateBatchesByIdCancelResponseContent( securityRequirements: s_CreateBatchesByIdCancelSecurityRequirements, operationName: "CreateBatchesByIdCancelAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/batches/{id}/cancel", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/batches/{id}/cancel", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -101,302 +160,487 @@ partial void ProcessCreateBatchesByIdCancelResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateBatchesByIdCancelRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateBatchesByIdCancelRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id!); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateBatchesByIdCancelResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Bad Request - if ((int)__response.StatusCode == 400) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - global::Together.BatchErrorResponse? __value_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createBatchesByIdCancel", + methodName: "CreateBatchesByIdCancelAsync", + pathTemplate: "$\"/batches/{id}/cancel\"", + 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 { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = global::Together.BatchErrorResponse.FromJson(__content_400, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createBatchesByIdCancel", + methodName: "CreateBatchesByIdCancelAsync", + pathTemplate: "$\"/batches/{id}/cancel\"", + 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; + } - __value_400 = global::Together.BatchErrorResponse.FromJson(__content_400, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } - throw new global::Together.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Unauthorized - if ((int)__response.StatusCode == 401) - { - string? __content_401 = null; - global::System.Exception? __exception_401 = null; - global::Together.BatchErrorResponse? __value_401 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_401 = global::Together.BatchErrorResponse.FromJson(__content_401, JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createBatchesByIdCancel", + methodName: "CreateBatchesByIdCancelAsync", + pathTemplate: "$\"/batches/{id}/cancel\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_401 = global::Together.BatchErrorResponse.FromJson(__content_401, JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_401 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_401, - statusCode: __response.StatusCode) - { - ResponseBody = __content_401, - ResponseObject = __value_401, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Forbidden - if ((int)__response.StatusCode == 403) - { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - global::Together.BatchErrorResponse? __value_403 = null; - try + using (__response) { - if (ReadResponseAsString) - { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_403 = global::Together.BatchErrorResponse.FromJson(__content_403, JsonSerializerContext); - } - else - { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_403 = global::Together.BatchErrorResponse.FromJson(__content_403, JsonSerializerContext); - } + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateBatchesByIdCancelResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createBatchesByIdCancel", + methodName: "CreateBatchesByIdCancelAsync", + pathTemplate: "$\"/batches/{id}/cancel\"", + 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); } - catch (global::System.Exception __ex) + else { - __exception_403 = __ex; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createBatchesByIdCancel", + methodName: "CreateBatchesByIdCancelAsync", + pathTemplate: "$\"/batches/{id}/cancel\"", + 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); } + // Bad Request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Together.BatchErrorResponse? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Together.BatchErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - throw new global::Together.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) - { - ResponseBody = __content_403, - ResponseObject = __value_403, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Not Found - if ((int)__response.StatusCode == 404) - { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; - global::Together.BatchErrorResponse? __value_404 = null; - try - { - if (ReadResponseAsString) - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = global::Together.BatchErrorResponse.FromJson(__content_404, JsonSerializerContext); - } - else - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __value_400 = global::Together.BatchErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } - __value_404 = global::Together.BatchErrorResponse.FromJson(__content_404, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_404 = __ex; - } + throw new global::Together.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unauthorized + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Together.BatchErrorResponse? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Together.BatchErrorResponse.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - throw new global::Together.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Internal Server Error - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - global::Together.BatchErrorResponse? __value_500 = null; - try - { - if (ReadResponseAsString) - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.BatchErrorResponse.FromJson(__content_500, JsonSerializerContext); - } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __value_401 = global::Together.BatchErrorResponse.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } - __value_500 = global::Together.BatchErrorResponse.FromJson(__content_500, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_500 = __ex; - } + throw new global::Together.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseObject = __value_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Forbidden + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Together.BatchErrorResponse? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Together.BatchErrorResponse.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) - { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } + __value_403 = global::Together.BatchErrorResponse.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + throw new global::Together.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseObject = __value_403, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Not Found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Together.BatchErrorResponse? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Together.BatchErrorResponse.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessCreateBatchesByIdCancelResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __value_404 = global::Together.BatchErrorResponse.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } - try - { - __response.EnsureSuccessStatusCode(); + throw new global::Together.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal Server Error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Together.BatchErrorResponse? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Together.BatchErrorResponse.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - global::Together.BatchJob.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - } - catch (global::System.Exception __ex) - { - throw new global::Together.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 - cancellationToken -#endif - ).ConfigureAwait(false); + __value_500 = global::Together.BatchErrorResponse.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } - return - await global::Together.BatchJob.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessCreateBatchesByIdCancelResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.BatchJob.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.BatchJob.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.BatchesClient.GetBatches.g.cs b/src/libs/Together/Generated/Together.BatchesClient.GetBatches.g.cs index 5ec9da9b..20809fff 100644 --- a/src/libs/Together/Generated/Together.BatchesClient.GetBatches.g.cs +++ b/src/libs/Together/Generated/Together.BatchesClient.GetBatches.g.cs @@ -14,6 +14,7 @@ public partial class BatchesClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -42,6 +43,7 @@ partial void ProcessGetBatchesResponseContent( /// List batch jobs
/// List all batch jobs for the authenticated user /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -56,6 +58,36 @@ partial void ProcessGetBatchesResponseContent( /// print(batch.id) /// public async global::System.Threading.Tasks.Task> GetBatchesAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetBatchesAsResponseAsync( + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// List batch jobs
+ /// List all batch jobs for the authenticated user + ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// batches = client.batches.list()
+ /// for batch in batches:
+ /// print(batch.id) + ///
+ public async global::System.Threading.Tasks.Task>> GetBatchesAsResponseAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +101,44 @@ partial void ProcessGetBatchesResponseContent( securityRequirements: s_GetBatchesSecurityRequirements, operationName: "GetBatchesAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/batches", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/batches", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -94,187 +148,372 @@ partial void ProcessGetBatchesResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetBatchesRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetBatchesRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); - - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetBatchesResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Unauthorized - if ((int)__response.StatusCode == 401) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_401 = null; - global::System.Exception? __exception_401 = null; - global::Together.BatchErrorResponse? __value_401 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getBatches", + methodName: "GetBatchesAsync", + pathTemplate: "\"/batches\"", + httpMethod: "GET", + 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 { - __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_401 = global::Together.BatchErrorResponse.FromJson(__content_401, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getBatches", + methodName: "GetBatchesAsync", + pathTemplate: "\"/batches\"", + httpMethod: "GET", + 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; + } - __value_401 = global::Together.BatchErrorResponse.FromJson(__content_401, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_401 = __ex; - } - throw new global::Together.ApiException( - message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_401, - statusCode: __response.StatusCode) - { - ResponseBody = __content_401, - ResponseObject = __value_401, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Internal Server Error - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - global::Together.BatchErrorResponse? __value_500 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.BatchErrorResponse.FromJson(__content_500, JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getBatches", + methodName: "GetBatchesAsync", + pathTemplate: "\"/batches\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.BatchErrorResponse.FromJson(__content_500, JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_500 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessGetBatchesResponseContent( + response: __response); + ProcessGetBatchesResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getBatches", + methodName: "GetBatchesAsync", + pathTemplate: "\"/batches\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getBatches", + methodName: "GetBatchesAsync", + pathTemplate: "\"/batches\"", + httpMethod: "GET", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Unauthorized + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Together.BatchErrorResponse? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Together.BatchErrorResponse.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_401 = global::Together.BatchErrorResponse.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Together.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseObject = __value_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal Server Error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Together.BatchErrorResponse? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Together.BatchErrorResponse.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::Together.BatchErrorResponse.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessGetBatchesResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse>( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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 = (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse>( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.BatchesClient.GetBatchesById.g.cs b/src/libs/Together/Generated/Together.BatchesClient.GetBatchesById.g.cs index 3a0719b6..e40ec7d7 100644 --- a/src/libs/Together/Generated/Together.BatchesClient.GetBatchesById.g.cs +++ b/src/libs/Together/Generated/Together.BatchesClient.GetBatchesById.g.cs @@ -14,6 +14,7 @@ public partial class BatchesClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,6 +49,7 @@ partial void ProcessGetBatchesByIdResponseContent( /// The ID of the batch job to retrieve
/// Example: batch_job_abc123def456 /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -62,6 +64,41 @@ partial void ProcessGetBatchesByIdResponseContent( /// public async global::System.Threading.Tasks.Task GetBatchesByIdAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetBatchesByIdAsResponseAsync( + id: id, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get a batch job
+ /// Get details of a batch job by ID + ///
+ /// + /// The ID of the batch job to retrieve
+ /// Example: batch_job_abc123def456 + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// batch = client.batches.retrieve("batch_id")
+ /// print(batch) + ///
+ public async global::System.Threading.Tasks.Task> GetBatchesByIdAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -76,22 +113,44 @@ partial void ProcessGetBatchesByIdResponseContent( securityRequirements: s_GetBatchesByIdSecurityRequirements, operationName: "GetBatchesByIdAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/batches/{id}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/batches/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -101,302 +160,487 @@ partial void ProcessGetBatchesByIdResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetBatchesByIdRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetBatchesByIdRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id!); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetBatchesByIdResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Bad Request - if ((int)__response.StatusCode == 400) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - global::Together.BatchErrorResponse? __value_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getBatchesById", + methodName: "GetBatchesByIdAsync", + pathTemplate: "$\"/batches/{id}\"", + httpMethod: "GET", + 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 { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = global::Together.BatchErrorResponse.FromJson(__content_400, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getBatchesById", + methodName: "GetBatchesByIdAsync", + pathTemplate: "$\"/batches/{id}\"", + httpMethod: "GET", + 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; + } - __value_400 = global::Together.BatchErrorResponse.FromJson(__content_400, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } - throw new global::Together.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Unauthorized - if ((int)__response.StatusCode == 401) - { - string? __content_401 = null; - global::System.Exception? __exception_401 = null; - global::Together.BatchErrorResponse? __value_401 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_401 = global::Together.BatchErrorResponse.FromJson(__content_401, JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getBatchesById", + methodName: "GetBatchesByIdAsync", + pathTemplate: "$\"/batches/{id}\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_401 = global::Together.BatchErrorResponse.FromJson(__content_401, JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_401 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_401, - statusCode: __response.StatusCode) - { - ResponseBody = __content_401, - ResponseObject = __value_401, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Forbidden - if ((int)__response.StatusCode == 403) - { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - global::Together.BatchErrorResponse? __value_403 = null; - try + using (__response) { - if (ReadResponseAsString) - { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_403 = global::Together.BatchErrorResponse.FromJson(__content_403, JsonSerializerContext); - } - else - { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_403 = global::Together.BatchErrorResponse.FromJson(__content_403, JsonSerializerContext); - } + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetBatchesByIdResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getBatchesById", + methodName: "GetBatchesByIdAsync", + pathTemplate: "$\"/batches/{id}\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - __exception_403 = __ex; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getBatchesById", + methodName: "GetBatchesByIdAsync", + pathTemplate: "$\"/batches/{id}\"", + httpMethod: "GET", + 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); } + // Bad Request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Together.BatchErrorResponse? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Together.BatchErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - throw new global::Together.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) - { - ResponseBody = __content_403, - ResponseObject = __value_403, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Not Found - if ((int)__response.StatusCode == 404) - { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; - global::Together.BatchErrorResponse? __value_404 = null; - try - { - if (ReadResponseAsString) - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = global::Together.BatchErrorResponse.FromJson(__content_404, JsonSerializerContext); - } - else - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __value_400 = global::Together.BatchErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } - __value_404 = global::Together.BatchErrorResponse.FromJson(__content_404, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_404 = __ex; - } + throw new global::Together.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unauthorized + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Together.BatchErrorResponse? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Together.BatchErrorResponse.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - throw new global::Together.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Internal Server Error - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - global::Together.BatchErrorResponse? __value_500 = null; - try - { - if (ReadResponseAsString) - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.BatchErrorResponse.FromJson(__content_500, JsonSerializerContext); - } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __value_401 = global::Together.BatchErrorResponse.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } - __value_500 = global::Together.BatchErrorResponse.FromJson(__content_500, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_500 = __ex; - } + throw new global::Together.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseObject = __value_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Forbidden + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Together.BatchErrorResponse? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Together.BatchErrorResponse.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) - { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } + __value_403 = global::Together.BatchErrorResponse.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + throw new global::Together.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseObject = __value_403, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Not Found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Together.BatchErrorResponse? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Together.BatchErrorResponse.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessGetBatchesByIdResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __value_404 = global::Together.BatchErrorResponse.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } - try - { - __response.EnsureSuccessStatusCode(); + throw new global::Together.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal Server Error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Together.BatchErrorResponse? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Together.BatchErrorResponse.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - global::Together.BatchJob.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - } - catch (global::System.Exception __ex) - { - throw new global::Together.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 - cancellationToken -#endif - ).ConfigureAwait(false); + __value_500 = global::Together.BatchErrorResponse.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } - return - await global::Together.BatchJob.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessGetBatchesByIdResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.BatchJob.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.BatchJob.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.BatchesClient.g.cs b/src/libs/Together/Generated/Together.BatchesClient.g.cs index 5ddc2649..722469ef 100644 --- a/src/libs/Together/Generated/Together.BatchesClient.g.cs +++ b/src/libs/Together/Generated/Together.BatchesClient.g.cs @@ -12,7 +12,7 @@ public sealed partial class BatchesClient : global::Together.IBatchesClient, glo /// /// /// - public const string DefaultBaseUrl = "https://api.together.xyz/v1"; + public const string DefaultBaseUrl = "https://api.together.ai/v1"; private bool _disposeHttpClient = true; @@ -30,6 +30,12 @@ public sealed partial class BatchesClient : global::Together.IBatchesClient, glo #if DEBUG = true; #endif + + /// + public global::Together.AutoSDKClientOptions Options { get; } + + + internal global::Together.AutoSDKServerConfiguration AutoSDKServerConfiguration { get; set; } = new global::Together.AutoSDKServerConfiguration(); /// /// /// @@ -49,13 +55,62 @@ public BatchesClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the BatchesClient with explicit options but no base URL override. + /// Skips passing baseUri so the default base URL from the OpenAPI spec applies. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public BatchesClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, + bool disposeHttpClient = true) : this( + httpClient, + baseUri: null, + authorizations, + options, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the BatchesClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public BatchesClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Together.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; + AutoSDKServerConfiguration.ExplicitBaseUri = baseUri ?? httpClient?.BaseAddress; + Initialized(HttpClient); } diff --git a/src/libs/Together/Generated/Together.ChatClient.ChatCompletions.g.cs b/src/libs/Together/Generated/Together.ChatClient.ChatCompletions.g.cs index 187cd7e1..f35ef9d2 100644 --- a/src/libs/Together/Generated/Together.ChatClient.ChatCompletions.g.cs +++ b/src/libs/Together/Generated/Together.ChatClient.ChatCompletions.g.cs @@ -16,6 +16,7 @@ public partial class ChatClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,6 +48,7 @@ partial void ProcessChatCompletionsResponseContent( /// Generate a model response for a given chat conversation. Supports single queries and multi-turn conversations with system, user, and assistant messages. /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -68,6 +70,46 @@ partial void ProcessChatCompletionsResponseContent( public async global::System.Threading.Tasks.Task ChatCompletionsAsync( global::Together.ChatCompletionRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await ChatCompletionsAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Create chat completion
+ /// Generate a model response for a given chat conversation. Supports single queries and multi-turn conversations with system, user, and assistant messages. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.chat.completions.create(
+ /// model="Qwen/Qwen3.5-9B",
+ /// messages=[
+ /// {"role": "system", "content": "You are a helpful assistant."},
+ /// {"role": "user", "content": "What are some fun things to do in New York?"},
+ /// ],
+ /// reasoning={"enabled": False}
+ /// ) + ///
+ public async global::System.Threading.Tasks.Task> ChatCompletionsAsResponseAsync( + + global::Together.ChatCompletionRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -114,22 +156,44 @@ partial void ProcessChatCompletionsResponseContent( securityRequirements: s_ChatCompletionsSecurityRequirements, operationName: "ChatCompletionsAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/chat/completions", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/chat/completions", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -139,346 +203,531 @@ partial void ProcessChatCompletionsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } - } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareChatCompletionsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); - - ProcessResponse( - client: HttpClient, - response: __response); - ProcessChatCompletionsResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // BadRequest - if ((int)__response.StatusCode == 400) - { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - global::Together.ErrorData? __value_400 = null; - try - { - if (ReadResponseAsString) - { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); - } - else - { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - - __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } - - throw new global::Together.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + } } - // Unauthorized - if ((int)__response.StatusCode == 401) - { - string? __content_401 = null; - global::System.Exception? __exception_401 = null; - global::Together.ErrorData? __value_401 = null; - try - { - if (ReadResponseAsString) - { - __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); - } - else - { - __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - - __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_401 = __ex; - } + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareChatCompletionsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - throw new global::Together.ApiException( - message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_401, - statusCode: __response.StatusCode) - { - ResponseBody = __content_401, - ResponseObject = __value_401, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + return __httpRequest; } - // NotFound - if ((int)__response.StatusCode == 404) - { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; - global::Together.ErrorData? __value_404 = null; - try - { - if (ReadResponseAsString) - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); - } - else - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_404 = __ex; - } - - throw new global::Together.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // RateLimit - if ((int)__response.StatusCode == 429) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_429 = null; - global::System.Exception? __exception_429 = null; - global::Together.ErrorData? __value_429 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ChatCompletions", + methodName: "ChatCompletionsAsync", + pathTemplate: "\"/chat/completions\"", + 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 { - __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_429 = global::Together.ErrorData.FromJson(__content_429, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - - __value_429 = global::Together.ErrorData.FromJson(__content_429, JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ChatCompletions", + methodName: "ChatCompletionsAsync", + pathTemplate: "\"/chat/completions\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_429 = __ex; - } - throw new global::Together.ApiException( - message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_429, - statusCode: __response.StatusCode) - { - ResponseBody = __content_429, - ResponseObject = __value_429, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Overloaded - if ((int)__response.StatusCode == 503) - { - string? __content_503 = null; - global::System.Exception? __exception_503 = null; - global::Together.ErrorData? __value_503 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_503 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_503 = global::Together.ErrorData.FromJson(__content_503, JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ChatCompletions", + methodName: "ChatCompletionsAsync", + pathTemplate: "\"/chat/completions\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_503 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_503 = global::Together.ErrorData.FromJson(__content_503, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_503 = __ex; + break; } - throw new global::Together.ApiException( - message: __content_503 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_503, - statusCode: __response.StatusCode) + if (__response == null) { - ResponseBody = __content_503, - ResponseObject = __value_503, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Timeout - if ((int)__response.StatusCode == 504) - { - string? __content_504 = null; - global::System.Exception? __exception_504 = null; - global::Together.ErrorData? __value_504 = null; - try - { - if (ReadResponseAsString) - { - __content_504 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_504 = global::Together.ErrorData.FromJson(__content_504, JsonSerializerContext); - } - else - { - __content_504 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - - __value_504 = global::Together.ErrorData.FromJson(__content_504, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_504 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_504 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_504, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_504, - ResponseObject = __value_504, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessChatCompletionsResponseContent( + response: __response); + ProcessChatCompletionsResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.ChatCompletionResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ChatCompletions", + methodName: "ChatCompletionsAsync", + pathTemplate: "\"/chat/completions\"", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ChatCompletions", + methodName: "ChatCompletionsAsync", + pathTemplate: "\"/chat/completions\"", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // BadRequest + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Together.ErrorData? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Together.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unauthorized + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Together.ErrorData? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Together.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseObject = __value_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // NotFound + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Together.ErrorData? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Together.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // RateLimit + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Together.ErrorData? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Together.ErrorData.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Together.ErrorData.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Together.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseObject = __value_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Overloaded + if ((int)__response.StatusCode == 503) + { + string? __content_503 = null; + global::System.Exception? __exception_503 = null; + global::Together.ErrorData? __value_503 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_503 = global::Together.ErrorData.FromJson(__content_503, JsonSerializerContext); + } + else + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_503 = global::Together.ErrorData.FromJson(__content_503, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_503 = __ex; + } + + throw new global::Together.ApiException( + message: __content_503 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_503, + statusCode: __response.StatusCode) + { + ResponseBody = __content_503, + ResponseObject = __value_503, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Timeout + if ((int)__response.StatusCode == 504) + { + string? __content_504 = null; + global::System.Exception? __exception_504 = null; + global::Together.ErrorData? __value_504 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_504 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_504 = global::Together.ErrorData.FromJson(__content_504, JsonSerializerContext); + } + else + { + __content_504 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_504 = global::Together.ErrorData.FromJson(__content_504, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_504 = __ex; + } + + throw new global::Together.ApiException( + message: __content_504 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_504, + statusCode: __response.StatusCode) + { + ResponseBody = __content_504, + ResponseObject = __value_504, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessChatCompletionsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.ChatCompletionResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.ChatCompletionResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - return - await global::Together.ChatCompletionResponse.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } - - throw new global::Together.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 chat completion
@@ -494,7 +743,7 @@ partial void ProcessChatCompletionsResponseContent( /// The maximum number of tokens to generate. /// /// - /// A list of string sequences that will truncate (stop) inference text output. For example, "</s>" will stop generation as soon as the model generates the given token. + /// A list of string sequences that truncate (stop) inference text output. For example, "</s>" stops generation as soon as the model generates the given token. /// /// /// A decimal number from 0-1 that determines the degree of randomness in the response. A temperature less than 1 favors more correctness and is appropriate for question answering or summarization. A value closer to 1 introduces more randomness in the output. @@ -506,17 +755,17 @@ partial void ProcessChatCompletionsResponseContent( /// An integer that's used to limit the number of choices for the next predicted word or token. It specifies the maximum number of tokens to consider at each step, based on their probability of occurrence. This technique helps to speed up the generation process and can improve the quality of the generated text by focusing on the most likely options. /// /// - /// Defined the behavior of the API when max_tokens exceed the maximum context length of the model. When set to 'error', API will return 400 with appropriate error message. When set to 'truncate', override the max_tokens with maximum context length of the model.
+ /// Defines the behavior of the API when max_tokens exceed the maximum context length of the model. When set to 'error', the API returns 400 with an appropriate error message. When set to 'truncate', overrides max_tokens with the maximum context length of the model.
/// Default Value: error /// /// /// A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition. /// /// - /// An integer between 0 and 20 of the top k tokens to return log probabilities for at each generation step, instead of just the sampled token. Log probabilities help assess model confidence in token predictions. + /// An integer between 0 and 20 of the top k tokens to return log probabilities for at each generation step, instead of only the sampled token. Log probabilities help assess model confidence in token predictions. /// /// - /// If true, the response will contain the prompt. Can be used with `logprobs` to return prompt logprobs. + /// If true, the response contains the prompt. Can be used with `logprobs` to return prompt logprobs. /// /// /// The number of completions to generate for each prompt. @@ -570,6 +819,7 @@ partial void ProcessChatCompletionsResponseContent( /// /// For models that support toggling reasoning functionality, this object can be used to control that functionality. /// + /// 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 ChatCompletionsAsync( @@ -599,6 +849,7 @@ partial void ProcessChatCompletionsResponseContent( string? safetyModel = default, global::Together.ChatCompletionRequestReasoningEffort? reasoningEffort = default, global::Together.ChatCompletionRequestReasoning? reasoning = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.ChatCompletionRequest @@ -634,6 +885,7 @@ partial void ProcessChatCompletionsResponseContent( return await ChatCompletionsAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Together/Generated/Together.ChatClient.ChatCompletionsAsStream.g.cs b/src/libs/Together/Generated/Together.ChatClient.ChatCompletionsAsStream.g.cs index c71a7937..6df142fd 100644 --- a/src/libs/Together/Generated/Together.ChatClient.ChatCompletionsAsStream.g.cs +++ b/src/libs/Together/Generated/Together.ChatClient.ChatCompletionsAsStream.g.cs @@ -16,6 +16,7 @@ public partial class ChatClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -42,6 +43,7 @@ partial void ProcessChatCompletionsAsStreamResponse( /// Generate a model response for a given chat conversation. Supports single queries and multi-turn conversations with system, user, and assistant messages. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -63,6 +65,7 @@ partial void ProcessChatCompletionsAsStreamResponse( public async global::System.Collections.Generic.IAsyncEnumerable ChatCompletionsAsStreamAsync( global::Together.ChatCompletionRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -109,22 +112,44 @@ partial void ProcessChatCompletionsAsStreamResponse( securityRequirements: s_ChatCompletionsAsStreamSecurityRequirements, operationName: "ChatCompletionsAsStreamAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/chat/completions", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/chat/completions", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -134,95 +159,272 @@ partial void ProcessChatCompletionsAsStreamResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareChatCompletionsAsStreamRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareChatCompletionsAsStreamRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessChatCompletionsAsStreamResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; try { - __response.EnsureSuccessStatusCode(); - } - catch (global::System.Net.Http.HttpRequestException __ex) - { - string? __content = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ChatCompletionsAsStream", + methodName: "ChatCompletionsAsStreamAsync", + pathTemplate: "\"/chat/completions\"", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ChatCompletionsAsStream", + methodName: "ChatCompletionsAsStreamAsync", + pathTemplate: "\"/chat/completions\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ChatCompletionsAsStream", + methodName: "ChatCompletionsAsStreamAsync", + pathTemplate: "\"/chat/completions\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; } - catch (global::System.Exception) + + if (__response == null) { + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) + using (__response) { - 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 - cancellationToken -#endif - ).ConfigureAwait(false); - - await foreach (var __sseEvent in global::System.Net.ServerSentEvents.SseParser - .Create(__stream).EnumerateAsync(cancellationToken)) - { - var __content = __sseEvent.Data; - if (__content == "[DONE]") + ProcessResponse( + client: HttpClient, + response: __response); + ProcessChatCompletionsAsStreamResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ChatCompletionsAsStream", + methodName: "ChatCompletionsAsStreamAsync", + pathTemplate: "\"/chat/completions\"", + 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 { - yield break; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ChatCompletionsAsStream", + methodName: "ChatCompletionsAsStreamAsync", + pathTemplate: "\"/chat/completions\"", + 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); } - var __streamedResponse = global::Together.ChatCompletionStream.FromJson(__content, JsonSerializerContext) ?? - throw new global::Together.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; + 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::Together.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::Together.ChatCompletionStream.FromJson(__content, JsonSerializerContext) ?? + throw new global::Together.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(); } } /// @@ -239,7 +441,7 @@ partial void ProcessChatCompletionsAsStreamResponse( /// The maximum number of tokens to generate. /// /// - /// A list of string sequences that will truncate (stop) inference text output. For example, "</s>" will stop generation as soon as the model generates the given token. + /// A list of string sequences that truncate (stop) inference text output. For example, "</s>" stops generation as soon as the model generates the given token. /// /// /// A decimal number from 0-1 that determines the degree of randomness in the response. A temperature less than 1 favors more correctness and is appropriate for question answering or summarization. A value closer to 1 introduces more randomness in the output. @@ -251,17 +453,17 @@ partial void ProcessChatCompletionsAsStreamResponse( /// An integer that's used to limit the number of choices for the next predicted word or token. It specifies the maximum number of tokens to consider at each step, based on their probability of occurrence. This technique helps to speed up the generation process and can improve the quality of the generated text by focusing on the most likely options. /// /// - /// Defined the behavior of the API when max_tokens exceed the maximum context length of the model. When set to 'error', API will return 400 with appropriate error message. When set to 'truncate', override the max_tokens with maximum context length of the model.
+ /// Defines the behavior of the API when max_tokens exceed the maximum context length of the model. When set to 'error', the API returns 400 with an appropriate error message. When set to 'truncate', overrides max_tokens with the maximum context length of the model.
/// Default Value: error /// /// /// A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition. /// /// - /// An integer between 0 and 20 of the top k tokens to return log probabilities for at each generation step, instead of just the sampled token. Log probabilities help assess model confidence in token predictions. + /// An integer between 0 and 20 of the top k tokens to return log probabilities for at each generation step, instead of only the sampled token. Log probabilities help assess model confidence in token predictions. /// /// - /// If true, the response will contain the prompt. Can be used with `logprobs` to return prompt logprobs. + /// If true, the response contains the prompt. Can be used with `logprobs` to return prompt logprobs. /// /// /// The number of completions to generate for each prompt. @@ -315,6 +517,7 @@ partial void ProcessChatCompletionsAsStreamResponse( /// /// For models that support toggling reasoning functionality, this object can be used to control that functionality. /// + /// 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 ChatCompletionsAsStreamAsync( @@ -344,6 +547,7 @@ partial void ProcessChatCompletionsAsStreamResponse( string? safetyModel = default, global::Together.ChatCompletionRequestReasoningEffort? reasoningEffort = default, global::Together.ChatCompletionRequestReasoning? reasoning = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.ChatCompletionRequest @@ -379,6 +583,7 @@ partial void ProcessChatCompletionsAsStreamResponse( var __enumerable = ChatCompletionsAsStreamAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken); await foreach (var __response in __enumerable) diff --git a/src/libs/Together/Generated/Together.ChatClient.g.cs b/src/libs/Together/Generated/Together.ChatClient.g.cs index 99f97061..515d3203 100644 --- a/src/libs/Together/Generated/Together.ChatClient.g.cs +++ b/src/libs/Together/Generated/Together.ChatClient.g.cs @@ -12,7 +12,7 @@ public sealed partial class ChatClient : global::Together.IChatClient, global::S /// /// /// - public const string DefaultBaseUrl = "https://api.together.xyz/v1"; + public const string DefaultBaseUrl = "https://api.together.ai/v1"; private bool _disposeHttpClient = true; @@ -30,6 +30,12 @@ public sealed partial class ChatClient : global::Together.IChatClient, global::S #if DEBUG = true; #endif + + /// + public global::Together.AutoSDKClientOptions Options { get; } + + + internal global::Together.AutoSDKServerConfiguration AutoSDKServerConfiguration { get; set; } = new global::Together.AutoSDKServerConfiguration(); /// /// /// @@ -49,13 +55,62 @@ public ChatClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the ChatClient with explicit options but no base URL override. + /// Skips passing baseUri so the default base URL from the OpenAPI spec applies. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public ChatClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, + bool disposeHttpClient = true) : this( + httpClient, + baseUri: null, + authorizations, + options, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the ChatClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public ChatClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Together.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; + AutoSDKServerConfiguration.ExplicitBaseUri = baseUri ?? httpClient?.BaseAddress; + Initialized(HttpClient); } diff --git a/src/libs/Together/Generated/Together.CodeInterpreterClient.SessionsList.g.cs b/src/libs/Together/Generated/Together.CodeInterpreterClient.SessionsList.g.cs index f5be844a..f5d64711 100644 --- a/src/libs/Together/Generated/Together.CodeInterpreterClient.SessionsList.g.cs +++ b/src/libs/Together/Generated/Together.CodeInterpreterClient.SessionsList.g.cs @@ -14,6 +14,7 @@ public partial class CodeInterpreterClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -39,8 +40,10 @@ partial void ProcessSessionsListResponseContent( ref string content); /// + /// List active sessions
/// Lists all your currently active sessions. ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -55,6 +58,36 @@ partial void ProcessSessionsListResponseContent( /// print(session.id) /// public async global::System.Threading.Tasks.Task SessionsListAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await SessionsListAsResponseAsync( + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// List active sessions
+ /// Lists all your currently active sessions. + ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.code_interpreter.sessions.list()
+ /// for session in response.data.sessions:
+ /// print(session.id) + ///
+ public async global::System.Threading.Tasks.Task> SessionsListAsResponseAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -68,22 +101,44 @@ partial void ProcessSessionsListResponseContent( securityRequirements: s_SessionsListSecurityRequirements, operationName: "SessionsListAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/tci/sessions", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/tci/sessions", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -93,111 +148,296 @@ partial void ProcessSessionsListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSessionsListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareSessionsListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessSessionsListResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SessionsList", + methodName: "SessionsListAsync", + pathTemplate: "\"/tci/sessions\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SessionsList", + methodName: "SessionsListAsync", + pathTemplate: "\"/tci/sessions\"", + httpMethod: "GET", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessSessionsListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SessionsList", + methodName: "SessionsListAsync", + pathTemplate: "\"/tci/sessions\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::Together.SessionListResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Together.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), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return - await global::Together.SessionListResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessSessionsListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SessionsList", + methodName: "SessionsListAsync", + pathTemplate: "\"/tci/sessions\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SessionsList", + methodName: "SessionsListAsync", + pathTemplate: "\"/tci/sessions\"", + httpMethod: "GET", + 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); + ProcessSessionsListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.SessionListResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.SessionListResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.CodeInterpreterClient.TciExecute.g.cs b/src/libs/Together/Generated/Together.CodeInterpreterClient.TciExecute.g.cs index f0d27cee..c03fa6d7 100644 --- a/src/libs/Together/Generated/Together.CodeInterpreterClient.TciExecute.g.cs +++ b/src/libs/Together/Generated/Together.CodeInterpreterClient.TciExecute.g.cs @@ -14,6 +14,7 @@ public partial class CodeInterpreterClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -41,10 +42,12 @@ partial void ProcessTciExecuteResponseContent( ref string content); /// - /// Executes the given code snippet and returns the output. Without a session_id, a new session will be created to run the code. If you do pass in a valid session_id, the code will be run in that session. This is useful for running multiple code snippets in the same environment, because dependencies and similar things are persisted
+ /// Execute code
+ /// Executes the given code snippet and returns the output. Without a session_id, a new session is created to run the code. If you pass a valid session_id, the code runs in that session. This is useful for running multiple code snippets in the same environment, because dependencies and similar things are persisted
/// between calls to the same session. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -63,6 +66,44 @@ partial void ProcessTciExecuteResponseContent( public async global::System.Threading.Tasks.Task TciExecuteAsync( global::Together.ExecuteRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await TciExecuteAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Execute code
+ /// Executes the given code snippet and returns the output. Without a session_id, a new session is created to run the code. If you pass a valid session_id, the code runs in that session. This is useful for running multiple code snippets in the same environment, because dependencies and similar things are persisted
+ /// between calls to the same session. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.code_interpreter.execute(
+ /// code="print('Hello world!')",
+ /// language="python",
+ /// )
+ /// print(response.data.outputs[0].data); + ///
+ public async global::System.Threading.Tasks.Task> TciExecuteAsResponseAsync( + + global::Together.ExecuteRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -79,22 +120,44 @@ partial void ProcessTciExecuteResponseContent( securityRequirements: s_TciExecuteSecurityRequirements, operationName: "TciExecuteAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/tci/execute", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/tci/execute", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -104,121 +167,307 @@ partial void ProcessTciExecuteResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareTciExecuteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareTciExecuteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessTciExecuteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "TciExecute", + methodName: "TciExecuteAsync", + pathTemplate: "\"/tci/execute\"", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "TciExecute", + methodName: "TciExecuteAsync", + pathTemplate: "\"/tci/execute\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessTciExecuteResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "TciExecute", + methodName: "TciExecuteAsync", + pathTemplate: "\"/tci/execute\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::Together.ExecuteResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Together.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), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return - await global::Together.ExecuteResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessTciExecuteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "TciExecute", + methodName: "TciExecuteAsync", + pathTemplate: "\"/tci/execute\"", + 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); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "TciExecute", + methodName: "TciExecuteAsync", + pathTemplate: "\"/tci/execute\"", + 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); + ProcessTciExecuteResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.ExecuteResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.ExecuteResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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(); + } } /// - /// Executes the given code snippet and returns the output. Without a session_id, a new session will be created to run the code. If you do pass in a valid session_id, the code will be run in that session. This is useful for running multiple code snippets in the same environment, because dependencies and similar things are persisted
+ /// Execute code
+ /// Executes the given code snippet and returns the output. Without a session_id, a new session is created to run the code. If you pass a valid session_id, the code runs in that session. This is useful for running multiple code snippets in the same environment, because dependencies and similar things are persisted
/// between calls to the same session. ///
/// @@ -226,16 +475,17 @@ partial void ProcessTciExecuteResponseContent( /// Example: print('Hello, world!') /// /// - /// Files to upload to the session. If present, files will be uploaded before executing the given code. + /// Files to upload to the session. If present, files are uploaded before executing the given code. /// /// - /// Programming language for the code to execute. Currently only supports Python, but more will be added.
+ /// Programming language for the code to execute. Currently only supports Python.
/// Default Value: python /// /// - /// Identifier of the current session. Used to make follow-up calls. Requests will return an error if the session does not belong to the caller or has expired.
+ /// Identifier of the current session. Used to make follow-up calls. Returns an error if the session does not belong to the caller or has expired.
/// Example: ses_abcDEF123 /// + /// 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 TciExecuteAsync( @@ -243,6 +493,7 @@ partial void ProcessTciExecuteResponseContent( global::System.Collections.Generic.IList? files = default, global::Together.ExecuteRequestLanguage language = global::Together.ExecuteRequestLanguage.Python, string? sessionId = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.ExecuteRequest @@ -255,6 +506,7 @@ partial void ProcessTciExecuteResponseContent( return await TciExecuteAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Together/Generated/Together.CodeInterpreterClient.g.cs b/src/libs/Together/Generated/Together.CodeInterpreterClient.g.cs index 1a9ebf42..46f9e1c2 100644 --- a/src/libs/Together/Generated/Together.CodeInterpreterClient.g.cs +++ b/src/libs/Together/Generated/Together.CodeInterpreterClient.g.cs @@ -12,7 +12,7 @@ public sealed partial class CodeInterpreterClient : global::Together.ICodeInterp /// /// /// - public const string DefaultBaseUrl = "https://api.together.xyz/v1"; + public const string DefaultBaseUrl = "https://api.together.ai/v1"; private bool _disposeHttpClient = true; @@ -30,6 +30,12 @@ public sealed partial class CodeInterpreterClient : global::Together.ICodeInterp #if DEBUG = true; #endif + + /// + public global::Together.AutoSDKClientOptions Options { get; } + + + internal global::Together.AutoSDKServerConfiguration AutoSDKServerConfiguration { get; set; } = new global::Together.AutoSDKServerConfiguration(); /// /// /// @@ -49,13 +55,62 @@ public CodeInterpreterClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the CodeInterpreterClient with explicit options but no base URL override. + /// Skips passing baseUri so the default base URL from the OpenAPI spec applies. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public CodeInterpreterClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, + bool disposeHttpClient = true) : this( + httpClient, + baseUri: null, + authorizations, + options, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the CodeInterpreterClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public CodeInterpreterClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Together.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; + AutoSDKServerConfiguration.ExplicitBaseUri = baseUri ?? httpClient?.BaseAddress; + Initialized(HttpClient); } diff --git a/src/libs/Together/Generated/Together.CompletionClient.Completions.g.cs b/src/libs/Together/Generated/Together.CompletionClient.Completions.g.cs index 1eb6f9fd..551f7670 100644 --- a/src/libs/Together/Generated/Together.CompletionClient.Completions.g.cs +++ b/src/libs/Together/Generated/Together.CompletionClient.Completions.g.cs @@ -14,6 +14,7 @@ public partial class CompletionClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,6 +46,7 @@ partial void ProcessCompletionsResponseContent( /// Generate text completions for a given prompt using a language, code, or image model. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -64,6 +66,44 @@ partial void ProcessCompletionsResponseContent( public async global::System.Threading.Tasks.Task CompletionsAsync( global::Together.CompletionRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CompletionsAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Create completion
+ /// Generate text completions for a given prompt using a language, code, or image model. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.completions.create(
+ /// model="Qwen/Qwen3.5-9B",
+ /// prompt="The largest city in France is",
+ /// max_tokens=1
+ /// )
+ /// print(response.choices[0].text) + ///
+ public async global::System.Threading.Tasks.Task> CompletionsAsResponseAsync( + + global::Together.CompletionRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -101,22 +141,44 @@ partial void ProcessCompletionsResponseContent( securityRequirements: s_CompletionsSecurityRequirements, operationName: "CompletionsAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/completions", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/completions", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -126,346 +188,531 @@ partial void ProcessCompletionsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCompletionsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); - - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCompletionsResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // BadRequest - if ((int)__response.StatusCode == 400) - { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - global::Together.ErrorData? __value_400 = null; - try - { - if (ReadResponseAsString) - { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); - } - else - { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - - __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } - - throw new global::Together.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Unauthorized - if ((int)__response.StatusCode == 401) - { - string? __content_401 = null; - global::System.Exception? __exception_401 = null; - global::Together.ErrorData? __value_401 = null; - try - { - if (ReadResponseAsString) - { - __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); - } - else - { - __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - - __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_401 = __ex; - } + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCompletionsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - throw new global::Together.ApiException( - message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_401, - statusCode: __response.StatusCode) - { - ResponseBody = __content_401, - ResponseObject = __value_401, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + return __httpRequest; } - // NotFound - if ((int)__response.StatusCode == 404) - { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; - global::Together.ErrorData? __value_404 = null; - try - { - if (ReadResponseAsString) - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); - } - else - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - - __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_404 = __ex; - } - throw new global::Together.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // RateLimit - if ((int)__response.StatusCode == 429) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_429 = null; - global::System.Exception? __exception_429 = null; - global::Together.ErrorData? __value_429 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Completions", + methodName: "CompletionsAsync", + pathTemplate: "\"/completions\"", + 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 { - __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_429 = global::Together.ErrorData.FromJson(__content_429, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - - __value_429 = global::Together.ErrorData.FromJson(__content_429, JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Completions", + methodName: "CompletionsAsync", + pathTemplate: "\"/completions\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_429 = __ex; - } - throw new global::Together.ApiException( - message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_429, - statusCode: __response.StatusCode) - { - ResponseBody = __content_429, - ResponseObject = __value_429, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Overloaded - if ((int)__response.StatusCode == 503) - { - string? __content_503 = null; - global::System.Exception? __exception_503 = null; - global::Together.ErrorData? __value_503 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_503 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_503 = global::Together.ErrorData.FromJson(__content_503, JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Completions", + methodName: "CompletionsAsync", + pathTemplate: "\"/completions\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_503 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_503 = global::Together.ErrorData.FromJson(__content_503, JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) - { - __exception_503 = __ex; - } - - throw new global::Together.ApiException( - message: __content_503 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_503, - statusCode: __response.StatusCode) - { - ResponseBody = __content_503, - ResponseObject = __value_503, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Timeout - if ((int)__response.StatusCode == 504) - { - string? __content_504 = null; - global::System.Exception? __exception_504 = null; - global::Together.ErrorData? __value_504 = null; - try - { - if (ReadResponseAsString) - { - __content_504 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_504 = global::Together.ErrorData.FromJson(__content_504, JsonSerializerContext); - } - else - { - __content_504 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_504 = global::Together.ErrorData.FromJson(__content_504, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) + if (__response == null) { - __exception_504 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_504 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_504, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_504, - ResponseObject = __value_504, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessCompletionsResponseContent( + response: __response); + ProcessCompletionsResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.CompletionResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Completions", + methodName: "CompletionsAsync", + pathTemplate: "\"/completions\"", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Completions", + methodName: "CompletionsAsync", + pathTemplate: "\"/completions\"", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // BadRequest + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Together.ErrorData? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Together.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unauthorized + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Together.ErrorData? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Together.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseObject = __value_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // NotFound + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Together.ErrorData? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Together.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // RateLimit + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Together.ErrorData? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Together.ErrorData.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Together.ErrorData.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Together.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseObject = __value_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Overloaded + if ((int)__response.StatusCode == 503) + { + string? __content_503 = null; + global::System.Exception? __exception_503 = null; + global::Together.ErrorData? __value_503 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_503 = global::Together.ErrorData.FromJson(__content_503, JsonSerializerContext); + } + else + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_503 = global::Together.ErrorData.FromJson(__content_503, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_503 = __ex; + } + + throw new global::Together.ApiException( + message: __content_503 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_503, + statusCode: __response.StatusCode) + { + ResponseBody = __content_503, + ResponseObject = __value_503, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Timeout + if ((int)__response.StatusCode == 504) + { + string? __content_504 = null; + global::System.Exception? __exception_504 = null; + global::Together.ErrorData? __value_504 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_504 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_504 = global::Together.ErrorData.FromJson(__content_504, JsonSerializerContext); + } + else + { + __content_504 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_504 = global::Together.ErrorData.FromJson(__content_504, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_504 = __ex; + } + + throw new global::Together.ApiException( + message: __content_504 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_504, + statusCode: __response.StatusCode) + { + ResponseBody = __content_504, + ResponseObject = __value_504, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessCompletionsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.CompletionResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.CompletionResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - return - await global::Together.CompletionResponse.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } - - throw new global::Together.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 completion
@@ -483,7 +730,7 @@ partial void ProcessCompletionsResponseContent( /// The maximum number of tokens to generate. /// /// - /// A list of string sequences that will truncate (stop) inference text output. For example, "</s>" will stop generation as soon as the model generates the given token. + /// A list of string sequences that truncate (stop) inference text output. For example, "</s>" stops generation as soon as the model generates the given token. /// /// /// A decimal number from 0-1 that determines the degree of randomness in the response. A temperature less than 1 favors more correctness and is appropriate for question answering or summarization. A value closer to 1 introduces more randomness in the output. @@ -498,10 +745,10 @@ partial void ProcessCompletionsResponseContent( /// A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition. /// /// - /// An integer between 0 and 20 of the top k tokens to return log probabilities for at each generation step, instead of just the sampled token. Log probabilities help assess model confidence in token predictions. + /// An integer between 0 and 20 of the top k tokens to return log probabilities for at each generation step, instead of only the sampled token. Log probabilities help assess model confidence in token predictions. /// /// - /// If true, the response will contain the prompt. Can be used with `logprobs` to return prompt logprobs. + /// If true, the response contains the prompt. Can be used with `logprobs` to return prompt logprobs. /// /// /// The number of completions to generate for each prompt. @@ -527,6 +774,7 @@ partial void ProcessCompletionsResponseContent( /// Seed value for reproducibility.
/// Example: 42 /// + /// 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 CompletionsAsync( @@ -547,6 +795,7 @@ partial void ProcessCompletionsResponseContent( float? frequencyPenalty = default, global::System.Collections.Generic.Dictionary? logitBias = default, int? seed = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.CompletionRequest @@ -573,6 +822,7 @@ partial void ProcessCompletionsResponseContent( return await CompletionsAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Together/Generated/Together.CompletionClient.CompletionsAsStream.g.cs b/src/libs/Together/Generated/Together.CompletionClient.CompletionsAsStream.g.cs index b95415d3..48283718 100644 --- a/src/libs/Together/Generated/Together.CompletionClient.CompletionsAsStream.g.cs +++ b/src/libs/Together/Generated/Together.CompletionClient.CompletionsAsStream.g.cs @@ -14,6 +14,7 @@ public partial class CompletionClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -40,6 +41,7 @@ partial void ProcessCompletionsAsStreamResponse( /// Generate text completions for a given prompt using a language, code, or image model. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -59,6 +61,7 @@ partial void ProcessCompletionsAsStreamResponse( public async global::System.Collections.Generic.IAsyncEnumerable CompletionsAsStreamAsync( global::Together.CompletionRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -96,22 +99,44 @@ partial void ProcessCompletionsAsStreamResponse( securityRequirements: s_CompletionsAsStreamSecurityRequirements, operationName: "CompletionsAsStreamAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/completions", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/completions", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -121,95 +146,272 @@ partial void ProcessCompletionsAsStreamResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCompletionsAsStreamRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCompletionsAsStreamRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCompletionsAsStreamResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; try { - __response.EnsureSuccessStatusCode(); - } - catch (global::System.Net.Http.HttpRequestException __ex) - { - string? __content = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CompletionsAsStream", + methodName: "CompletionsAsStreamAsync", + pathTemplate: "\"/completions\"", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CompletionsAsStream", + methodName: "CompletionsAsStreamAsync", + pathTemplate: "\"/completions\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CompletionsAsStream", + methodName: "CompletionsAsStreamAsync", + pathTemplate: "\"/completions\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; } - catch (global::System.Exception) + + if (__response == null) { + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) + using (__response) { - 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 - cancellationToken -#endif - ).ConfigureAwait(false); - await foreach (var __sseEvent in global::System.Net.ServerSentEvents.SseParser - .Create(__stream).EnumerateAsync(cancellationToken)) - { - var __content = __sseEvent.Data; - if (__content == "[DONE]") + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCompletionsAsStreamResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - yield break; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CompletionsAsStream", + methodName: "CompletionsAsStreamAsync", + pathTemplate: "\"/completions\"", + 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::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CompletionsAsStream", + methodName: "CompletionsAsStreamAsync", + pathTemplate: "\"/completions\"", + 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::Together.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::Together.CompletionStream.FromJson(__content, JsonSerializerContext) ?? - throw new global::Together.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), - }; + var __streamedResponse = global::Together.CompletionStream.FromJson(__content, JsonSerializerContext) ?? + throw new global::Together.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; + yield return __streamedResponse; + } + + } + } + finally + { + __httpRequest?.Dispose(); } } /// @@ -228,7 +430,7 @@ partial void ProcessCompletionsAsStreamResponse( /// The maximum number of tokens to generate. /// /// - /// A list of string sequences that will truncate (stop) inference text output. For example, "</s>" will stop generation as soon as the model generates the given token. + /// A list of string sequences that truncate (stop) inference text output. For example, "</s>" stops generation as soon as the model generates the given token. /// /// /// A decimal number from 0-1 that determines the degree of randomness in the response. A temperature less than 1 favors more correctness and is appropriate for question answering or summarization. A value closer to 1 introduces more randomness in the output. @@ -243,10 +445,10 @@ partial void ProcessCompletionsAsStreamResponse( /// A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition. /// /// - /// An integer between 0 and 20 of the top k tokens to return log probabilities for at each generation step, instead of just the sampled token. Log probabilities help assess model confidence in token predictions. + /// An integer between 0 and 20 of the top k tokens to return log probabilities for at each generation step, instead of only the sampled token. Log probabilities help assess model confidence in token predictions. /// /// - /// If true, the response will contain the prompt. Can be used with `logprobs` to return prompt logprobs. + /// If true, the response contains the prompt. Can be used with `logprobs` to return prompt logprobs. /// /// /// The number of completions to generate for each prompt. @@ -272,6 +474,7 @@ partial void ProcessCompletionsAsStreamResponse( /// Seed value for reproducibility.
/// Example: 42 /// + /// 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 CompletionsAsStreamAsync( @@ -292,6 +495,7 @@ partial void ProcessCompletionsAsStreamResponse( float? frequencyPenalty = default, global::System.Collections.Generic.Dictionary? logitBias = default, int? seed = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.CompletionRequest @@ -318,6 +522,7 @@ partial void ProcessCompletionsAsStreamResponse( var __enumerable = CompletionsAsStreamAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken); await foreach (var __response in __enumerable) diff --git a/src/libs/Together/Generated/Together.CompletionClient.g.cs b/src/libs/Together/Generated/Together.CompletionClient.g.cs index 0bab751f..40340412 100644 --- a/src/libs/Together/Generated/Together.CompletionClient.g.cs +++ b/src/libs/Together/Generated/Together.CompletionClient.g.cs @@ -12,7 +12,7 @@ public sealed partial class CompletionClient : global::Together.ICompletionClien /// /// /// - public const string DefaultBaseUrl = "https://api.together.xyz/v1"; + public const string DefaultBaseUrl = "https://api.together.ai/v1"; private bool _disposeHttpClient = true; @@ -30,6 +30,12 @@ public sealed partial class CompletionClient : global::Together.ICompletionClien #if DEBUG = true; #endif + + /// + public global::Together.AutoSDKClientOptions Options { get; } + + + internal global::Together.AutoSDKServerConfiguration AutoSDKServerConfiguration { get; set; } = new global::Together.AutoSDKServerConfiguration(); /// /// /// @@ -49,13 +55,62 @@ public CompletionClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the CompletionClient with explicit options but no base URL override. + /// Skips passing baseUri so the default base URL from the OpenAPI spec applies. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public CompletionClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, + bool disposeHttpClient = true) : this( + httpClient, + baseUri: null, + authorizations, + options, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the CompletionClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public CompletionClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Together.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; + AutoSDKServerConfiguration.ExplicitBaseUri = baseUri ?? httpClient?.BaseAddress; + Initialized(HttpClient); } diff --git a/src/libs/Together/Generated/Together.DeploymentsClient.CreateDeployments.g.cs b/src/libs/Together/Generated/Together.DeploymentsClient.CreateDeployments.g.cs index 84c9afe8..6ab78bd7 100644 --- a/src/libs/Together/Generated/Together.DeploymentsClient.CreateDeployments.g.cs +++ b/src/libs/Together/Generated/Together.DeploymentsClient.CreateDeployments.g.cs @@ -14,6 +14,7 @@ public partial class DeploymentsClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,6 +46,7 @@ partial void ProcessCreateDeploymentsResponseContent( /// Create a new deployment with specified configuration ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -53,13 +55,47 @@ partial void ProcessCreateDeploymentsResponseContent( /// deployment = client.beta.jig.deploy(
/// name="my-deployment",
/// gpu_type="h100-80gb",
- /// image="registry.together.xyz/proj_abcdefg1234567890/my-image:latest"
+ /// image="registry.together.ai/proj_abcdefg1234567890/my-image:latest"
/// )
/// print(deployment) ///
public async global::System.Threading.Tasks.Task CreateDeploymentsAsync( global::Together.CreateDeploymentRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreateDeploymentsAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Create a new deployment
+ /// Create a new deployment with specified configuration + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// deployment = client.beta.jig.deploy(
+ /// name="my-deployment",
+ /// gpu_type="h100-80gb",
+ /// image="registry.together.ai/proj_abcdefg1234567890/my-image:latest"
+ /// )
+ /// print(deployment) + ///
+ public async global::System.Threading.Tasks.Task> CreateDeploymentsAsResponseAsync( + + global::Together.CreateDeploymentRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -76,22 +112,44 @@ partial void ProcessCreateDeploymentsResponseContent( securityRequirements: s_CreateDeploymentsSecurityRequirements, operationName: "CreateDeploymentsAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/deployments", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/deployments", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -101,194 +159,379 @@ partial void ProcessCreateDeploymentsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateDeploymentsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateDeploymentsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateDeploymentsResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Invalid request - if ((int)__response.StatusCode == 400) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - string? __value_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createDeployments", + methodName: "CreateDeploymentsAsync", + pathTemplate: "\"/deployments\"", + 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 { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createDeployments", + methodName: "CreateDeploymentsAsync", + pathTemplate: "\"/deployments\"", + 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; + } - __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } - throw new global::Together.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Internal server error - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - string? __value_500 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createDeployments", + methodName: "CreateDeploymentsAsync", + pathTemplate: "\"/deployments\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_500 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessCreateDeploymentsResponseContent( + response: __response); + ProcessCreateDeploymentsResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.DeploymentResponseItem.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createDeployments", + methodName: "CreateDeploymentsAsync", + pathTemplate: "\"/deployments\"", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createDeployments", + methodName: "CreateDeploymentsAsync", + pathTemplate: "\"/deployments\"", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Invalid request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + string? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.DeploymentResponseItem.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Together.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal server error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + string? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessCreateDeploymentsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.DeploymentResponseItem.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.DeploymentResponseItem.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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 a new deployment
@@ -319,13 +562,13 @@ partial void ProcessCreateDeploymentsResponseContent( /// GPUType specifies the GPU hardware to use (e.g., "h100-80gb"). /// /// - /// HealthCheckPath is the HTTP path for health checks (e.g., "/health"). If set, the platform will check this endpoint to determine container health + /// HealthCheckPath is the HTTP path for health checks (e.g., "/health"). If set, the platform checks this endpoint to determine container health. /// /// /// Image is the container image to deploy from registry.together.ai. /// /// - /// MaxReplicas is the maximum number of container instances that can be scaled up to. If not set, will be set to MinReplicas + /// MaxReplicas is the maximum number of container instances. Defaults to MinReplicas if not set. /// /// /// Memory is the amount of RAM to allocate per container instance in GiB (e.g., 0.5 = 512MiB) @@ -348,9 +591,11 @@ partial void ProcessCreateDeploymentsResponseContent( /// /// Volumes is a list of volume mounts to attach to the container. Each mount must reference an existing volume by name /// + /// 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 CreateDeploymentsAsync( + global::Together.CreateDeploymentRequestGpuType gpuType, string image, string name, global::System.Collections.Generic.IList? args = default, @@ -360,7 +605,6 @@ partial void ProcessCreateDeploymentsResponseContent( string? description = default, global::System.Collections.Generic.IList? environmentVariables = default, int? gpuCount = default, - global::Together.CreateDeploymentRequestGpuType gpuType = default, string? healthCheckPath = default, int? maxReplicas = default, double? memory = default, @@ -369,6 +613,7 @@ partial void ProcessCreateDeploymentsResponseContent( int? storage = default, int? terminationGracePeriodSeconds = default, global::System.Collections.Generic.IList? volumes = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.CreateDeploymentRequest @@ -395,6 +640,7 @@ partial void ProcessCreateDeploymentsResponseContent( return await CreateDeploymentsAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Together/Generated/Together.DeploymentsClient.DeleteDeploymentsById.g.cs b/src/libs/Together/Generated/Together.DeploymentsClient.DeleteDeploymentsById.g.cs index 43fa0cc3..cb0a43dc 100644 --- a/src/libs/Together/Generated/Together.DeploymentsClient.DeleteDeploymentsById.g.cs +++ b/src/libs/Together/Generated/Together.DeploymentsClient.DeleteDeploymentsById.g.cs @@ -14,6 +14,7 @@ public partial class DeploymentsClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,6 +48,7 @@ partial void ProcessDeleteDeploymentsByIdResponseContent( /// /// Deployment ID or name /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -57,6 +59,36 @@ partial void ProcessDeleteDeploymentsByIdResponseContent( /// public async global::System.Threading.Tasks.Task DeleteDeploymentsByIdAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await DeleteDeploymentsByIdAsResponseAsync( + id: id, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Delete a deployment
+ /// Delete an existing deployment + ///
+ /// + /// Deployment ID or name + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// deployment = client.beta.jig.destroy("my-deployment")
+ /// print(deployment) + ///
+ public async global::System.Threading.Tasks.Task> DeleteDeploymentsByIdAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -71,22 +103,44 @@ partial void ProcessDeleteDeploymentsByIdResponseContent( securityRequirements: s_DeleteDeploymentsByIdSecurityRequirements, operationName: "DeleteDeploymentsByIdAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/deployments/{id}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Delete, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/deployments/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Delete, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -96,184 +150,369 @@ partial void ProcessDeleteDeploymentsByIdResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteDeploymentsByIdRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteDeploymentsByIdRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id!); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteDeploymentsByIdResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Deployment not found - if ((int)__response.StatusCode == 404) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; - string? __value_404 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "deleteDeploymentsById", + methodName: "DeleteDeploymentsByIdAsync", + pathTemplate: "$\"/deployments/{id}\"", + httpMethod: "DELETE", + 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 { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "deleteDeploymentsById", + methodName: "DeleteDeploymentsByIdAsync", + pathTemplate: "$\"/deployments/{id}\"", + httpMethod: "DELETE", + 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; + } - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_404 = __ex; - } - throw new global::Together.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Internal server error - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - string? __value_500 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "deleteDeploymentsById", + methodName: "DeleteDeploymentsByIdAsync", + pathTemplate: "$\"/deployments/{id}\"", + httpMethod: "DELETE", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_500 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessDeleteDeploymentsByIdResponseContent( + response: __response); + ProcessDeleteDeploymentsByIdResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return __content; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "deleteDeploymentsById", + methodName: "DeleteDeploymentsByIdAsync", + pathTemplate: "$\"/deployments/{id}\"", + httpMethod: "DELETE", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "deleteDeploymentsById", + methodName: "DeleteDeploymentsByIdAsync", + pathTemplate: "$\"/deployments/{id}\"", + httpMethod: "DELETE", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Deployment not found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + string? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return __content; - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Together.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal server error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + string? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessDeleteDeploymentsByIdResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __content); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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(); + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __content); + } + 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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.DeploymentsClient.EditDeploymentsById.g.cs b/src/libs/Together/Generated/Together.DeploymentsClient.EditDeploymentsById.g.cs index 1eec6169..a098243b 100644 --- a/src/libs/Together/Generated/Together.DeploymentsClient.EditDeploymentsById.g.cs +++ b/src/libs/Together/Generated/Together.DeploymentsClient.EditDeploymentsById.g.cs @@ -14,6 +14,7 @@ public partial class DeploymentsClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -50,6 +51,7 @@ partial void ProcessEditDeploymentsByIdResponseContent( /// Deployment ID or name /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -62,6 +64,41 @@ partial void ProcessEditDeploymentsByIdResponseContent( string id, global::Together.UpdateDeploymentRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await EditDeploymentsByIdAsResponseAsync( + id: id, + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Update a deployment
+ /// Update an existing deployment configuration + ///
+ /// + /// Deployment ID or name + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// deployment = client.beta.jig.update("my-deployment", gpu_count=2)
+ /// print(deployment) + ///
+ public async global::System.Threading.Tasks.Task> EditDeploymentsByIdAsResponseAsync( + string id, + + global::Together.UpdateDeploymentRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -79,22 +116,44 @@ partial void ProcessEditDeploymentsByIdResponseContent( securityRequirements: s_EditDeploymentsByIdSecurityRequirements, operationName: "EditDeploymentsByIdAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/deployments/{id}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: new global::System.Net.Http.HttpMethod("PATCH"), - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/deployments/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: new global::System.Net.Http.HttpMethod("PATCH"), + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -104,233 +163,418 @@ partial void ProcessEditDeploymentsByIdResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareEditDeploymentsByIdRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareEditDeploymentsByIdRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id!, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessEditDeploymentsByIdResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Invalid request - if ((int)__response.StatusCode == 400) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - string? __value_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "editDeploymentsById", + methodName: "EditDeploymentsByIdAsync", + pathTemplate: "$\"/deployments/{id}\"", + httpMethod: "PATCH", + 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 { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "editDeploymentsById", + methodName: "EditDeploymentsByIdAsync", + pathTemplate: "$\"/deployments/{id}\"", + httpMethod: "PATCH", + 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; + } - __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } - throw new global::Together.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Deployment not found - if ((int)__response.StatusCode == 404) - { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; - string? __value_404 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "editDeploymentsById", + methodName: "EditDeploymentsByIdAsync", + pathTemplate: "$\"/deployments/{id}\"", + httpMethod: "PATCH", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_404 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Internal server error - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - string? __value_500 = null; - try + using (__response) { - if (ReadResponseAsString) - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); - } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); - } + ProcessResponse( + client: HttpClient, + response: __response); + ProcessEditDeploymentsByIdResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "editDeploymentsById", + methodName: "EditDeploymentsByIdAsync", + pathTemplate: "$\"/deployments/{id}\"", + httpMethod: "PATCH", + 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); } - catch (global::System.Exception __ex) + else { - __exception_500 = __ex; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "editDeploymentsById", + methodName: "EditDeploymentsByIdAsync", + pathTemplate: "$\"/deployments/{id}\"", + httpMethod: "PATCH", + 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); } + // Invalid request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + string? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) - { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } + __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + throw new global::Together.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Deployment not found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + string? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessEditDeploymentsByIdResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } - try - { - __response.EnsureSuccessStatusCode(); + throw new global::Together.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal server error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + string? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - global::Together.DeploymentResponseItem.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - } - catch (global::System.Exception __ex) - { - throw new global::Together.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 - cancellationToken -#endif - ).ConfigureAwait(false); + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } - return - await global::Together.DeploymentResponseItem.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessEditDeploymentsByIdResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.DeploymentResponseItem.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.DeploymentResponseItem.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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(); + } } /// /// Update a deployment
@@ -355,7 +599,7 @@ partial void ProcessEditDeploymentsByIdResponseContent( /// Description is an optional human-readable description of your deployment /// /// - /// EnvironmentVariables is a list of environment variables to set in the container. This will replace all existing environment variables + /// EnvironmentVariables is a list of environment variables to set in the container. Replaces all existing environment variables. /// /// /// GPUCount is the number of GPUs to allocate per container instance @@ -391,8 +635,9 @@ partial void ProcessEditDeploymentsByIdResponseContent( /// TerminationGracePeriodSeconds is the time in seconds to wait for graceful shutdown before forcefully terminating the replica /// /// - /// Volumes is a list of volume mounts to attach to the container. This will replace all existing volumes + /// Volumes is a list of volume mounts to attach to the container. Replaces all existing volumes. /// + /// 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 EditDeploymentsByIdAsync( @@ -415,6 +660,7 @@ partial void ProcessEditDeploymentsByIdResponseContent( int? storage = default, int? terminationGracePeriodSeconds = default, global::System.Collections.Generic.IList? volumes = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.UpdateDeploymentRequest @@ -442,6 +688,7 @@ partial void ProcessEditDeploymentsByIdResponseContent( return await EditDeploymentsByIdAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Together/Generated/Together.DeploymentsClient.GetDeployments.g.cs b/src/libs/Together/Generated/Together.DeploymentsClient.GetDeployments.g.cs index 0a64824d..8993303f 100644 --- a/src/libs/Together/Generated/Together.DeploymentsClient.GetDeployments.g.cs +++ b/src/libs/Together/Generated/Together.DeploymentsClient.GetDeployments.g.cs @@ -14,6 +14,7 @@ public partial class DeploymentsClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -42,6 +43,7 @@ partial void ProcessGetDeploymentsResponseContent( /// Get the list of deployments
/// Get a list of all deployments in your project ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -51,6 +53,31 @@ partial void ProcessGetDeploymentsResponseContent( /// print(deployments) /// public async global::System.Threading.Tasks.Task GetDeploymentsAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetDeploymentsAsResponseAsync( + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get the list of deployments
+ /// Get a list of all deployments in your project + ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// deployments = client.beta.jig.list()
+ /// print(deployments) + ///
+ public async global::System.Threading.Tasks.Task> GetDeploymentsAsResponseAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -64,22 +91,44 @@ partial void ProcessGetDeploymentsResponseContent( securityRequirements: s_GetDeploymentsSecurityRequirements, operationName: "GetDeploymentsAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/deployments", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/deployments", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -89,149 +138,334 @@ partial void ProcessGetDeploymentsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetDeploymentsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetDeploymentsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); - - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetDeploymentsResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Internal server error - if ((int)__response.StatusCode == 500) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - string? __value_500 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeployments", + methodName: "GetDeploymentsAsync", + pathTemplate: "\"/deployments\"", + httpMethod: "GET", + 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 { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeployments", + methodName: "GetDeploymentsAsync", + pathTemplate: "\"/deployments\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeployments", + methodName: "GetDeploymentsAsync", + pathTemplate: "\"/deployments\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_500 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessGetDeploymentsResponseContent( + response: __response); + ProcessGetDeploymentsResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.DeploymentListResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeployments", + methodName: "GetDeploymentsAsync", + pathTemplate: "\"/deployments\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeployments", + methodName: "GetDeploymentsAsync", + pathTemplate: "\"/deployments\"", + httpMethod: "GET", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Internal server error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + string? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.DeploymentListResponse.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessGetDeploymentsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.DeploymentListResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.DeploymentListResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.DeploymentsClient.GetDeploymentsById.g.cs b/src/libs/Together/Generated/Together.DeploymentsClient.GetDeploymentsById.g.cs index 80d7a7db..a0091413 100644 --- a/src/libs/Together/Generated/Together.DeploymentsClient.GetDeploymentsById.g.cs +++ b/src/libs/Together/Generated/Together.DeploymentsClient.GetDeploymentsById.g.cs @@ -14,6 +14,7 @@ public partial class DeploymentsClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,6 +48,7 @@ partial void ProcessGetDeploymentsByIdResponseContent( /// /// Deployment ID or name /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -57,6 +59,36 @@ partial void ProcessGetDeploymentsByIdResponseContent( /// public async global::System.Threading.Tasks.Task GetDeploymentsByIdAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetDeploymentsByIdAsResponseAsync( + id: id, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get a deployment by ID or name
+ /// Retrieve details of a specific deployment by its ID or name + ///
+ /// + /// Deployment ID or name + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// deployment = client.beta.jig.retrieve("my-deployment")
+ /// print(deployment) + ///
+ public async global::System.Threading.Tasks.Task> GetDeploymentsByIdAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -71,22 +103,44 @@ partial void ProcessGetDeploymentsByIdResponseContent( securityRequirements: s_GetDeploymentsByIdSecurityRequirements, operationName: "GetDeploymentsByIdAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/deployments/{id}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/deployments/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -96,188 +150,373 @@ partial void ProcessGetDeploymentsByIdResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetDeploymentsByIdRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetDeploymentsByIdRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id!); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetDeploymentsByIdResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Deployment not found - if ((int)__response.StatusCode == 404) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; - string? __value_404 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsById", + methodName: "GetDeploymentsByIdAsync", + pathTemplate: "$\"/deployments/{id}\"", + httpMethod: "GET", + 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 { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsById", + methodName: "GetDeploymentsByIdAsync", + pathTemplate: "$\"/deployments/{id}\"", + httpMethod: "GET", + 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; + } - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_404 = __ex; - } - throw new global::Together.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Internal server error - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - string? __value_500 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsById", + methodName: "GetDeploymentsByIdAsync", + pathTemplate: "$\"/deployments/{id}\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_500 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessGetDeploymentsByIdResponseContent( + response: __response); + ProcessGetDeploymentsByIdResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.DeploymentResponseItem.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsById", + methodName: "GetDeploymentsByIdAsync", + pathTemplate: "$\"/deployments/{id}\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsById", + methodName: "GetDeploymentsByIdAsync", + pathTemplate: "$\"/deployments/{id}\"", + httpMethod: "GET", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Deployment not found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + string? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.DeploymentResponseItem.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Together.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal server error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + string? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessGetDeploymentsByIdResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.DeploymentResponseItem.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.DeploymentResponseItem.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.DeploymentsClient.GetDeploymentsByIdLogs.g.cs b/src/libs/Together/Generated/Together.DeploymentsClient.GetDeploymentsByIdLogs.g.cs index 9ade3380..28a9858a 100644 --- a/src/libs/Together/Generated/Together.DeploymentsClient.GetDeploymentsByIdLogs.g.cs +++ b/src/libs/Together/Generated/Together.DeploymentsClient.GetDeploymentsByIdLogs.g.cs @@ -14,6 +14,7 @@ public partial class DeploymentsClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -52,6 +53,7 @@ partial void ProcessGetDeploymentsByIdLogsResponseContent( /// /// Replica ID to filter logs /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -63,6 +65,41 @@ partial void ProcessGetDeploymentsByIdLogsResponseContent( public async global::System.Threading.Tasks.Task GetDeploymentsByIdLogsAsync( string id, string? replicaId = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetDeploymentsByIdLogsAsResponseAsync( + id: id, + replicaId: replicaId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get logs for a deployment
+ /// Retrieve logs from a deployment, optionally filtered by replica ID. + ///
+ /// + /// Deployment ID or name + /// + /// + /// Replica ID to filter logs + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// deployment = client.beta.jig.logs("my-deployment")
+ /// print(deployment) + ///
+ public async global::System.Threading.Tasks.Task> GetDeploymentsByIdLogsAsResponseAsync( + string id, + string? replicaId = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -78,25 +115,47 @@ partial void ProcessGetDeploymentsByIdLogsResponseContent( securityRequirements: s_GetDeploymentsByIdLogsSecurityRequirements, operationName: "GetDeploymentsByIdLogsAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/deployments/{id}/logs", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("replica_id", replicaId) - ; - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/deployments/{id}/logs", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("replica_id", replicaId) + ; + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -106,189 +165,374 @@ partial void ProcessGetDeploymentsByIdLogsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetDeploymentsByIdLogsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - replicaId: replicaId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetDeploymentsByIdLogsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id!, + replicaId: replicaId); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetDeploymentsByIdLogsResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Deployment not found - if ((int)__response.StatusCode == 404) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; - string? __value_404 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsByIdLogs", + methodName: "GetDeploymentsByIdLogsAsync", + pathTemplate: "$\"/deployments/{id}/logs\"", + httpMethod: "GET", + 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 { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsByIdLogs", + methodName: "GetDeploymentsByIdLogsAsync", + pathTemplate: "$\"/deployments/{id}/logs\"", + httpMethod: "GET", + 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; + } - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_404 = __ex; - } - throw new global::Together.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Internal server error - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - string? __value_500 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsByIdLogs", + methodName: "GetDeploymentsByIdLogsAsync", + pathTemplate: "$\"/deployments/{id}/logs\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_500 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessGetDeploymentsByIdLogsResponseContent( + response: __response); + ProcessGetDeploymentsByIdLogsResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.DeploymentLogs.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsByIdLogs", + methodName: "GetDeploymentsByIdLogsAsync", + pathTemplate: "$\"/deployments/{id}/logs\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsByIdLogs", + methodName: "GetDeploymentsByIdLogsAsync", + pathTemplate: "$\"/deployments/{id}/logs\"", + httpMethod: "GET", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Deployment not found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + string? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.DeploymentLogs.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Together.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal server error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + string? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessGetDeploymentsByIdLogsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.DeploymentLogs.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.DeploymentLogs.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.DeploymentsClient.g.cs b/src/libs/Together/Generated/Together.DeploymentsClient.g.cs index bb6ea8aa..65374494 100644 --- a/src/libs/Together/Generated/Together.DeploymentsClient.g.cs +++ b/src/libs/Together/Generated/Together.DeploymentsClient.g.cs @@ -12,7 +12,7 @@ public sealed partial class DeploymentsClient : global::Together.IDeploymentsCli /// /// /// - public const string DefaultBaseUrl = "https://api.together.xyz/v1"; + public const string DefaultBaseUrl = "https://api.together.ai/v1"; private bool _disposeHttpClient = true; @@ -30,6 +30,12 @@ public sealed partial class DeploymentsClient : global::Together.IDeploymentsCli #if DEBUG = true; #endif + + /// + public global::Together.AutoSDKClientOptions Options { get; } + + + internal global::Together.AutoSDKServerConfiguration AutoSDKServerConfiguration { get; set; } = new global::Together.AutoSDKServerConfiguration(); /// /// /// @@ -49,13 +55,62 @@ public DeploymentsClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the DeploymentsClient with explicit options but no base URL override. + /// Skips passing baseUri so the default base URL from the OpenAPI spec applies. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public DeploymentsClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, + bool disposeHttpClient = true) : this( + httpClient, + baseUri: null, + authorizations, + options, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the DeploymentsClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public DeploymentsClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Together.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; + AutoSDKServerConfiguration.ExplicitBaseUri = baseUri ?? httpClient?.BaseAddress; + Initialized(HttpClient); } diff --git a/src/libs/Together/Generated/Together.DeploymentsStorageClient.GetDeploymentsStorageByFilename.g.cs b/src/libs/Together/Generated/Together.DeploymentsStorageClient.GetDeploymentsStorageByFilename.g.cs index c71187df..a571a8c1 100644 --- a/src/libs/Together/Generated/Together.DeploymentsStorageClient.GetDeploymentsStorageByFilename.g.cs +++ b/src/libs/Together/Generated/Together.DeploymentsStorageClient.GetDeploymentsStorageByFilename.g.cs @@ -14,6 +14,7 @@ public partial class DeploymentsStorageClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -42,10 +43,33 @@ partial void ProcessGetDeploymentsStorageByFilenameResponse( /// /// Filename /// + /// 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 GetDeploymentsStorageByFilenameAsync( string filename, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + await GetDeploymentsStorageByFilenameAsResponseAsync( + filename: filename, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + } + /// + /// Download a file
+ /// Download a file by redirecting to a signed URL + ///
+ /// + /// Filename + /// + /// 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 GetDeploymentsStorageByFilenameAsResponseAsync( + string filename, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -60,22 +84,44 @@ partial void ProcessGetDeploymentsStorageByFilenameResponse( securityRequirements: s_GetDeploymentsStorageByFilenameSecurityRequirements, operationName: "GetDeploymentsStorageByFilenameAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/deployments/storage/{filename}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/deployments/storage/{filename}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -85,247 +131,432 @@ partial void ProcessGetDeploymentsStorageByFilenameResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetDeploymentsStorageByFilenameRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - filename: filename); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetDeploymentsStorageByFilenameRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + filename: filename!); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetDeploymentsStorageByFilenameResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Redirect to signed download URL - if ((int)__response.StatusCode == 307) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_307 = null; - global::System.Exception? __exception_307 = null; - string? __value_307 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsStorageByFilename", + methodName: "GetDeploymentsStorageByFilenameAsync", + pathTemplate: "$\"/deployments/storage/{filename}\"", + httpMethod: "GET", + 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 { - __content_307 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_307 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_307, typeof(string), JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_307 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsStorageByFilename", + methodName: "GetDeploymentsStorageByFilenameAsync", + pathTemplate: "$\"/deployments/storage/{filename}\"", + httpMethod: "GET", + 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; + } - __value_307 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_307, typeof(string), JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_307 = __ex; - } - throw new global::Together.ApiException( - message: __content_307 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_307, - statusCode: __response.StatusCode) - { - ResponseBody = __content_307, - ResponseObject = __value_307, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Invalid request - if ((int)__response.StatusCode == 400) - { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - global::System.Collections.Generic.Dictionary? __value_400 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = (global::System.Collections.Generic.Dictionary?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(global::System.Collections.Generic.Dictionary), JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsStorageByFilename", + methodName: "GetDeploymentsStorageByFilenameAsync", + pathTemplate: "$\"/deployments/storage/{filename}\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = (global::System.Collections.Generic.Dictionary?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(global::System.Collections.Generic.Dictionary), JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_400 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException>( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // File not found - if ((int)__response.StatusCode == 404) - { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; - global::System.Collections.Generic.Dictionary? __value_404 = null; - try + using (__response) { - if (ReadResponseAsString) - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = (global::System.Collections.Generic.Dictionary?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(global::System.Collections.Generic.Dictionary), JsonSerializerContext); - } - else - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = (global::System.Collections.Generic.Dictionary?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(global::System.Collections.Generic.Dictionary), JsonSerializerContext); - } + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetDeploymentsStorageByFilenameResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsStorageByFilename", + methodName: "GetDeploymentsStorageByFilenameAsync", + pathTemplate: "$\"/deployments/storage/{filename}\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - __exception_404 = __ex; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsStorageByFilename", + methodName: "GetDeploymentsStorageByFilenameAsync", + pathTemplate: "$\"/deployments/storage/{filename}\"", + httpMethod: "GET", + 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); } + // Redirect to signed download URL + if ((int)__response.StatusCode == 307) + { + string? __content_307 = null; + global::System.Exception? __exception_307 = null; + string? __value_307 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_307 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_307 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_307, typeof(string), JsonSerializerContext); + } + else + { + __content_307 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - throw new global::Together.ApiException>( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Internal error - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - global::System.Collections.Generic.Dictionary? __value_500 = null; - try - { - if (ReadResponseAsString) - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = (global::System.Collections.Generic.Dictionary?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(global::System.Collections.Generic.Dictionary), JsonSerializerContext); - } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __value_307 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_307, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_307 = __ex; + } - __value_500 = (global::System.Collections.Generic.Dictionary?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(global::System.Collections.Generic.Dictionary), JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_500 = __ex; - } + throw new global::Together.ApiException( + message: __content_307 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_307, + statusCode: __response.StatusCode) + { + ResponseBody = __content_307, + ResponseObject = __value_307, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Invalid request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::System.Collections.Generic.Dictionary? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = (global::System.Collections.Generic.Dictionary?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(global::System.Collections.Generic.Dictionary), JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - throw new global::Together.ApiException>( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) - { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } + __value_400 = (global::System.Collections.Generic.Dictionary?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(global::System.Collections.Generic.Dictionary), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + throw new global::Together.ApiException>( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // File not found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::System.Collections.Generic.Dictionary? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = (global::System.Collections.Generic.Dictionary?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(global::System.Collections.Generic.Dictionary), JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + __value_404 = (global::System.Collections.Generic.Dictionary?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(global::System.Collections.Generic.Dictionary), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } - try - { - __response.EnsureSuccessStatusCode(); + throw new global::Together.ApiException>( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::System.Collections.Generic.Dictionary? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = (global::System.Collections.Generic.Dictionary?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(global::System.Collections.Generic.Dictionary), JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = (global::System.Collections.Generic.Dictionary?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(global::System.Collections.Generic.Dictionary), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Together.ApiException>( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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(); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri); + } + 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::Together.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), + }; + } + } - } - catch (global::System.Exception __ex) - { - throw new global::Together.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 + finally { - try - { - __response.EnsureSuccessStatusCode(); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } - - throw new global::Together.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), - }; - } + __httpRequest?.Dispose(); } } } diff --git a/src/libs/Together/Generated/Together.DeploymentsStorageClient.g.cs b/src/libs/Together/Generated/Together.DeploymentsStorageClient.g.cs index 5cb78004..7f378b75 100644 --- a/src/libs/Together/Generated/Together.DeploymentsStorageClient.g.cs +++ b/src/libs/Together/Generated/Together.DeploymentsStorageClient.g.cs @@ -12,7 +12,7 @@ public sealed partial class DeploymentsStorageClient : global::Together.IDeploym /// /// /// - public const string DefaultBaseUrl = "https://api.together.xyz/v1"; + public const string DefaultBaseUrl = "https://api.together.ai/v1"; private bool _disposeHttpClient = true; @@ -30,6 +30,12 @@ public sealed partial class DeploymentsStorageClient : global::Together.IDeploym #if DEBUG = true; #endif + + /// + public global::Together.AutoSDKClientOptions Options { get; } + + + internal global::Together.AutoSDKServerConfiguration AutoSDKServerConfiguration { get; set; } = new global::Together.AutoSDKServerConfiguration(); /// /// /// @@ -49,13 +55,62 @@ public DeploymentsStorageClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the DeploymentsStorageClient with explicit options but no base URL override. + /// Skips passing baseUri so the default base URL from the OpenAPI spec applies. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public DeploymentsStorageClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, + bool disposeHttpClient = true) : this( + httpClient, + baseUri: null, + authorizations, + options, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the DeploymentsStorageClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public DeploymentsStorageClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Together.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; + AutoSDKServerConfiguration.ExplicitBaseUri = baseUri ?? httpClient?.BaseAddress; + Initialized(HttpClient); } diff --git a/src/libs/Together/Generated/Together.DeploymentsVolumesClient.CreateDeploymentsStorageVolumes.g.cs b/src/libs/Together/Generated/Together.DeploymentsVolumesClient.CreateDeploymentsStorageVolumes.g.cs index 221bf3ff..936b7a26 100644 --- a/src/libs/Together/Generated/Together.DeploymentsVolumesClient.CreateDeploymentsStorageVolumes.g.cs +++ b/src/libs/Together/Generated/Together.DeploymentsVolumesClient.CreateDeploymentsStorageVolumes.g.cs @@ -14,6 +14,7 @@ public partial class DeploymentsVolumesClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,6 +46,7 @@ partial void ProcessCreateDeploymentsStorageVolumesResponseContent( /// Create a new volume to preload files in deployments ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -56,6 +58,36 @@ partial void ProcessCreateDeploymentsStorageVolumesResponseContent( public async global::System.Threading.Tasks.Task CreateDeploymentsStorageVolumesAsync( global::Together.CreateVolumeRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreateDeploymentsStorageVolumesAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Create a new volume
+ /// Create a new volume to preload files in deployments + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// volumes = client.beta.jig.volumes.create(name="my-volume")
+ /// print(volumes) + ///
+ public async global::System.Threading.Tasks.Task> CreateDeploymentsStorageVolumesAsResponseAsync( + + global::Together.CreateVolumeRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -72,22 +104,44 @@ partial void ProcessCreateDeploymentsStorageVolumesResponseContent( securityRequirements: s_CreateDeploymentsStorageVolumesSecurityRequirements, operationName: "CreateDeploymentsStorageVolumesAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/deployments/storage/volumes", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/deployments/storage/volumes", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -97,194 +151,379 @@ partial void ProcessCreateDeploymentsStorageVolumesResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateDeploymentsStorageVolumesRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateDeploymentsStorageVolumesRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateDeploymentsStorageVolumesResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Invalid request - if ((int)__response.StatusCode == 400) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - string? __value_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createDeploymentsStorageVolumes", + methodName: "CreateDeploymentsStorageVolumesAsync", + pathTemplate: "\"/deployments/storage/volumes\"", + 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 { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createDeploymentsStorageVolumes", + methodName: "CreateDeploymentsStorageVolumesAsync", + pathTemplate: "\"/deployments/storage/volumes\"", + 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; + } - __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } - throw new global::Together.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Internal server error - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - string? __value_500 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createDeploymentsStorageVolumes", + methodName: "CreateDeploymentsStorageVolumesAsync", + pathTemplate: "\"/deployments/storage/volumes\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_500 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessCreateDeploymentsStorageVolumesResponseContent( + response: __response); + ProcessCreateDeploymentsStorageVolumesResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.VolumeResponseItem.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createDeploymentsStorageVolumes", + methodName: "CreateDeploymentsStorageVolumesAsync", + pathTemplate: "\"/deployments/storage/volumes\"", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createDeploymentsStorageVolumes", + methodName: "CreateDeploymentsStorageVolumesAsync", + pathTemplate: "\"/deployments/storage/volumes\"", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Invalid request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + string? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.VolumeResponseItem.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Together.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal server error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + string? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessCreateDeploymentsStorageVolumesResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.VolumeResponseItem.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.VolumeResponseItem.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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 a new volume
@@ -299,12 +538,14 @@ partial void ProcessCreateDeploymentsStorageVolumesResponseContent( /// /// Type is the volume type (currently only "readOnly" is supported) /// + /// 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 CreateDeploymentsStorageVolumesAsync( global::Together.VolumeContentRequest content, string name, global::Together.VolumeType type = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.CreateVolumeRequest @@ -316,6 +557,7 @@ partial void ProcessCreateDeploymentsStorageVolumesResponseContent( return await CreateDeploymentsStorageVolumesAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Together/Generated/Together.DeploymentsVolumesClient.GetDeploymentsStorageVolumes.g.cs b/src/libs/Together/Generated/Together.DeploymentsVolumesClient.GetDeploymentsStorageVolumes.g.cs index 371f3fc7..4b0df238 100644 --- a/src/libs/Together/Generated/Together.DeploymentsVolumesClient.GetDeploymentsStorageVolumes.g.cs +++ b/src/libs/Together/Generated/Together.DeploymentsVolumesClient.GetDeploymentsStorageVolumes.g.cs @@ -14,6 +14,7 @@ public partial class DeploymentsVolumesClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -42,6 +43,7 @@ partial void ProcessGetDeploymentsStorageVolumesResponseContent( /// Get the list of project volumes
/// Retrieve all volumes in your project ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -51,6 +53,31 @@ partial void ProcessGetDeploymentsStorageVolumesResponseContent( /// print(volumes) /// public async global::System.Threading.Tasks.Task GetDeploymentsStorageVolumesAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetDeploymentsStorageVolumesAsResponseAsync( + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get the list of project volumes
+ /// Retrieve all volumes in your project + ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// volumes = client.beta.jig.storage.volumes.list()
+ /// print(volumes) + ///
+ public async global::System.Threading.Tasks.Task> GetDeploymentsStorageVolumesAsResponseAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -64,22 +91,44 @@ partial void ProcessGetDeploymentsStorageVolumesResponseContent( securityRequirements: s_GetDeploymentsStorageVolumesSecurityRequirements, operationName: "GetDeploymentsStorageVolumesAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/deployments/storage/volumes", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/deployments/storage/volumes", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -89,149 +138,334 @@ partial void ProcessGetDeploymentsStorageVolumesResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetDeploymentsStorageVolumesRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetDeploymentsStorageVolumesRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); - - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetDeploymentsStorageVolumesResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Internal server error - if ((int)__response.StatusCode == 500) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - string? __value_500 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsStorageVolumes", + methodName: "GetDeploymentsStorageVolumesAsync", + pathTemplate: "\"/deployments/storage/volumes\"", + httpMethod: "GET", + 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 { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsStorageVolumes", + methodName: "GetDeploymentsStorageVolumesAsync", + pathTemplate: "\"/deployments/storage/volumes\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsStorageVolumes", + methodName: "GetDeploymentsStorageVolumesAsync", + pathTemplate: "\"/deployments/storage/volumes\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_500 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessGetDeploymentsStorageVolumesResponseContent( + response: __response); + ProcessGetDeploymentsStorageVolumesResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.ListVolumesResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsStorageVolumes", + methodName: "GetDeploymentsStorageVolumesAsync", + pathTemplate: "\"/deployments/storage/volumes\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsStorageVolumes", + methodName: "GetDeploymentsStorageVolumesAsync", + pathTemplate: "\"/deployments/storage/volumes\"", + httpMethod: "GET", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Internal server error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + string? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.ListVolumesResponse.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessGetDeploymentsStorageVolumesResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.ListVolumesResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.ListVolumesResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.DeploymentsVolumesClient.g.cs b/src/libs/Together/Generated/Together.DeploymentsVolumesClient.g.cs index f1791281..4be0e720 100644 --- a/src/libs/Together/Generated/Together.DeploymentsVolumesClient.g.cs +++ b/src/libs/Together/Generated/Together.DeploymentsVolumesClient.g.cs @@ -12,7 +12,7 @@ public sealed partial class DeploymentsVolumesClient : global::Together.IDeploym /// /// /// - public const string DefaultBaseUrl = "https://api.together.xyz/v1"; + public const string DefaultBaseUrl = "https://api.together.ai/v1"; private bool _disposeHttpClient = true; @@ -30,6 +30,12 @@ public sealed partial class DeploymentsVolumesClient : global::Together.IDeploym #if DEBUG = true; #endif + + /// + public global::Together.AutoSDKClientOptions Options { get; } + + + internal global::Together.AutoSDKServerConfiguration AutoSDKServerConfiguration { get; set; } = new global::Together.AutoSDKServerConfiguration(); /// /// /// @@ -49,13 +55,62 @@ public DeploymentsVolumesClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the DeploymentsVolumesClient with explicit options but no base URL override. + /// Skips passing baseUri so the default base URL from the OpenAPI spec applies. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public DeploymentsVolumesClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, + bool disposeHttpClient = true) : this( + httpClient, + baseUri: null, + authorizations, + options, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the DeploymentsVolumesClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public DeploymentsVolumesClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Together.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; + AutoSDKServerConfiguration.ExplicitBaseUri = baseUri ?? httpClient?.BaseAddress; + Initialized(HttpClient); } diff --git a/src/libs/Together/Generated/Together.EmbeddingsClient.Embeddings.g.cs b/src/libs/Together/Generated/Together.EmbeddingsClient.Embeddings.g.cs index a88d261c..5b2c3956 100644 --- a/src/libs/Together/Generated/Together.EmbeddingsClient.Embeddings.g.cs +++ b/src/libs/Together/Generated/Together.EmbeddingsClient.Embeddings.g.cs @@ -14,6 +14,7 @@ public partial class EmbeddingsClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,6 +46,7 @@ partial void ProcessEmbeddingsResponseContent( /// Generate vector embeddings for one or more text inputs. Returns numerical arrays representing semantic meaning, useful for search, classification, and retrieval. /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -63,6 +65,43 @@ partial void ProcessEmbeddingsResponseContent( public async global::System.Threading.Tasks.Task EmbeddingsAsync( global::Together.EmbeddingsRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await EmbeddingsAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Create embedding
+ /// Generate vector embeddings for one or more text inputs. Returns numerical arrays representing semantic meaning, useful for search, classification, and retrieval. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.embeddings.create(
+ /// model="BAAI/bge-large-en-v1.5",
+ /// input="New York City",
+ /// )
+ /// print(response.data[0].embedding) + ///
+ public async global::System.Threading.Tasks.Task> EmbeddingsAsResponseAsync( + + global::Together.EmbeddingsRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -79,22 +118,44 @@ partial void ProcessEmbeddingsResponseContent( securityRequirements: s_EmbeddingsSecurityRequirements, operationName: "EmbeddingsAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/embeddings", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/embeddings", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -104,346 +165,531 @@ partial void ProcessEmbeddingsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } - } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareEmbeddingsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); - - ProcessResponse( - client: HttpClient, - response: __response); - ProcessEmbeddingsResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // BadRequest - if ((int)__response.StatusCode == 400) - { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - global::Together.ErrorData? __value_400 = null; - try - { - if (ReadResponseAsString) - { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); - } - else - { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - - __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } - - throw new global::Together.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + } } - // Unauthorized - if ((int)__response.StatusCode == 401) - { - string? __content_401 = null; - global::System.Exception? __exception_401 = null; - global::Together.ErrorData? __value_401 = null; - try - { - if (ReadResponseAsString) - { - __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); - } - else - { - __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - - __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_401 = __ex; - } + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareEmbeddingsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - throw new global::Together.ApiException( - message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_401, - statusCode: __response.StatusCode) - { - ResponseBody = __content_401, - ResponseObject = __value_401, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + return __httpRequest; } - // NotFound - if ((int)__response.StatusCode == 404) - { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; - global::Together.ErrorData? __value_404 = null; - try - { - if (ReadResponseAsString) - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); - } - else - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - - __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_404 = __ex; - } - throw new global::Together.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // RateLimit - if ((int)__response.StatusCode == 429) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_429 = null; - global::System.Exception? __exception_429 = null; - global::Together.ErrorData? __value_429 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Embeddings", + methodName: "EmbeddingsAsync", + pathTemplate: "\"/embeddings\"", + 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 { - __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_429 = global::Together.ErrorData.FromJson(__content_429, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - - __value_429 = global::Together.ErrorData.FromJson(__content_429, JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Embeddings", + methodName: "EmbeddingsAsync", + pathTemplate: "\"/embeddings\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_429 = __ex; - } - throw new global::Together.ApiException( - message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_429, - statusCode: __response.StatusCode) - { - ResponseBody = __content_429, - ResponseObject = __value_429, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Overloaded - if ((int)__response.StatusCode == 503) - { - string? __content_503 = null; - global::System.Exception? __exception_503 = null; - global::Together.ErrorData? __value_503 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_503 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_503 = global::Together.ErrorData.FromJson(__content_503, JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Embeddings", + methodName: "EmbeddingsAsync", + pathTemplate: "\"/embeddings\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_503 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_503 = global::Together.ErrorData.FromJson(__content_503, JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) - { - __exception_503 = __ex; - } - - throw new global::Together.ApiException( - message: __content_503 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_503, - statusCode: __response.StatusCode) - { - ResponseBody = __content_503, - ResponseObject = __value_503, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Timeout - if ((int)__response.StatusCode == 504) - { - string? __content_504 = null; - global::System.Exception? __exception_504 = null; - global::Together.ErrorData? __value_504 = null; - try - { - if (ReadResponseAsString) - { - __content_504 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_504 = global::Together.ErrorData.FromJson(__content_504, JsonSerializerContext); - } - else - { - __content_504 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_504 = global::Together.ErrorData.FromJson(__content_504, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) + if (__response == null) { - __exception_504 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_504 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_504, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_504, - ResponseObject = __value_504, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessEmbeddingsResponseContent( + response: __response); + ProcessEmbeddingsResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.EmbeddingsResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Embeddings", + methodName: "EmbeddingsAsync", + pathTemplate: "\"/embeddings\"", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Embeddings", + methodName: "EmbeddingsAsync", + pathTemplate: "\"/embeddings\"", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // BadRequest + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Together.ErrorData? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Together.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unauthorized + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Together.ErrorData? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Together.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseObject = __value_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // NotFound + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Together.ErrorData? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Together.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // RateLimit + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Together.ErrorData? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Together.ErrorData.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Together.ErrorData.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Together.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseObject = __value_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Overloaded + if ((int)__response.StatusCode == 503) + { + string? __content_503 = null; + global::System.Exception? __exception_503 = null; + global::Together.ErrorData? __value_503 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_503 = global::Together.ErrorData.FromJson(__content_503, JsonSerializerContext); + } + else + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_503 = global::Together.ErrorData.FromJson(__content_503, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_503 = __ex; + } + + throw new global::Together.ApiException( + message: __content_503 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_503, + statusCode: __response.StatusCode) + { + ResponseBody = __content_503, + ResponseObject = __value_503, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Timeout + if ((int)__response.StatusCode == 504) + { + string? __content_504 = null; + global::System.Exception? __exception_504 = null; + global::Together.ErrorData? __value_504 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_504 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_504 = global::Together.ErrorData.FromJson(__content_504, JsonSerializerContext); + } + else + { + __content_504 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_504 = global::Together.ErrorData.FromJson(__content_504, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_504 = __ex; + } + + throw new global::Together.ApiException( + message: __content_504 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_504, + statusCode: __response.StatusCode) + { + ResponseBody = __content_504, + ResponseObject = __value_504, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessEmbeddingsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.EmbeddingsResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.EmbeddingsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - return - await global::Together.EmbeddingsResponse.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } - - throw new global::Together.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 embedding
@@ -456,11 +702,13 @@ partial void ProcessEmbeddingsResponseContent( /// /// Example: Our solar system orbits the Milky Way galaxy at about 515,000 mph /// + /// 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 EmbeddingsAsync( global::Together.AnyOf model, global::Together.OneOf> input, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.EmbeddingsRequest @@ -471,6 +719,7 @@ partial void ProcessEmbeddingsResponseContent( return await EmbeddingsAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Together/Generated/Together.EmbeddingsClient.g.cs b/src/libs/Together/Generated/Together.EmbeddingsClient.g.cs index dcd9321a..4f9df31f 100644 --- a/src/libs/Together/Generated/Together.EmbeddingsClient.g.cs +++ b/src/libs/Together/Generated/Together.EmbeddingsClient.g.cs @@ -12,7 +12,7 @@ public sealed partial class EmbeddingsClient : global::Together.IEmbeddingsClien /// /// /// - public const string DefaultBaseUrl = "https://api.together.xyz/v1"; + public const string DefaultBaseUrl = "https://api.together.ai/v1"; private bool _disposeHttpClient = true; @@ -30,6 +30,12 @@ public sealed partial class EmbeddingsClient : global::Together.IEmbeddingsClien #if DEBUG = true; #endif + + /// + public global::Together.AutoSDKClientOptions Options { get; } + + + internal global::Together.AutoSDKServerConfiguration AutoSDKServerConfiguration { get; set; } = new global::Together.AutoSDKServerConfiguration(); /// /// /// @@ -49,13 +55,62 @@ public EmbeddingsClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the EmbeddingsClient with explicit options but no base URL override. + /// Skips passing baseUri so the default base URL from the OpenAPI spec applies. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public EmbeddingsClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, + bool disposeHttpClient = true) : this( + httpClient, + baseUri: null, + authorizations, + options, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the EmbeddingsClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public EmbeddingsClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Together.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; + AutoSDKServerConfiguration.ExplicitBaseUri = baseUri ?? httpClient?.BaseAddress; + Initialized(HttpClient); } diff --git a/src/libs/Together/Generated/Together.Endpoints2Client.AvailabilityZones.g.cs b/src/libs/Together/Generated/Together.Endpoints2Client.AvailabilityZones.g.cs index 0b2f5e33..08d2e821 100644 --- a/src/libs/Together/Generated/Together.Endpoints2Client.AvailabilityZones.g.cs +++ b/src/libs/Together/Generated/Together.Endpoints2Client.AvailabilityZones.g.cs @@ -14,6 +14,7 @@ public partial class Endpoints2Client { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -39,9 +40,10 @@ partial void ProcessAvailabilityZonesResponseContent( ref string content); /// - /// List all available availability zones.
+ /// List all available availability zones
/// List all available availability zones. ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -54,6 +56,34 @@ partial void ProcessAvailabilityZonesResponseContent( /// print(response.avzones) /// public async global::System.Threading.Tasks.Task AvailabilityZonesAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await AvailabilityZonesAsResponseAsync( + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// List all available availability zones
+ /// List all available availability zones. + ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.endpoints.list_avzones()
+ /// print(response.avzones) + ///
+ public async global::System.Threading.Tasks.Task> AvailabilityZonesAsResponseAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -67,22 +97,44 @@ partial void ProcessAvailabilityZonesResponseContent( securityRequirements: s_AvailabilityZonesSecurityRequirements, operationName: "AvailabilityZonesAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/clusters/availability-zones", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/clusters/availability-zones", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -92,111 +144,296 @@ partial void ProcessAvailabilityZonesResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareAvailabilityZonesRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareAvailabilityZonesRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessAvailabilityZonesResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AvailabilityZones", + methodName: "AvailabilityZonesAsync", + pathTemplate: "\"/clusters/availability-zones\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AvailabilityZones", + methodName: "AvailabilityZonesAsync", + pathTemplate: "\"/clusters/availability-zones\"", + httpMethod: "GET", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessAvailabilityZonesResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AvailabilityZones", + methodName: "AvailabilityZonesAsync", + pathTemplate: "\"/clusters/availability-zones\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::Together.ListAvailibilityZonesResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Together.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), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return - await global::Together.ListAvailibilityZonesResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessAvailabilityZonesResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AvailabilityZones", + methodName: "AvailabilityZonesAsync", + pathTemplate: "\"/clusters/availability-zones\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AvailabilityZones", + methodName: "AvailabilityZonesAsync", + pathTemplate: "\"/clusters/availability-zones\"", + httpMethod: "GET", + 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); + ProcessAvailabilityZonesResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.ListAvailibilityZonesResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.ListAvailibilityZonesResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.Endpoints2Client.g.cs b/src/libs/Together/Generated/Together.Endpoints2Client.g.cs index 1296c285..bbbade39 100644 --- a/src/libs/Together/Generated/Together.Endpoints2Client.g.cs +++ b/src/libs/Together/Generated/Together.Endpoints2Client.g.cs @@ -12,7 +12,7 @@ public sealed partial class Endpoints2Client : global::Together.IEndpoints2Clien /// /// /// - public const string DefaultBaseUrl = "https://api.together.xyz/v1"; + public const string DefaultBaseUrl = "https://api.together.ai/v1"; private bool _disposeHttpClient = true; @@ -30,6 +30,12 @@ public sealed partial class Endpoints2Client : global::Together.IEndpoints2Clien #if DEBUG = true; #endif + + /// + public global::Together.AutoSDKClientOptions Options { get; } + + + internal global::Together.AutoSDKServerConfiguration AutoSDKServerConfiguration { get; set; } = new global::Together.AutoSDKServerConfiguration(); /// /// /// @@ -49,13 +55,62 @@ public Endpoints2Client( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the Endpoints2Client with explicit options but no base URL override. + /// Skips passing baseUri so the default base URL from the OpenAPI spec applies. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public Endpoints2Client( + global::System.Net.Http.HttpClient? httpClient, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, + bool disposeHttpClient = true) : this( + httpClient, + baseUri: null, + authorizations, + options, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the Endpoints2Client. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public Endpoints2Client( + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Together.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; + AutoSDKServerConfiguration.ExplicitBaseUri = baseUri ?? httpClient?.BaseAddress; + Initialized(HttpClient); } diff --git a/src/libs/Together/Generated/Together.EndpointsClient.CreateEndpoint.g.cs b/src/libs/Together/Generated/Together.EndpointsClient.CreateEndpoint.g.cs index a2abc43f..8e429340 100644 --- a/src/libs/Together/Generated/Together.EndpointsClient.CreateEndpoint.g.cs +++ b/src/libs/Together/Generated/Together.EndpointsClient.CreateEndpoint.g.cs @@ -16,6 +16,7 @@ public partial class EndpointsClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -43,10 +44,11 @@ partial void ProcessCreateEndpointResponseContent( ref string content); /// - /// Create a dedicated endpoint, it will start automatically
- /// Creates a new dedicated endpoint for serving models. The endpoint will automatically start after creation. You can deploy any supported model on hardware configurations that meet the model's requirements. + /// Create a dedicated endpoint
+ /// Creates a new dedicated endpoint for serving models. The endpoint starts automatically after creation. You can deploy any supported model on hardware configurations that meet the model's requirements. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -69,6 +71,47 @@ partial void ProcessCreateEndpointResponseContent( public async global::System.Threading.Tasks.Task CreateEndpointAsync( global::Together.CreateEndpointRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreateEndpointAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Create a dedicated endpoint
+ /// Creates a new dedicated endpoint for serving models. The endpoint starts automatically after creation. You can deploy any supported model on hardware configurations that meet the model's requirements. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// endpoint = client.endpoints.create(
+ /// model="Qwen/Qwen3.5-9B-FP8",
+ /// hardware="1x_nvidia_a100_80gb_sxm",
+ /// autoscaling={
+ /// "min_replicas": 2,
+ /// "max_replicas": 5,
+ /// }
+ /// )
+ /// print(endpoint.id) + ///
+ public async global::System.Threading.Tasks.Task> CreateEndpointAsResponseAsync( + + global::Together.CreateEndpointRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -85,22 +128,44 @@ partial void ProcessCreateEndpointResponseContent( securityRequirements: s_CreateEndpointSecurityRequirements, operationName: "CreateEndpointAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/endpoints", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/endpoints", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -110,198 +175,383 @@ partial void ProcessCreateEndpointResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateEndpointRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateEndpointRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateEndpointResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Unauthorized - if ((int)__response.StatusCode == 403) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - global::Together.ErrorData? __value_403 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateEndpoint", + methodName: "CreateEndpointAsync", + pathTemplate: "\"/endpoints\"", + 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 { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_403 = global::Together.ErrorData.FromJson(__content_403, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateEndpoint", + methodName: "CreateEndpointAsync", + pathTemplate: "\"/endpoints\"", + 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; + } - __value_403 = global::Together.ErrorData.FromJson(__content_403, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_403 = __ex; - } - throw new global::Together.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) - { - ResponseBody = __content_403, - ResponseObject = __value_403, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Internal error - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - global::Together.ErrorData? __value_500 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateEndpoint", + methodName: "CreateEndpointAsync", + pathTemplate: "\"/endpoints\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_500 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessCreateEndpointResponseContent( + response: __response); + ProcessCreateEndpointResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.DedicatedEndpoint.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateEndpoint", + methodName: "CreateEndpointAsync", + pathTemplate: "\"/endpoints\"", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateEndpoint", + methodName: "CreateEndpointAsync", + pathTemplate: "\"/endpoints\"", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Unauthorized + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Together.ErrorData? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Together.ErrorData.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.DedicatedEndpoint.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_403 = global::Together.ErrorData.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::Together.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseObject = __value_403, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Together.ErrorData? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessCreateEndpointResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.DedicatedEndpoint.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.DedicatedEndpoint.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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 a dedicated endpoint, it will start automatically
- /// Creates a new dedicated endpoint for serving models. The endpoint will automatically start after creation. You can deploy any supported model on hardware configurations that meet the model's requirements. + /// Create a dedicated endpoint
+ /// Creates a new dedicated endpoint for serving models. The endpoint starts automatically after creation. You can deploy any supported model on hardware configurations that meet the model's requirements. ///
/// /// A human-readable name for the endpoint
@@ -328,12 +578,13 @@ partial void ProcessCreateEndpointResponseContent( /// Example: STARTED /// /// - /// The number of minutes of inactivity after which the endpoint will be automatically stopped. Set to null, omit or set to 0 to disable automatic timeout.
+ /// The number of minutes of inactivity after which the endpoint stops automatically. Set to null, omit, or set to 0 to disable automatic timeout.
/// Example: 60 /// /// /// Create the endpoint in a specified availability zone (e.g., us-central-4b) /// + /// 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 CreateEndpointAsync( @@ -345,6 +596,7 @@ partial void ProcessCreateEndpointResponseContent( global::Together.CreateEndpointRequestState? state = default, int? inactiveTimeout = default, string? availabilityZone = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.CreateEndpointRequest @@ -361,6 +613,7 @@ partial void ProcessCreateEndpointResponseContent( return await CreateEndpointAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Together/Generated/Together.EndpointsClient.DeleteEndpoint.g.cs b/src/libs/Together/Generated/Together.EndpointsClient.DeleteEndpoint.g.cs index 8b809fe0..5b1076d1 100644 --- a/src/libs/Together/Generated/Together.EndpointsClient.DeleteEndpoint.g.cs +++ b/src/libs/Together/Generated/Together.EndpointsClient.DeleteEndpoint.g.cs @@ -14,6 +14,7 @@ public partial class EndpointsClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -43,6 +44,7 @@ partial void ProcessDeleteEndpointResponse( /// The ID of the endpoint to delete
/// Example: endpoint-d23901de-ef8f-44bf-b3e7-de9c1ca8f2d7 /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -57,6 +59,39 @@ partial void ProcessDeleteEndpointResponse( /// public async global::System.Threading.Tasks.Task DeleteEndpointAsync( string endpointId, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + await DeleteEndpointAsResponseAsync( + endpointId: endpointId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + } + /// + /// Delete endpoint
+ /// Permanently deletes an endpoint. This action cannot be undone. + ///
+ /// + /// The ID of the endpoint to delete
+ /// Example: endpoint-d23901de-ef8f-44bf-b3e7-de9c1ca8f2d7 + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// endpoint = client.endpoints.delete("endpoint-id")
+ /// print(endpoint) + ///
+ public async global::System.Threading.Tasks.Task DeleteEndpointAsResponseAsync( + string endpointId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -71,22 +106,44 @@ partial void ProcessDeleteEndpointResponse( securityRequirements: s_DeleteEndpointSecurityRequirements, operationName: "DeleteEndpointAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/endpoints/{endpointId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Delete, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/endpoints/{endpointId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Delete, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -96,209 +153,394 @@ partial void ProcessDeleteEndpointResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteEndpointRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - endpointId: endpointId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteEndpointRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + endpointId: endpointId!); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteEndpointResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Unauthorized - if ((int)__response.StatusCode == 403) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - global::Together.ErrorData? __value_403 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteEndpoint", + methodName: "DeleteEndpointAsync", + pathTemplate: "$\"/endpoints/{endpointId}\"", + httpMethod: "DELETE", + 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 { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_403 = global::Together.ErrorData.FromJson(__content_403, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteEndpoint", + methodName: "DeleteEndpointAsync", + pathTemplate: "$\"/endpoints/{endpointId}\"", + httpMethod: "DELETE", + 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; + } - __value_403 = global::Together.ErrorData.FromJson(__content_403, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_403 = __ex; - } - throw new global::Together.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) - { - ResponseBody = __content_403, - ResponseObject = __value_403, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Not Found - if ((int)__response.StatusCode == 404) - { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; - global::Together.ErrorData? __value_404 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteEndpoint", + methodName: "DeleteEndpointAsync", + pathTemplate: "$\"/endpoints/{endpointId}\"", + httpMethod: "DELETE", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_404 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Internal error - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - global::Together.ErrorData? __value_500 = null; - try - { - if (ReadResponseAsString) - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); - } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); - } + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteEndpointResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteEndpoint", + methodName: "DeleteEndpointAsync", + pathTemplate: "$\"/endpoints/{endpointId}\"", + httpMethod: "DELETE", + 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); } - catch (global::System.Exception __ex) + else { - __exception_500 = __ex; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteEndpoint", + methodName: "DeleteEndpointAsync", + pathTemplate: "$\"/endpoints/{endpointId}\"", + httpMethod: "DELETE", + 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); } + // Unauthorized + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Together.ErrorData? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Together.ErrorData.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) - { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } + __value_403 = global::Together.ErrorData.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + throw new global::Together.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseObject = __value_403, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Not Found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Together.ErrorData? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } - try - { - __response.EnsureSuccessStatusCode(); + throw new global::Together.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Together.ErrorData? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + + try + { + __response.EnsureSuccessStatusCode(); + + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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(); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri); + } + 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::Together.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), + }; + } + } - } - catch (global::System.Exception __ex) - { - throw new global::Together.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 + finally { - try - { - __response.EnsureSuccessStatusCode(); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } - - throw new global::Together.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), - }; - } + __httpRequest?.Dispose(); } } } diff --git a/src/libs/Together/Generated/Together.EndpointsClient.GetEndpoint.g.cs b/src/libs/Together/Generated/Together.EndpointsClient.GetEndpoint.g.cs index 2c0ea7f4..f65fb507 100644 --- a/src/libs/Together/Generated/Together.EndpointsClient.GetEndpoint.g.cs +++ b/src/libs/Together/Generated/Together.EndpointsClient.GetEndpoint.g.cs @@ -14,6 +14,7 @@ public partial class EndpointsClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,6 +49,7 @@ partial void ProcessGetEndpointResponseContent( /// The ID of the endpoint to retrieve
/// Example: endpoint-d23901de-ef8f-44bf-b3e7-de9c1ca8f2d7 /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -62,6 +64,41 @@ partial void ProcessGetEndpointResponseContent( /// public async global::System.Threading.Tasks.Task GetEndpointAsync( string endpointId, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetEndpointAsResponseAsync( + endpointId: endpointId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get endpoint by ID
+ /// Retrieves details about a specific endpoint, including its current state, configuration, and scaling settings. + ///
+ /// + /// The ID of the endpoint to retrieve
+ /// Example: endpoint-d23901de-ef8f-44bf-b3e7-de9c1ca8f2d7 + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// endpoint = client.endpoints.retrieve("endpoint-id")
+ /// print(endpoint.id) + ///
+ public async global::System.Threading.Tasks.Task> GetEndpointAsResponseAsync( + string endpointId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -76,22 +113,44 @@ partial void ProcessGetEndpointResponseContent( securityRequirements: s_GetEndpointSecurityRequirements, operationName: "GetEndpointAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/endpoints/{endpointId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/endpoints/{endpointId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -101,226 +160,411 @@ partial void ProcessGetEndpointResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetEndpointRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - endpointId: endpointId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetEndpointRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + endpointId: endpointId!); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetEndpointResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Unauthorized - if ((int)__response.StatusCode == 403) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - global::Together.ErrorData? __value_403 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetEndpoint", + methodName: "GetEndpointAsync", + pathTemplate: "$\"/endpoints/{endpointId}\"", + httpMethod: "GET", + 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 { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_403 = global::Together.ErrorData.FromJson(__content_403, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetEndpoint", + methodName: "GetEndpointAsync", + pathTemplate: "$\"/endpoints/{endpointId}\"", + httpMethod: "GET", + 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; + } - __value_403 = global::Together.ErrorData.FromJson(__content_403, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_403 = __ex; - } - throw new global::Together.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) - { - ResponseBody = __content_403, - ResponseObject = __value_403, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Not Found - if ((int)__response.StatusCode == 404) - { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; - global::Together.ErrorData? __value_404 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetEndpoint", + methodName: "GetEndpointAsync", + pathTemplate: "$\"/endpoints/{endpointId}\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_404 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Internal error - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - global::Together.ErrorData? __value_500 = null; - try + using (__response) { - if (ReadResponseAsString) - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); - } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); - } + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetEndpointResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetEndpoint", + methodName: "GetEndpointAsync", + pathTemplate: "$\"/endpoints/{endpointId}\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - __exception_500 = __ex; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetEndpoint", + methodName: "GetEndpointAsync", + pathTemplate: "$\"/endpoints/{endpointId}\"", + httpMethod: "GET", + 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); } + // Unauthorized + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Together.ErrorData? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Together.ErrorData.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) - { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } + __value_403 = global::Together.ErrorData.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + throw new global::Together.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseObject = __value_403, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Not Found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Together.ErrorData? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessGetEndpointResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } - try - { - __response.EnsureSuccessStatusCode(); + throw new global::Together.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Together.ErrorData? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - global::Together.DedicatedEndpoint.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - } - catch (global::System.Exception __ex) - { - throw new global::Together.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 - cancellationToken -#endif - ).ConfigureAwait(false); + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } - return - await global::Together.DedicatedEndpoint.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessGetEndpointResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.DedicatedEndpoint.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.DedicatedEndpoint.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.EndpointsClient.ListEndpoints.g.cs b/src/libs/Together/Generated/Together.EndpointsClient.ListEndpoints.g.cs index 28c41362..df4beb62 100644 --- a/src/libs/Together/Generated/Together.EndpointsClient.ListEndpoints.g.cs +++ b/src/libs/Together/Generated/Together.EndpointsClient.ListEndpoints.g.cs @@ -14,6 +14,7 @@ public partial class EndpointsClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,7 +46,7 @@ partial void ProcessListEndpointsResponseContent( ref string content); /// - /// List all endpoints, can be filtered by type
+ /// List all endpoints
/// Returns a list of all endpoints associated with your account. You can filter the results by type (dedicated or serverless). ///
/// @@ -57,6 +58,7 @@ partial void ProcessListEndpointsResponseContent( /// /// If true, return only endpoints owned by the caller /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -74,6 +76,51 @@ partial void ProcessListEndpointsResponseContent( global::Together.ListEndpointsType? type = default, global::Together.ListEndpointsUsageType? usageType = default, bool? mine = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await ListEndpointsAsResponseAsync( + type: type, + usageType: usageType, + mine: mine, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// List all endpoints
+ /// Returns a list of all endpoints associated with your account. You can filter the results by type (dedicated or serverless). + ///
+ /// + /// Filter endpoints by type + /// + /// + /// Filter endpoints by usage type + /// + /// + /// If true, return only endpoints owned by the caller + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.endpoints.list()
+ /// for endpoint in response.data:
+ /// print(endpoint.id) + ///
+ public async global::System.Threading.Tasks.Task> ListEndpointsAsResponseAsync( + global::Together.ListEndpointsType? type = default, + global::Together.ListEndpointsUsageType? usageType = default, + bool? mine = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -90,27 +137,49 @@ partial void ProcessListEndpointsResponseContent( securityRequirements: s_ListEndpointsSecurityRequirements, operationName: "ListEndpointsAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/endpoints", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("type", type?.ToValueString()) - .AddOptionalParameter("usage_type", usageType?.ToValueString()) - .AddOptionalParameter("mine", mine?.ToString().ToLowerInvariant()) - ; - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/endpoints", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("type", type?.ToValueString()) + .AddOptionalParameter("usage_type", usageType?.ToValueString()) + .AddOptionalParameter("mine", mine?.ToString().ToLowerInvariant()) + ; + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -120,190 +189,375 @@ partial void ProcessListEndpointsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListEndpointsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - type: type, - usageType: usageType, - mine: mine); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListEndpointsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + type: type, + usageType: usageType, + mine: mine); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListEndpointsResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Unauthorized - if ((int)__response.StatusCode == 403) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - global::Together.ErrorData? __value_403 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListEndpoints", + methodName: "ListEndpointsAsync", + pathTemplate: "\"/endpoints\"", + httpMethod: "GET", + 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 { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_403 = global::Together.ErrorData.FromJson(__content_403, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListEndpoints", + methodName: "ListEndpointsAsync", + pathTemplate: "\"/endpoints\"", + httpMethod: "GET", + 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; + } - __value_403 = global::Together.ErrorData.FromJson(__content_403, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_403 = __ex; - } - throw new global::Together.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) - { - ResponseBody = __content_403, - ResponseObject = __value_403, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Internal error - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - global::Together.ErrorData? __value_500 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListEndpoints", + methodName: "ListEndpointsAsync", + pathTemplate: "\"/endpoints\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_500 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessListEndpointsResponseContent( + response: __response); + ProcessListEndpointsResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.ListEndpointsResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListEndpoints", + methodName: "ListEndpointsAsync", + pathTemplate: "\"/endpoints\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListEndpoints", + methodName: "ListEndpointsAsync", + pathTemplate: "\"/endpoints\"", + httpMethod: "GET", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Unauthorized + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Together.ErrorData? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Together.ErrorData.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.ListEndpointsResponse.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_403 = global::Together.ErrorData.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::Together.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseObject = __value_403, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Together.ErrorData? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessListEndpointsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.ListEndpointsResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.ListEndpointsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.EndpointsClient.UpdateEndpoint.g.cs b/src/libs/Together/Generated/Together.EndpointsClient.UpdateEndpoint.g.cs index 99d8baab..f81b2956 100644 --- a/src/libs/Together/Generated/Together.EndpointsClient.UpdateEndpoint.g.cs +++ b/src/libs/Together/Generated/Together.EndpointsClient.UpdateEndpoint.g.cs @@ -14,6 +14,7 @@ public partial class EndpointsClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,6 +52,7 @@ partial void ProcessUpdateEndpointResponseContent( /// Example: endpoint-d23901de-ef8f-44bf-b3e7-de9c1ca8f2d7 /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -70,6 +72,49 @@ partial void ProcessUpdateEndpointResponseContent( string endpointId, global::Together.UpdateEndpointRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await UpdateEndpointAsResponseAsync( + endpointId: endpointId, + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Update endpoint, this can also be used to start or stop a dedicated endpoint
+ /// Updates an existing endpoint's configuration. You can modify the display name, autoscaling settings, or change the endpoint's state (start/stop). + ///
+ /// + /// The ID of the endpoint to update
+ /// Example: endpoint-d23901de-ef8f-44bf-b3e7-de9c1ca8f2d7 + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// endpoint = client.endpoints.update(
+ /// "endpoint-id",
+ /// state="STOPPED"
+ /// )
+ /// print(endpoint) + ///
+ public async global::System.Threading.Tasks.Task> UpdateEndpointAsResponseAsync( + string endpointId, + + global::Together.UpdateEndpointRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -87,22 +132,44 @@ partial void ProcessUpdateEndpointResponseContent( securityRequirements: s_UpdateEndpointSecurityRequirements, operationName: "UpdateEndpointAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/endpoints/{endpointId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: new global::System.Net.Http.HttpMethod("PATCH"), - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/endpoints/{endpointId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: new global::System.Net.Http.HttpMethod("PATCH"), + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -112,233 +179,418 @@ partial void ProcessUpdateEndpointResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareUpdateEndpointRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - endpointId: endpointId, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareUpdateEndpointRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + endpointId: endpointId!, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateEndpointResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Unauthorized - if ((int)__response.StatusCode == 403) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - global::Together.ErrorData? __value_403 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateEndpoint", + methodName: "UpdateEndpointAsync", + pathTemplate: "$\"/endpoints/{endpointId}\"", + httpMethod: "PATCH", + 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 { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_403 = global::Together.ErrorData.FromJson(__content_403, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateEndpoint", + methodName: "UpdateEndpointAsync", + pathTemplate: "$\"/endpoints/{endpointId}\"", + httpMethod: "PATCH", + 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; + } - __value_403 = global::Together.ErrorData.FromJson(__content_403, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_403 = __ex; - } - throw new global::Together.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) - { - ResponseBody = __content_403, - ResponseObject = __value_403, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Not Found - if ((int)__response.StatusCode == 404) - { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; - global::Together.ErrorData? __value_404 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateEndpoint", + methodName: "UpdateEndpointAsync", + pathTemplate: "$\"/endpoints/{endpointId}\"", + httpMethod: "PATCH", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_404 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Internal error - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - global::Together.ErrorData? __value_500 = null; - try + using (__response) { - if (ReadResponseAsString) - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); - } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); - } + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateEndpointResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateEndpoint", + methodName: "UpdateEndpointAsync", + pathTemplate: "$\"/endpoints/{endpointId}\"", + httpMethod: "PATCH", + 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); } - catch (global::System.Exception __ex) + else { - __exception_500 = __ex; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateEndpoint", + methodName: "UpdateEndpointAsync", + pathTemplate: "$\"/endpoints/{endpointId}\"", + httpMethod: "PATCH", + 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); } + // Unauthorized + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Together.ErrorData? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Together.ErrorData.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) - { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } + __value_403 = global::Together.ErrorData.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + throw new global::Together.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseObject = __value_403, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Not Found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Together.ErrorData? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateEndpointResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } - try - { - __response.EnsureSuccessStatusCode(); + throw new global::Together.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Together.ErrorData? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - global::Together.DedicatedEndpoint.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - } - catch (global::System.Exception __ex) - { - throw new global::Together.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 - cancellationToken -#endif - ).ConfigureAwait(false); + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } - return - await global::Together.DedicatedEndpoint.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessUpdateEndpointResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.DedicatedEndpoint.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.DedicatedEndpoint.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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(); + } } /// /// Update endpoint, this can also be used to start or stop a dedicated endpoint
@@ -360,9 +612,10 @@ partial void ProcessUpdateEndpointResponseContent( /// New autoscaling configuration for the endpoint /// /// - /// The number of minutes of inactivity after which the endpoint will be automatically stopped. Set to 0 to disable automatic timeout.
+ /// The number of minutes of inactivity after which the endpoint stops automatically. Set to 0 to disable automatic timeout.
/// Example: 60 /// + /// 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 UpdateEndpointAsync( @@ -371,6 +624,7 @@ partial void ProcessUpdateEndpointResponseContent( global::Together.UpdateEndpointRequestState? state = default, global::Together.Autoscaling? autoscaling = default, int? inactiveTimeout = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.UpdateEndpointRequest @@ -384,6 +638,7 @@ partial void ProcessUpdateEndpointResponseContent( return await UpdateEndpointAsync( endpointId: endpointId, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Together/Generated/Together.EndpointsClient.g.cs b/src/libs/Together/Generated/Together.EndpointsClient.g.cs index 1de07ba0..3c831861 100644 --- a/src/libs/Together/Generated/Together.EndpointsClient.g.cs +++ b/src/libs/Together/Generated/Together.EndpointsClient.g.cs @@ -12,7 +12,7 @@ public sealed partial class EndpointsClient : global::Together.IEndpointsClient, /// /// /// - public const string DefaultBaseUrl = "https://api.together.xyz/v1"; + public const string DefaultBaseUrl = "https://api.together.ai/v1"; private bool _disposeHttpClient = true; @@ -30,6 +30,12 @@ public sealed partial class EndpointsClient : global::Together.IEndpointsClient, #if DEBUG = true; #endif + + /// + public global::Together.AutoSDKClientOptions Options { get; } + + + internal global::Together.AutoSDKServerConfiguration AutoSDKServerConfiguration { get; set; } = new global::Together.AutoSDKServerConfiguration(); /// /// /// @@ -49,13 +55,62 @@ public EndpointsClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the EndpointsClient with explicit options but no base URL override. + /// Skips passing baseUri so the default base URL from the OpenAPI spec applies. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public EndpointsClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, + bool disposeHttpClient = true) : this( + httpClient, + baseUri: null, + authorizations, + options, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the EndpointsClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public EndpointsClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Together.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; + AutoSDKServerConfiguration.ExplicitBaseUri = baseUri ?? httpClient?.BaseAddress; + Initialized(HttpClient); } diff --git a/src/libs/Together/Generated/Together.EvaluationClient.CreateEvaluationJob.g.cs b/src/libs/Together/Generated/Together.EvaluationClient.CreateEvaluationJob.g.cs index 7e2a148e..aefc69fc 100644 --- a/src/libs/Together/Generated/Together.EvaluationClient.CreateEvaluationJob.g.cs +++ b/src/libs/Together/Generated/Together.EvaluationClient.CreateEvaluationJob.g.cs @@ -14,6 +14,7 @@ public partial class EvaluationClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -44,6 +45,7 @@ partial void ProcessCreateEvaluationJobResponseContent( /// Create an evaluation job ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -72,6 +74,52 @@ partial void ProcessCreateEvaluationJobResponseContent( public async global::System.Threading.Tasks.Task CreateEvaluationJobAsync( global::Together.EvaluationTypedRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreateEvaluationJobAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Create an evaluation job + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.evals.create(
+ /// type="classify",
+ /// parameters=ParametersEvaluationClassifyParameters(
+ /// judge=ParametersEvaluationClassifyParametersJudge(
+ /// model="openai/gpt-oss-120b",
+ /// model_source="serverless",
+ /// system_template="You are an expert evaluator...",
+ /// ),
+ /// input_data_file_path="file-abc123",
+ /// labels=["good", "bad"],
+ /// pass_labels=["good"],
+ /// model_to_evaluate="Qwen/Qwen3.5-9B"
+ /// )
+ /// )
+ /// print(response.workflow_id) + ///
+ public async global::System.Threading.Tasks.Task> CreateEvaluationJobAsResponseAsync( + + global::Together.EvaluationTypedRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -88,22 +136,44 @@ partial void ProcessCreateEvaluationJobResponseContent( securityRequirements: s_CreateEvaluationJobSecurityRequirements, operationName: "CreateEvaluationJobAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/evaluation", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/evaluation", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -113,194 +183,379 @@ partial void ProcessCreateEvaluationJobResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateEvaluationJobRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateEvaluationJobRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateEvaluationJobResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Invalid request format - if ((int)__response.StatusCode == 400) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - global::Together.ErrorData? __value_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateEvaluationJob", + methodName: "CreateEvaluationJobAsync", + pathTemplate: "\"/evaluation\"", + 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 { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateEvaluationJob", + methodName: "CreateEvaluationJobAsync", + pathTemplate: "\"/evaluation\"", + 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; + } - __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } - throw new global::Together.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Failed to create evaluation job - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - global::Together.ErrorData? __value_500 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateEvaluationJob", + methodName: "CreateEvaluationJobAsync", + pathTemplate: "\"/evaluation\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_500 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessCreateEvaluationJobResponseContent( + response: __response); + ProcessCreateEvaluationJobResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.EvaluationResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateEvaluationJob", + methodName: "CreateEvaluationJobAsync", + pathTemplate: "\"/evaluation\"", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateEvaluationJob", + methodName: "CreateEvaluationJobAsync", + pathTemplate: "\"/evaluation\"", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Invalid request format + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Together.ErrorData? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.EvaluationResponse.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Together.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Failed to create evaluation job + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Together.ErrorData? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessCreateEvaluationJobResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.EvaluationResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.EvaluationResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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 an evaluation job @@ -312,11 +567,13 @@ partial void ProcessCreateEvaluationJobResponseContent( /// /// Type-specific parameters for the evaluation /// + /// 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 CreateEvaluationJobAsync( global::Together.EvaluationTypedRequestType type, global::Together.OneOf parameters, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.EvaluationTypedRequest @@ -327,6 +584,7 @@ partial void ProcessCreateEvaluationJobResponseContent( return await CreateEvaluationJobAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Together/Generated/Together.EvaluationClient.GetAllEvaluationJobs.g.cs b/src/libs/Together/Generated/Together.EvaluationClient.GetAllEvaluationJobs.g.cs index 880ef688..9228b947 100644 --- a/src/libs/Together/Generated/Together.EvaluationClient.GetAllEvaluationJobs.g.cs +++ b/src/libs/Together/Generated/Together.EvaluationClient.GetAllEvaluationJobs.g.cs @@ -14,6 +14,7 @@ public partial class EvaluationClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -52,6 +53,7 @@ partial void ProcessGetAllEvaluationJobsResponseContent( /// Limit the number of results
/// Default Value: 10 /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -68,6 +70,46 @@ partial void ProcessGetAllEvaluationJobsResponseContent( public async global::System.Threading.Tasks.Task> GetAllEvaluationJobsAsync( string? status = default, int? limit = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetAllEvaluationJobsAsResponseAsync( + status: status, + limit: limit, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get all evaluation jobs + /// + /// + /// Filter evaluation jobs by status + /// + /// + /// Limit the number of results
+ /// Default Value: 10 + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.evals.list()
+ /// for job in response:
+ /// print(job.workflow_id) + ///
+ public async global::System.Threading.Tasks.Task>> GetAllEvaluationJobsAsResponseAsync( + string? status = default, + int? limit = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -83,26 +125,48 @@ partial void ProcessGetAllEvaluationJobsResponseContent( securityRequirements: s_GetAllEvaluationJobsSecurityRequirements, operationName: "GetAllEvaluationJobsAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/evaluation", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("status", status) - .AddOptionalParameter("limit", limit?.ToString()) - ; - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/evaluation", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("status", status) + .AddOptionalParameter("limit", limit?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -112,189 +176,374 @@ partial void ProcessGetAllEvaluationJobsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetAllEvaluationJobsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - status: status, - limit: limit); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetAllEvaluationJobsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + status: status, + limit: limit); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetAllEvaluationJobsResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Invalid request format - if ((int)__response.StatusCode == 400) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - global::Together.ErrorData? __value_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetAllEvaluationJobs", + methodName: "GetAllEvaluationJobsAsync", + pathTemplate: "\"/evaluation\"", + httpMethod: "GET", + 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 { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetAllEvaluationJobs", + methodName: "GetAllEvaluationJobsAsync", + pathTemplate: "\"/evaluation\"", + httpMethod: "GET", + 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; + } - __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } - throw new global::Together.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Error retrieving jobs from manager - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - global::Together.ErrorData? __value_500 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetAllEvaluationJobs", + methodName: "GetAllEvaluationJobsAsync", + pathTemplate: "\"/evaluation\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_500 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessGetAllEvaluationJobsResponseContent( + response: __response); + ProcessGetAllEvaluationJobsResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetAllEvaluationJobs", + methodName: "GetAllEvaluationJobsAsync", + pathTemplate: "\"/evaluation\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetAllEvaluationJobs", + methodName: "GetAllEvaluationJobsAsync", + pathTemplate: "\"/evaluation\"", + httpMethod: "GET", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Invalid request format + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Together.ErrorData? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Together.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Error retrieving jobs from manager + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Together.ErrorData? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessGetAllEvaluationJobsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse>( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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 = (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse>( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.EvaluationClient.GetEvaluationJobDetails.g.cs b/src/libs/Together/Generated/Together.EvaluationClient.GetEvaluationJobDetails.g.cs index 8c7a3747..014cc8d9 100644 --- a/src/libs/Together/Generated/Together.EvaluationClient.GetEvaluationJobDetails.g.cs +++ b/src/libs/Together/Generated/Together.EvaluationClient.GetEvaluationJobDetails.g.cs @@ -14,6 +14,7 @@ public partial class EvaluationClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,6 +47,7 @@ partial void ProcessGetEvaluationJobDetailsResponseContent( /// /// The ID of the evaluation job to retrieve /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -60,6 +62,39 @@ partial void ProcessGetEvaluationJobDetailsResponseContent( /// public async global::System.Threading.Tasks.Task GetEvaluationJobDetailsAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetEvaluationJobDetailsAsResponseAsync( + id: id, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get evaluation job details + /// + /// + /// The ID of the evaluation job to retrieve + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.evals.retrieve('eval_id')
+ /// print(response) + ///
+ public async global::System.Threading.Tasks.Task> GetEvaluationJobDetailsAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -74,22 +109,44 @@ partial void ProcessGetEvaluationJobDetailsResponseContent( securityRequirements: s_GetEvaluationJobDetailsSecurityRequirements, operationName: "GetEvaluationJobDetailsAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/evaluation/{id}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/evaluation/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -99,188 +156,373 @@ partial void ProcessGetEvaluationJobDetailsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetEvaluationJobDetailsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetEvaluationJobDetailsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id!); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetEvaluationJobDetailsResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Evaluation job not found - if ((int)__response.StatusCode == 404) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; - global::Together.ErrorData? __value_404 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetEvaluationJobDetails", + methodName: "GetEvaluationJobDetailsAsync", + pathTemplate: "$\"/evaluation/{id}\"", + httpMethod: "GET", + 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 { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetEvaluationJobDetails", + methodName: "GetEvaluationJobDetailsAsync", + pathTemplate: "$\"/evaluation/{id}\"", + httpMethod: "GET", + 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; + } - __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_404 = __ex; - } - throw new global::Together.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Failed to get evaluation job - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - global::Together.ErrorData? __value_500 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetEvaluationJobDetails", + methodName: "GetEvaluationJobDetailsAsync", + pathTemplate: "$\"/evaluation/{id}\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_500 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessGetEvaluationJobDetailsResponseContent( + response: __response); + ProcessGetEvaluationJobDetailsResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.EvaluationJob.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetEvaluationJobDetails", + methodName: "GetEvaluationJobDetailsAsync", + pathTemplate: "$\"/evaluation/{id}\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetEvaluationJobDetails", + methodName: "GetEvaluationJobDetailsAsync", + pathTemplate: "$\"/evaluation/{id}\"", + httpMethod: "GET", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Evaluation job not found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Together.ErrorData? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.EvaluationJob.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Together.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Failed to get evaluation job + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Together.ErrorData? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessGetEvaluationJobDetailsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.EvaluationJob.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.EvaluationJob.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.EvaluationClient.GetEvaluationJobStatusAndResults.g.cs b/src/libs/Together/Generated/Together.EvaluationClient.GetEvaluationJobStatusAndResults.g.cs index b0e93669..d2945d60 100644 --- a/src/libs/Together/Generated/Together.EvaluationClient.GetEvaluationJobStatusAndResults.g.cs +++ b/src/libs/Together/Generated/Together.EvaluationClient.GetEvaluationJobStatusAndResults.g.cs @@ -14,6 +14,7 @@ public partial class EvaluationClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,6 +47,7 @@ partial void ProcessGetEvaluationJobStatusAndResultsResponseContent( /// /// The ID of the evaluation job to get the status of /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -61,6 +63,40 @@ partial void ProcessGetEvaluationJobStatusAndResultsResponseContent( /// public async global::System.Threading.Tasks.Task GetEvaluationJobStatusAndResultsAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetEvaluationJobStatusAndResultsAsResponseAsync( + id: id, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get evaluation job status and results + /// + /// + /// The ID of the evaluation job to get the status of + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.evals.status('eval_id')
+ /// print(response.status)
+ /// print(response.results) + ///
+ public async global::System.Threading.Tasks.Task> GetEvaluationJobStatusAndResultsAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -75,22 +111,44 @@ partial void ProcessGetEvaluationJobStatusAndResultsResponseContent( securityRequirements: s_GetEvaluationJobStatusAndResultsSecurityRequirements, operationName: "GetEvaluationJobStatusAndResultsAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/evaluation/{id}/status", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/evaluation/{id}/status", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -100,188 +158,373 @@ partial void ProcessGetEvaluationJobStatusAndResultsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetEvaluationJobStatusAndResultsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetEvaluationJobStatusAndResultsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id!); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetEvaluationJobStatusAndResultsResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Evaluation job not found - if ((int)__response.StatusCode == 404) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; - global::Together.ErrorData? __value_404 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetEvaluationJobStatusAndResults", + methodName: "GetEvaluationJobStatusAndResultsAsync", + pathTemplate: "$\"/evaluation/{id}/status\"", + httpMethod: "GET", + 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 { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetEvaluationJobStatusAndResults", + methodName: "GetEvaluationJobStatusAndResultsAsync", + pathTemplate: "$\"/evaluation/{id}/status\"", + httpMethod: "GET", + 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; + } - __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_404 = __ex; - } - throw new global::Together.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Failed to get evaluation job - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - global::Together.ErrorData? __value_500 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetEvaluationJobStatusAndResults", + methodName: "GetEvaluationJobStatusAndResultsAsync", + pathTemplate: "$\"/evaluation/{id}/status\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_500 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessGetEvaluationJobStatusAndResultsResponseContent( + response: __response); + ProcessGetEvaluationJobStatusAndResultsResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.GetEvaluationJobStatusAndResultsResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetEvaluationJobStatusAndResults", + methodName: "GetEvaluationJobStatusAndResultsAsync", + pathTemplate: "$\"/evaluation/{id}/status\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetEvaluationJobStatusAndResults", + methodName: "GetEvaluationJobStatusAndResultsAsync", + pathTemplate: "$\"/evaluation/{id}/status\"", + httpMethod: "GET", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Evaluation job not found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Together.ErrorData? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.GetEvaluationJobStatusAndResultsResponse.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Together.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Failed to get evaluation job + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Together.ErrorData? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessGetEvaluationJobStatusAndResultsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.GetEvaluationJobStatusAndResultsResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.GetEvaluationJobStatusAndResultsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.EvaluationClient.GetModelList.g.cs b/src/libs/Together/Generated/Together.EvaluationClient.GetModelList.g.cs index b1defaed..f062d9d8 100644 --- a/src/libs/Together/Generated/Together.EvaluationClient.GetModelList.g.cs +++ b/src/libs/Together/Generated/Together.EvaluationClient.GetModelList.g.cs @@ -14,6 +14,7 @@ public partial class EvaluationClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,10 +48,35 @@ partial void ProcessGetModelListResponseContent( /// Filter models by source
/// Default Value: all /// + /// 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 GetModelListAsync( string? modelSource = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetModelListAsResponseAsync( + modelSource: modelSource, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get model list + /// + /// + /// Filter models by source
+ /// Default Value: all + /// + /// 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> GetModelListAsResponseAsync( + string? modelSource = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -65,25 +91,47 @@ partial void ProcessGetModelListResponseContent( securityRequirements: s_GetModelListSecurityRequirements, operationName: "GetModelListAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/evaluation/model-list", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("model_source", modelSource) - ; - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/evaluation/model-list", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("model_source", modelSource) + ; + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -93,188 +141,373 @@ partial void ProcessGetModelListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetModelListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - modelSource: modelSource); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetModelListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + modelSource: modelSource); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetModelListResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Invalid request format - if ((int)__response.StatusCode == 400) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - global::Together.ErrorData? __value_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetModelList", + methodName: "GetModelListAsync", + pathTemplate: "\"/evaluation/model-list\"", + httpMethod: "GET", + 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 { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetModelList", + methodName: "GetModelListAsync", + pathTemplate: "\"/evaluation/model-list\"", + httpMethod: "GET", + 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; + } - __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } - throw new global::Together.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Error retrieving model list - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - global::Together.ErrorData? __value_500 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetModelList", + methodName: "GetModelListAsync", + pathTemplate: "\"/evaluation/model-list\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_500 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessGetModelListResponseContent( + response: __response); + ProcessGetModelListResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.GetModelListResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetModelList", + methodName: "GetModelListAsync", + pathTemplate: "\"/evaluation/model-list\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetModelList", + methodName: "GetModelListAsync", + pathTemplate: "\"/evaluation/model-list\"", + httpMethod: "GET", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Invalid request format + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Together.ErrorData? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.GetModelListResponse.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Together.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Error retrieving model list + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Together.ErrorData? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessGetModelListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.GetModelListResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.GetModelListResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.EvaluationClient.g.cs b/src/libs/Together/Generated/Together.EvaluationClient.g.cs index 1e49deed..7dba363c 100644 --- a/src/libs/Together/Generated/Together.EvaluationClient.g.cs +++ b/src/libs/Together/Generated/Together.EvaluationClient.g.cs @@ -12,7 +12,7 @@ public sealed partial class EvaluationClient : global::Together.IEvaluationClien /// /// /// - public const string DefaultBaseUrl = "https://api.together.xyz/v1"; + public const string DefaultBaseUrl = "https://api.together.ai/v1"; private bool _disposeHttpClient = true; @@ -30,6 +30,12 @@ public sealed partial class EvaluationClient : global::Together.IEvaluationClien #if DEBUG = true; #endif + + /// + public global::Together.AutoSDKClientOptions Options { get; } + + + internal global::Together.AutoSDKServerConfiguration AutoSDKServerConfiguration { get; set; } = new global::Together.AutoSDKServerConfiguration(); /// /// /// @@ -49,13 +55,62 @@ public EvaluationClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the EvaluationClient with explicit options but no base URL override. + /// Skips passing baseUri so the default base URL from the OpenAPI spec applies. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public EvaluationClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, + bool disposeHttpClient = true) : this( + httpClient, + baseUri: null, + authorizations, + options, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the EvaluationClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public EvaluationClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Together.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; + AutoSDKServerConfiguration.ExplicitBaseUri = baseUri ?? httpClient?.BaseAddress; + Initialized(HttpClient); } diff --git a/src/libs/Together/Generated/Together.FilesClient.CreateFilesUpload.g.cs b/src/libs/Together/Generated/Together.FilesClient.CreateFilesUpload.g.cs index aa28674e..7ec5264f 100644 --- a/src/libs/Together/Generated/Together.FilesClient.CreateFilesUpload.g.cs +++ b/src/libs/Together/Generated/Together.FilesClient.CreateFilesUpload.g.cs @@ -14,6 +14,7 @@ public partial class FilesClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,6 +46,7 @@ partial void ProcessCreateFilesUploadResponseContent( /// Upload a file with specified purpose, file name, and file type. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -62,6 +64,42 @@ partial void ProcessCreateFilesUploadResponseContent( public async global::System.Threading.Tasks.Task CreateFilesUploadAsync( global::Together.CreateFilesUploadRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreateFilesUploadAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Upload a file
+ /// Upload a file with specified purpose, file name, and file type. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// current_dir = os.path.dirname(os.path.abspath(__file__))
+ /// file_path = os.path.join(current_dir, "data.jsonl")
+ /// file = client.files.upload(file=file_path)
+ /// print(file.id) + ///
+ public async global::System.Threading.Tasks.Task> CreateFilesUploadAsResponseAsync( + + global::Together.CreateFilesUploadRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -78,22 +116,44 @@ partial void ProcessCreateFilesUploadResponseContent( securityRequirements: s_CreateFilesUploadSecurityRequirements, operationName: "CreateFilesUploadAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/files/upload", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/files/upload", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -103,250 +163,1081 @@ partial void ProcessCreateFilesUploadResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - using var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent($"{request.Purpose.ToValueString()}"), - name: "\"purpose\""); - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent($"{request.FileName}"), - name: "\"file_name\""); - if (request.FileType != default) - { - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent($"{request.FileType?.ToValueString()}"), - name: "\"file_type\""); - } - var __contentFile = new global::System.Net.Http.ByteArrayContent(request.File ?? global::System.Array.Empty()); - __httpRequestContent.Add( - content: __contentFile, - name: "\"file\"", - fileName: request.FileName != null ? $"\"{request.FileName}\"" : string.Empty); - if (__contentFile.Headers.ContentDisposition != null) - { - __contentFile.Headers.ContentDisposition.FileNameStar = null; - } - __httpRequest.Content = __httpRequestContent; + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Purpose.ToValueString()), + name: "\"purpose\""); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateFilesUploadRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.FileName ?? string.Empty), + name: "\"file_name\""); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + if (request.FileType != default) + { - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateFilesUploadResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Internal Server Error - if ((int)__response.StatusCode == 500) + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.FileType).HasValue ? (request.FileType).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"file_type\""); + + } + var __contentFile = new global::System.Net.Http.ByteArrayContent(request.File ?? global::System.Array.Empty()); + __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; + } + + __httpRequest.Content = __httpRequestContent; + + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateFilesUploadRequest( + 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 { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - global::Together.ErrorData? __value_500 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createFilesUpload", + methodName: "CreateFilesUploadAsync", + pathTemplate: "\"/files/upload\"", + 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 { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createFilesUpload", + methodName: "CreateFilesUploadAsync", + pathTemplate: "\"/files/upload\"", + 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; + } - __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createFilesUpload", + methodName: "CreateFilesUploadAsync", + pathTemplate: "\"/files/upload\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_500 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Bad Request - if ((int)__response.StatusCode == 400) - { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - global::Together.ErrorData? __value_400 = null; - try - { - if (ReadResponseAsString) - { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); - } - else - { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); - } + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateFilesUploadResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createFilesUpload", + methodName: "CreateFilesUploadAsync", + pathTemplate: "\"/files/upload\"", + 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); } - catch (global::System.Exception __ex) + else { - __exception_400 = __ex; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createFilesUpload", + methodName: "CreateFilesUploadAsync", + pathTemplate: "\"/files/upload\"", + 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); } + // Internal Server Error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Together.ErrorData? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Bad Request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Together.ErrorData? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Together.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unauthorized + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Together.ErrorData? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Together.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseObject = __value_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessCreateFilesUploadResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.FileResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.FileResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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(); + } + } + /// + /// Upload a file
+ /// Upload a file with specified purpose, file name, and file type. + ///
+ /// + /// The purpose of the file
+ /// Example: fine-tune + /// + /// + /// The name of the file being uploaded
+ /// Example: dataset.csv + /// + /// + /// The type of the file
+ /// Default Value: jsonl
+ /// Example: jsonl + /// + /// + /// The content of the file being uploaded + /// + /// 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 CreateFilesUploadAsync( + global::Together.FilePurpose purpose, + string fileName, + byte[] file, + global::Together.FileType? fileType = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __request = new global::Together.CreateFilesUploadRequest + { + Purpose = purpose, + FileName = fileName, + FileType = fileType, + File = file, + }; + + return await CreateFilesUploadAsync( + request: __request, + requestOptions: requestOptions, + cancellationToken: cancellationToken).ConfigureAwait(false); + } + + /// + /// Upload a file
+ /// Upload a file with specified purpose, file name, and file type. + ///
+ /// + /// The purpose of the file
+ /// Example: fine-tune + /// + /// + /// The name of the file being uploaded
+ /// Example: dataset.csv + /// + /// + /// The type of the file
+ /// Default Value: jsonl
+ /// Example: jsonl + /// + /// + /// The content of the file being uploaded + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// current_dir = os.path.dirname(os.path.abspath(__file__))
+ /// file_path = os.path.join(current_dir, "data.jsonl")
+ /// file = client.files.upload(file=file_path)
+ /// print(file.id) + ///
+ public async global::System.Threading.Tasks.Task CreateFilesUploadAsync( + global::Together.FilePurpose purpose, + string fileName, + global::System.IO.Stream file, + global::Together.FileType? fileType = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + file = file ?? throw new global::System.ArgumentNullException(nameof(file)); + var request = new global::Together.CreateFilesUploadRequest + { + Purpose = purpose, + FileName = fileName, + FileType = fileType, + File = global::System.Array.Empty(), + }; + PrepareArguments( + client: HttpClient); + PrepareCreateFilesUploadArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Together.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_CreateFilesUploadSecurityRequirements, + operationName: "CreateFilesUploadAsync"); + + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/files/upload", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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 - throw new global::Together.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + __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.Purpose.ToValueString()), + name: "\"purpose\""); + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.FileName ?? string.Empty), + name: "\"file_name\""); + + if (request.FileType != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.FileType).HasValue ? (request.FileType).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"file_type\""); + + } + 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; + } + + __httpRequest.Content = __httpRequestContent; + + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateFilesUploadRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; } - // Unauthorized - if ((int)__response.StatusCode == 401) + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_401 = null; - global::System.Exception? __exception_401 = null; - global::Together.ErrorData? __value_401 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createFilesUpload", + methodName: "CreateFilesUploadAsync", + pathTemplate: "\"/files/upload\"", + 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 { - __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createFilesUpload", + methodName: "CreateFilesUploadAsync", + pathTemplate: "\"/files/upload\"", + 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; + } - __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createFilesUpload", + methodName: "CreateFilesUploadAsync", + pathTemplate: "\"/files/upload\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_401 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_401, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_401, - ResponseObject = __value_401, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessCreateFilesUploadResponseContent( + response: __response); + ProcessCreateFilesUploadResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.FileResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createFilesUpload", + methodName: "CreateFilesUploadAsync", + pathTemplate: "\"/files/upload\"", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createFilesUpload", + methodName: "CreateFilesUploadAsync", + pathTemplate: "\"/files/upload\"", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Internal Server Error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Together.ErrorData? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.FileResponse.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Bad Request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Together.ErrorData? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Together.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unauthorized + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Together.ErrorData? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Together.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseObject = __value_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessCreateFilesUploadResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Together.FileResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.FileResponse.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::Together.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), + }; + } + } - throw new global::Together.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(); + } } /// /// Upload a file
@@ -368,26 +1259,560 @@ partial void ProcessCreateFilesUploadResponseContent( /// /// The content of the file being uploaded /// + /// 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 CreateFilesUploadAsync( + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// current_dir = os.path.dirname(os.path.abspath(__file__))
+ /// file_path = os.path.join(current_dir, "data.jsonl")
+ /// file = client.files.upload(file=file_path)
+ /// print(file.id) + ///
+ public async global::System.Threading.Tasks.Task> CreateFilesUploadAsResponseAsync( global::Together.FilePurpose purpose, string fileName, - byte[] file, + global::System.IO.Stream file, global::Together.FileType? fileType = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { - var __request = new global::Together.CreateFilesUploadRequest + + file = file ?? throw new global::System.ArgumentNullException(nameof(file)); + var request = new global::Together.CreateFilesUploadRequest { Purpose = purpose, FileName = fileName, FileType = fileType, - File = file, + File = global::System.Array.Empty(), }; + PrepareArguments( + client: HttpClient); + PrepareCreateFilesUploadArguments( + httpClient: HttpClient, + request: request); - return await CreateFilesUploadAsync( - request: __request, - cancellationToken: cancellationToken).ConfigureAwait(false); + + var __authorizations = global::Together.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_CreateFilesUploadSecurityRequirements, + operationName: "CreateFilesUploadAsync"); + + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/files/upload", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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.Purpose.ToValueString()), + name: "\"purpose\""); + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.FileName ?? string.Empty), + name: "\"file_name\""); + + if (request.FileType != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.FileType).HasValue ? (request.FileType).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"file_type\""); + + } + 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; + } + + __httpRequest.Content = __httpRequestContent; + + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateFilesUploadRequest( + 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::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createFilesUpload", + methodName: "CreateFilesUploadAsync", + pathTemplate: "\"/files/upload\"", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createFilesUpload", + methodName: "CreateFilesUploadAsync", + pathTemplate: "\"/files/upload\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createFilesUpload", + methodName: "CreateFilesUploadAsync", + pathTemplate: "\"/files/upload\"", + 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::Together.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); + ProcessCreateFilesUploadResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createFilesUpload", + methodName: "CreateFilesUploadAsync", + pathTemplate: "\"/files/upload\"", + 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::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createFilesUpload", + methodName: "CreateFilesUploadAsync", + pathTemplate: "\"/files/upload\"", + 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); + } + // Internal Server Error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Together.ErrorData? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Bad Request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Together.ErrorData? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Together.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unauthorized + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Together.ErrorData? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Together.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseObject = __value_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessCreateFilesUploadResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.FileResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.FileResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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/Together/Generated/Together.FilesClient.DeleteFilesById.g.cs b/src/libs/Together/Generated/Together.FilesClient.DeleteFilesById.g.cs index 30a00bb9..fb9b3b8b 100644 --- a/src/libs/Together/Generated/Together.FilesClient.DeleteFilesById.g.cs +++ b/src/libs/Together/Generated/Together.FilesClient.DeleteFilesById.g.cs @@ -14,6 +14,7 @@ public partial class FilesClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,6 +48,7 @@ partial void ProcessDeleteFilesByIdResponseContent( /// /// The ID of the file to delete /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -61,6 +63,40 @@ partial void ProcessDeleteFilesByIdResponseContent( /// public async global::System.Threading.Tasks.Task DeleteFilesByIdAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await DeleteFilesByIdAsResponseAsync( + id: id, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Delete a file
+ /// Delete a previously uploaded data file. + ///
+ /// + /// The ID of the file to delete + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.files.delete(id="file-id")
+ /// print(response) + ///
+ public async global::System.Threading.Tasks.Task> DeleteFilesByIdAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -75,22 +111,44 @@ partial void ProcessDeleteFilesByIdResponseContent( securityRequirements: s_DeleteFilesByIdSecurityRequirements, operationName: "DeleteFilesByIdAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/files/{id}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Delete, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/files/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Delete, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -100,112 +158,297 @@ partial void ProcessDeleteFilesByIdResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteFilesByIdRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteFilesByIdRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id!); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteFilesByIdResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "deleteFilesById", + methodName: "DeleteFilesByIdAsync", + pathTemplate: "$\"/files/{id}\"", + httpMethod: "DELETE", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "deleteFilesById", + methodName: "DeleteFilesByIdAsync", + pathTemplate: "$\"/files/{id}\"", + httpMethod: "DELETE", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessDeleteFilesByIdResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "deleteFilesById", + methodName: "DeleteFilesByIdAsync", + pathTemplate: "$\"/files/{id}\"", + httpMethod: "DELETE", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::Together.FileDeleteResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Together.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), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return - await global::Together.FileDeleteResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteFilesByIdResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "deleteFilesById", + methodName: "DeleteFilesByIdAsync", + pathTemplate: "$\"/files/{id}\"", + httpMethod: "DELETE", + 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); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "deleteFilesById", + methodName: "DeleteFilesByIdAsync", + pathTemplate: "$\"/files/{id}\"", + httpMethod: "DELETE", + 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); + ProcessDeleteFilesByIdResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.FileDeleteResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.FileDeleteResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.FilesClient.GetFiles.g.cs b/src/libs/Together/Generated/Together.FilesClient.GetFiles.g.cs index 50b0bc19..b7867d7f 100644 --- a/src/libs/Together/Generated/Together.FilesClient.GetFiles.g.cs +++ b/src/libs/Together/Generated/Together.FilesClient.GetFiles.g.cs @@ -14,6 +14,7 @@ public partial class FilesClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -42,6 +43,7 @@ partial void ProcessGetFilesResponseContent( /// List all files
/// List the metadata for all uploaded data files. ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -56,6 +58,36 @@ partial void ProcessGetFilesResponseContent( /// print(file.id) /// public async global::System.Threading.Tasks.Task GetFilesAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetFilesAsResponseAsync( + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// List all files
+ /// List the metadata for all uploaded data files. + ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.files.list()
+ /// for file in response.data:
+ /// print(file.id) + ///
+ public async global::System.Threading.Tasks.Task> GetFilesAsResponseAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +101,44 @@ partial void ProcessGetFilesResponseContent( securityRequirements: s_GetFilesSecurityRequirements, operationName: "GetFilesAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/files", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/files", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -94,111 +148,296 @@ partial void ProcessGetFilesResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetFilesRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetFilesRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetFilesResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFiles", + methodName: "GetFilesAsync", + pathTemplate: "\"/files\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFiles", + methodName: "GetFilesAsync", + pathTemplate: "\"/files\"", + httpMethod: "GET", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessGetFilesResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFiles", + methodName: "GetFilesAsync", + pathTemplate: "\"/files\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::Together.FileList.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Together.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), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return - await global::Together.FileList.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetFilesResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFiles", + methodName: "GetFilesAsync", + pathTemplate: "\"/files\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFiles", + methodName: "GetFilesAsync", + pathTemplate: "\"/files\"", + httpMethod: "GET", + 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); + ProcessGetFilesResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.FileList.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.FileList.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.FilesClient.GetFilesById.g.cs b/src/libs/Together/Generated/Together.FilesClient.GetFilesById.g.cs index 3517eecb..0b71e6a0 100644 --- a/src/libs/Together/Generated/Together.FilesClient.GetFilesById.g.cs +++ b/src/libs/Together/Generated/Together.FilesClient.GetFilesById.g.cs @@ -14,6 +14,7 @@ public partial class FilesClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,6 +48,7 @@ partial void ProcessGetFilesByIdResponseContent( /// /// The ID of the file to retrieve /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -61,6 +63,40 @@ partial void ProcessGetFilesByIdResponseContent( /// public async global::System.Threading.Tasks.Task GetFilesByIdAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetFilesByIdAsResponseAsync( + id: id, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Retrieve file metadata
+ /// Retrieve the metadata for a single uploaded data file. + ///
+ /// + /// The ID of the file to retrieve + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// file = client.files.retrieve(id="file-id")
+ /// print(file) + ///
+ public async global::System.Threading.Tasks.Task> GetFilesByIdAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -75,22 +111,44 @@ partial void ProcessGetFilesByIdResponseContent( securityRequirements: s_GetFilesByIdSecurityRequirements, operationName: "GetFilesByIdAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/files/{id}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/files/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -100,112 +158,297 @@ partial void ProcessGetFilesByIdResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetFilesByIdRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetFilesByIdRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id!); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetFilesByIdResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFilesById", + methodName: "GetFilesByIdAsync", + pathTemplate: "$\"/files/{id}\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFilesById", + methodName: "GetFilesByIdAsync", + pathTemplate: "$\"/files/{id}\"", + httpMethod: "GET", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessGetFilesByIdResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFilesById", + methodName: "GetFilesByIdAsync", + pathTemplate: "$\"/files/{id}\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::Together.FileResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Together.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), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return - await global::Together.FileResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetFilesByIdResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFilesById", + methodName: "GetFilesByIdAsync", + pathTemplate: "$\"/files/{id}\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFilesById", + methodName: "GetFilesByIdAsync", + pathTemplate: "$\"/files/{id}\"", + httpMethod: "GET", + 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); + ProcessGetFilesByIdResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.FileResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.FileResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.FilesClient.GetFilesByIdContent.g.cs b/src/libs/Together/Generated/Together.FilesClient.GetFilesByIdContent.g.cs index dd181b9f..71eddd50 100644 --- a/src/libs/Together/Generated/Together.FilesClient.GetFilesByIdContent.g.cs +++ b/src/libs/Together/Generated/Together.FilesClient.GetFilesByIdContent.g.cs @@ -14,6 +14,7 @@ public partial class FilesClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,6 +48,7 @@ partial void ProcessGetFilesByIdContentResponseContent( /// /// The ID of the file to get the content of /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -62,6 +64,41 @@ partial void ProcessGetFilesByIdContentResponseContent( /// public async global::System.Threading.Tasks.Task GetFilesByIdContentAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetFilesByIdContentAsResponseAsync( + id: id, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get file contents
+ /// Get the contents of a single uploaded data file. + ///
+ /// + /// The ID of the file to get the content of + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// with client.files.with_streaming_response.content(id="file-id") as response:
+ /// for line in response.iter_lines():
+ /// print(line) + ///
+ public async global::System.Threading.Tasks.Task GetFilesByIdContentAsStreamAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -76,22 +113,44 @@ partial void ProcessGetFilesByIdContentResponseContent( securityRequirements: s_GetFilesByIdContentSecurityRequirements, operationName: "GetFilesByIdContentAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/files/{id}/content", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/files/{id}/content", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -101,140 +160,693 @@ partial void ProcessGetFilesByIdContentResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetFilesByIdContentRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetFilesByIdContentRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id!); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetFilesByIdContentResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Internal Server Error - if ((int)__response.StatusCode == 500) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - global::Together.ErrorData? __value_500 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFilesByIdContent", + methodName: "GetFilesByIdContentAsync", + pathTemplate: "$\"/files/{id}/content\"", + httpMethod: "GET", + 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 { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFilesByIdContent", + methodName: "GetFilesByIdContentAsync", + pathTemplate: "$\"/files/{id}/content\"", + httpMethod: "GET", + 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; + } - __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFilesByIdContent", + methodName: "GetFilesByIdContentAsync", + pathTemplate: "$\"/files/{id}/content\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_500 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) + try { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsByteArrayAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessGetFilesByIdContentResponseContent( + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetFilesByIdContentResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFilesByIdContent", + methodName: "GetFilesByIdContentAsync", + pathTemplate: "$\"/files/{id}/content\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFilesByIdContent", + methodName: "GetFilesByIdContentAsync", + pathTemplate: "$\"/files/{id}/content\"", + httpMethod: "GET", + 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); + } + // Internal Server Error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Together.ErrorData? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + try + { + __response.EnsureSuccessStatusCode(); + + var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::Together.ResponseStream(__response, __content); + } + 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::Together.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), + }; + } - return __content; } - catch (global::System.Exception __ex) + catch { - throw new global::Together.ApiException( - message: __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + __response.Dispose(); + throw; } } - else + finally { - try - { - __response.EnsureSuccessStatusCode(); - var __content = await __response.Content.ReadAsByteArrayAsync( -#if NET5_0_OR_GREATER - cancellationToken + __httpRequest?.Dispose(); + } + } + /// + /// Get file contents
+ /// Get the contents of a single uploaded data file. + ///
+ /// + /// The ID of the file to get the content of + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// with client.files.with_streaming_response.content(id="file-id") as response:
+ /// for line in response.iter_lines():
+ /// print(line) + ///
+ public async global::System.Threading.Tasks.Task> GetFilesByIdContentAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareGetFilesByIdContentArguments( + httpClient: HttpClient, + id: ref id); + + + var __authorizations = global::Together.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_GetFilesByIdContentSecurityRequirements, + operationName: "GetFilesByIdContentAsync"); + + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/files/{id}/content", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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 - ).ConfigureAwait(false); - return __content; + 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); } - catch (global::System.Exception __ex) + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") { - string? __content = null; + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetFilesByIdContentRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id!); + + 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::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFilesByIdContent", + methodName: "GetFilesByIdContentAsync", + pathTemplate: "$\"/files/{id}/content\"", + httpMethod: "GET", + 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 { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - catch (global::System.Exception) + catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFilesByIdContent", + methodName: "GetFilesByIdContentAsync", + pathTemplate: "$\"/files/{id}/content\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - throw new global::Together.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFilesByIdContent", + methodName: "GetFilesByIdContentAsync", + pathTemplate: "$\"/files/{id}/content\"", + httpMethod: "GET", + 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::Together.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); + ProcessGetFilesByIdContentResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFilesByIdContent", + methodName: "GetFilesByIdContentAsync", + pathTemplate: "$\"/files/{id}/content\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFilesByIdContent", + methodName: "GetFilesByIdContentAsync", + pathTemplate: "$\"/files/{id}/content\"", + httpMethod: "GET", + 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); + } + // Internal Server Error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Together.ErrorData? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsByteArrayAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessGetFilesByIdContentResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __content); + } + catch (global::System.Exception __ex) + { + throw new global::Together.ApiException( + message: __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + var __content = await __response.Content.ReadAsByteArrayAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __content); + } + 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::Together.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(); } } } diff --git a/src/libs/Together/Generated/Together.FilesClient.g.cs b/src/libs/Together/Generated/Together.FilesClient.g.cs index 21dd3c53..f33f9f9a 100644 --- a/src/libs/Together/Generated/Together.FilesClient.g.cs +++ b/src/libs/Together/Generated/Together.FilesClient.g.cs @@ -12,7 +12,7 @@ public sealed partial class FilesClient : global::Together.IFilesClient, global: /// /// /// - public const string DefaultBaseUrl = "https://api.together.xyz/v1"; + public const string DefaultBaseUrl = "https://api.together.ai/v1"; private bool _disposeHttpClient = true; @@ -30,6 +30,12 @@ public sealed partial class FilesClient : global::Together.IFilesClient, global: #if DEBUG = true; #endif + + /// + public global::Together.AutoSDKClientOptions Options { get; } + + + internal global::Together.AutoSDKServerConfiguration AutoSDKServerConfiguration { get; set; } = new global::Together.AutoSDKServerConfiguration(); /// /// /// @@ -49,13 +55,62 @@ public FilesClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the FilesClient with explicit options but no base URL override. + /// Skips passing baseUri so the default base URL from the OpenAPI spec applies. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public FilesClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, + bool disposeHttpClient = true) : this( + httpClient, + baseUri: null, + authorizations, + options, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the FilesClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public FilesClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Together.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; + AutoSDKServerConfiguration.ExplicitBaseUri = baseUri ?? httpClient?.BaseAddress; + Initialized(HttpClient); } diff --git a/src/libs/Together/Generated/Together.FineTuningClient.CreateFineTunes.g.cs b/src/libs/Together/Generated/Together.FineTuningClient.CreateFineTunes.g.cs index 6c0a2fb3..0a5bd8ec 100644 --- a/src/libs/Together/Generated/Together.FineTuningClient.CreateFineTunes.g.cs +++ b/src/libs/Together/Generated/Together.FineTuningClient.CreateFineTunes.g.cs @@ -16,6 +16,7 @@ public partial class FineTuningClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,6 +48,7 @@ partial void ProcessCreateFineTunesResponseContent( /// Create a fine-tuning job with the provided model and training data. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -65,6 +67,43 @@ partial void ProcessCreateFineTunesResponseContent( public async global::System.Threading.Tasks.Task CreateFineTunesAsync( global::Together.CreateFineTunesRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreateFineTunesAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Create job
+ /// Create a fine-tuning job with the provided model and training data. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.fine_tuning.create(
+ /// model="meta-llama/Meta-Llama-3.1-8B-Instruct-Reference",
+ /// training_file="file-id"
+ /// )
+ /// print(response) + ///
+ public async global::System.Threading.Tasks.Task> CreateFineTunesAsResponseAsync( + + global::Together.CreateFineTunesRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -81,22 +120,44 @@ partial void ProcessCreateFineTunesResponseContent( securityRequirements: s_CreateFineTunesSecurityRequirements, operationName: "CreateFineTunesAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/fine-tunes", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/fine-tunes", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -106,118 +167,303 @@ partial void ProcessCreateFineTunesResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateFineTunesRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateFineTunesRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateFineTunesResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createFineTunes", + methodName: "CreateFineTunesAsync", + pathTemplate: "\"/fine-tunes\"", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createFineTunes", + methodName: "CreateFineTunesAsync", + pathTemplate: "\"/fine-tunes\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessCreateFineTunesResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createFineTunes", + methodName: "CreateFineTunesAsync", + pathTemplate: "\"/fine-tunes\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::Together.FinetuneResponseTruncated.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Together.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), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return - await global::Together.FinetuneResponseTruncated.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateFineTunesResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createFineTunes", + methodName: "CreateFineTunesAsync", + pathTemplate: "\"/fine-tunes\"", + 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); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createFineTunes", + methodName: "CreateFineTunesAsync", + pathTemplate: "\"/fine-tunes\"", + 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); + ProcessCreateFineTunesResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.FinetuneResponseTruncated.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.FinetuneResponseTruncated.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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 job
@@ -233,6 +479,9 @@ partial void ProcessCreateFineTunesResponseContent( /// Whether to use sequence packing for training.
/// Default Value: true /// + /// + /// Maximum sequence length to use for training. If not specified, the maximum allowed for the model and training method will be used. + /// /// /// Name of the base model to run fine-tune job on /// @@ -252,6 +501,10 @@ partial void ProcessCreateFineTunesResponseContent( /// Number of training examples processed together (larger batches use more memory but may train faster). Defaults to "max". We use training optimizations like packing, so the effective batch size may be different than the value you set.
/// Default Value: max /// + /// + /// Number of steps to accumulate gradients before performing a weight update. Effectively increases the batch size without requiring more memory. For example, with batch_size=4 and gradient_accumulation_steps=8, the effective batch size is 32.
+ /// Default Value: 1 + /// /// /// Controls how quickly the model adapts to new information (too high may cause instability, too low may slow convergence)
/// Default Value: 0.00001 @@ -276,7 +529,7 @@ partial void ProcessCreateFineTunesResponseContent( /// Random seed for reproducible training. When set, the same seed produces the same run (e.g. data shuffle, init). If omitted or null, the server applies its default seed (e.g. 42). /// /// - /// Suffix that will be added to your fine-tuned model name + /// Suffix to add to your fine-tuned model name. Must be at most 64 characters long. /// /// /// Integration key for tracking experiments and model metrics on W&B platform @@ -285,7 +538,7 @@ partial void ProcessCreateFineTunesResponseContent( /// The base URL of a dedicated Weights & Biases instance. /// /// - /// The Weights & Biases project for your run. If not specified, will use `together` as the project name. + /// The Weights & Biases project for your run. If not specified, uses `together` as the project name. /// /// /// The Weights & Biases name for your run. @@ -297,12 +550,12 @@ partial void ProcessCreateFineTunesResponseContent( /// The training method to use. 'sft' for Supervised Fine-Tuning or 'dpo' for Direct Preference Optimization. /// /// - /// The training type to use. If not provided, the job will default to LoRA training type.
+ /// The training type to use. Defaults to LoRA if not provided.
/// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 /// /// /// - /// The checkpoint identifier to continue training from a previous fine-tuning job. Format is `{$JOB_ID}` or `{$OUTPUT_MODEL_NAME}` or `{$JOB_ID}:{$STEP}` or `{$OUTPUT_MODEL_NAME}:{$STEP}`. The step value is optional; without it, the final checkpoint will be used. + /// The checkpoint identifier to continue training from a previous fine-tuning job. Format is `{$JOB_ID}` or `{$OUTPUT_MODEL_NAME}` or `{$JOB_ID}:{$STEP}` or `{$OUTPUT_MODEL_NAME}:{$STEP}`. The step value is optional; without it, uses the final checkpoint. /// /// /// The Hugging Face Hub repo to start training from. Should be as close as possible to the base model (specified by the `model` argument) in terms of architecture and size. @@ -316,6 +569,7 @@ partial void ProcessCreateFineTunesResponseContent( /// /// The name of the Hugging Face repository to upload the fine-tuned model to. /// + /// 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 CreateFineTunesAsync( @@ -323,10 +577,12 @@ partial void ProcessCreateFineTunesResponseContent( string model, string? validationFile = default, bool? packing = default, + int? maxSeqLength = default, int? nEpochs = default, int? nCheckpoints = default, int? nEvals = default, global::Together.OneOf? batchSize = default, + int? gradientAccumulationSteps = default, float? learningRate = default, global::Together.LRScheduler? lrScheduler = default, float? warmupRatio = default, @@ -347,6 +603,7 @@ partial void ProcessCreateFineTunesResponseContent( string? hfModelRevision = default, string? hfApiToken = default, string? hfOutputRepoName = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.CreateFineTunesRequest @@ -354,11 +611,13 @@ partial void ProcessCreateFineTunesResponseContent( TrainingFile = trainingFile, ValidationFile = validationFile, Packing = packing, + MaxSeqLength = maxSeqLength, Model = model, NEpochs = nEpochs, NCheckpoints = nCheckpoints, NEvals = nEvals, BatchSize = batchSize, + GradientAccumulationSteps = gradientAccumulationSteps, LearningRate = learningRate, LrScheduler = lrScheduler, WarmupRatio = warmupRatio, @@ -383,6 +642,7 @@ partial void ProcessCreateFineTunesResponseContent( return await CreateFineTunesAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Together/Generated/Together.FineTuningClient.CreateFineTunesByIdCancel.g.cs b/src/libs/Together/Generated/Together.FineTuningClient.CreateFineTunesByIdCancel.g.cs index 65708eb9..b468669b 100644 --- a/src/libs/Together/Generated/Together.FineTuningClient.CreateFineTunesByIdCancel.g.cs +++ b/src/libs/Together/Generated/Together.FineTuningClient.CreateFineTunesByIdCancel.g.cs @@ -14,6 +14,7 @@ public partial class FineTuningClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,6 +48,7 @@ partial void ProcessCreateFineTunesByIdCancelResponseContent( /// /// Fine-tune ID to cancel. A string that starts with `ft-`. /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -61,6 +63,40 @@ partial void ProcessCreateFineTunesByIdCancelResponseContent( /// public async global::System.Threading.Tasks.Task CreateFineTunesByIdCancelAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreateFineTunesByIdCancelAsResponseAsync( + id: id, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Cancel job
+ /// Cancel a currently running fine-tuning job. Returns a FinetuneResponseTruncated object. + ///
+ /// + /// Fine-tune ID to cancel. A string that starts with `ft-`. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.fine_tuning.cancel(id="ft-id")
+ /// print(response) + ///
+ public async global::System.Threading.Tasks.Task> CreateFineTunesByIdCancelAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -75,22 +111,44 @@ partial void ProcessCreateFineTunesByIdCancelResponseContent( securityRequirements: s_CreateFineTunesByIdCancelSecurityRequirements, operationName: "CreateFineTunesByIdCancelAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/fine-tunes/{id}/cancel", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/fine-tunes/{id}/cancel", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -100,178 +158,363 @@ partial void ProcessCreateFineTunesByIdCancelResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateFineTunesByIdCancelRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateFineTunesByIdCancelRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id!); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateFineTunesByIdCancelResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 400) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createFineTunesByIdCancel", + methodName: "CreateFineTunesByIdCancelAsync", + pathTemplate: "$\"/fine-tunes/{id}/cancel\"", + 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 { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createFineTunesByIdCancel", + methodName: "CreateFineTunesByIdCancelAsync", + pathTemplate: "$\"/fine-tunes/{id}/cancel\"", + 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; + } - throw new global::Together.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // - if ((int)__response.StatusCode == 404) - { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; - try - { - if (ReadResponseAsString) - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else + + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createFineTunesByIdCancel", + methodName: "CreateFineTunesByIdCancelAsync", + pathTemplate: "$\"/fine-tunes/{id}/cancel\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_404 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessCreateFineTunesByIdCancelResponseContent( + response: __response); + ProcessCreateFineTunesByIdCancelResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.FinetuneResponseTruncated.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createFineTunesByIdCancel", + methodName: "CreateFineTunesByIdCancelAsync", + pathTemplate: "$\"/fine-tunes/{id}/cancel\"", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createFineTunesByIdCancel", + methodName: "CreateFineTunesByIdCancelAsync", + pathTemplate: "$\"/fine-tunes/{id}/cancel\"", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } - return - await global::Together.FinetuneResponseTruncated.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + throw new global::Together.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Together.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessCreateFineTunesByIdCancelResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.FinetuneResponseTruncated.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.FinetuneResponseTruncated.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.FineTuningClient.CreateFineTunesEstimatePrice.g.cs b/src/libs/Together/Generated/Together.FineTuningClient.CreateFineTunesEstimatePrice.g.cs index 8c862ec4..2b1f231c 100644 --- a/src/libs/Together/Generated/Together.FineTuningClient.CreateFineTunesEstimatePrice.g.cs +++ b/src/libs/Together/Generated/Together.FineTuningClient.CreateFineTunesEstimatePrice.g.cs @@ -14,6 +14,7 @@ public partial class FineTuningClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,36 @@ partial void ProcessCreateFineTunesEstimatePriceResponseContent( /// Estimate the price of a fine-tuning job. ///
/// + /// 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 CreateFineTunesEstimatePriceAsync( global::Together.CreateFineTunesEstimatePriceRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreateFineTunesEstimatePriceAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Estimate price
+ /// Estimate the price of a fine-tuning job. + ///
+ /// + /// 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> CreateFineTunesEstimatePriceAsResponseAsync( + + global::Together.CreateFineTunesEstimatePriceRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +92,44 @@ partial void ProcessCreateFineTunesEstimatePriceResponseContent( securityRequirements: s_CreateFineTunesEstimatePriceSecurityRequirements, operationName: "CreateFineTunesEstimatePriceAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/fine-tunes/estimate-price", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/fine-tunes/estimate-price", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -91,156 +139,341 @@ partial void ProcessCreateFineTunesEstimatePriceResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateFineTunesEstimatePriceRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateFineTunesEstimatePriceRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateFineTunesEstimatePriceResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Internal Server Error - if ((int)__response.StatusCode == 500) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - global::Together.ErrorData? __value_500 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createFineTunesEstimatePrice", + methodName: "CreateFineTunesEstimatePriceAsync", + pathTemplate: "\"/fine-tunes/estimate-price\"", + 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 { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createFineTunesEstimatePrice", + methodName: "CreateFineTunesEstimatePriceAsync", + pathTemplate: "\"/fine-tunes/estimate-price\"", + 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; + } - __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createFineTunesEstimatePrice", + methodName: "CreateFineTunesEstimatePriceAsync", + pathTemplate: "\"/fine-tunes/estimate-price\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_500 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessCreateFineTunesEstimatePriceResponseContent( + response: __response); + ProcessCreateFineTunesEstimatePriceResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.CreateFineTunesEstimatePriceResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createFineTunesEstimatePrice", + methodName: "CreateFineTunesEstimatePriceAsync", + pathTemplate: "\"/fine-tunes/estimate-price\"", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createFineTunesEstimatePrice", + methodName: "CreateFineTunesEstimatePriceAsync", + pathTemplate: "\"/fine-tunes/estimate-price\"", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Internal Server Error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Together.ErrorData? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.CreateFineTunesEstimatePriceResponse.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessCreateFineTunesEstimatePriceResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.CreateFineTunesEstimatePriceResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.CreateFineTunesEstimatePriceResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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(); + } } /// /// Estimate price
@@ -267,12 +500,13 @@ partial void ProcessCreateFineTunesEstimatePriceResponseContent( /// The training method to use. 'sft' for Supervised Fine-Tuning or 'dpo' for Direct Preference Optimization. /// /// - /// The training type to use. If not provided, the job will default to LoRA training type.
+ /// The training type to use. Defaults to LoRA if not provided.
/// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 /// /// - /// The checkpoint identifier to continue training from a previous fine-tuning job. Format is `{$JOB_ID}` or `{$OUTPUT_MODEL_NAME}` or `{$JOB_ID}:{$STEP}` or `{$OUTPUT_MODEL_NAME}:{$STEP}`. The step value is optional; without it, the final checkpoint will be used. + /// The checkpoint identifier to continue training from a previous fine-tuning job. Format is `{$JOB_ID}` or `{$OUTPUT_MODEL_NAME}` or `{$JOB_ID}:{$STEP}` or `{$OUTPUT_MODEL_NAME}:{$STEP}`. The step value is optional; without it, uses the final checkpoint. /// + /// 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 CreateFineTunesEstimatePriceAsync( @@ -284,6 +518,7 @@ partial void ProcessCreateFineTunesEstimatePriceResponseContent( global::Together.OneOf? trainingMethod = default, global::Together.OneOf? trainingType = default, string? fromCheckpoint = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.CreateFineTunesEstimatePriceRequest @@ -300,6 +535,7 @@ partial void ProcessCreateFineTunesEstimatePriceResponseContent( return await CreateFineTunesEstimatePriceAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Together/Generated/Together.FineTuningClient.DeleteFineTunesById.g.cs b/src/libs/Together/Generated/Together.FineTuningClient.DeleteFineTunesById.g.cs index 441d7b9d..0c742645 100644 --- a/src/libs/Together/Generated/Together.FineTuningClient.DeleteFineTunesById.g.cs +++ b/src/libs/Together/Generated/Together.FineTuningClient.DeleteFineTunesById.g.cs @@ -14,6 +14,7 @@ public partial class FineTuningClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -53,6 +54,7 @@ partial void ProcessDeleteFineTunesByIdResponseContent( /// Deprecated and unused parameter.
/// Default Value: false /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -68,6 +70,46 @@ partial void ProcessDeleteFineTunesByIdResponseContent( public async global::System.Threading.Tasks.Task DeleteFineTunesByIdAsync( string id, bool? force = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await DeleteFineTunesByIdAsResponseAsync( + id: id, + force: force, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Delete a fine-tune job
+ /// Delete a fine-tuning job. + ///
+ /// + /// The ID of the fine-tune job to delete + /// + /// + /// Deprecated and unused parameter.
+ /// Default Value: false + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.fine_tuning.delete(id="ft-id")
+ /// print(response) + ///
+ public async global::System.Threading.Tasks.Task> DeleteFineTunesByIdAsResponseAsync( + string id, + bool? force = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -83,25 +125,47 @@ partial void ProcessDeleteFineTunesByIdResponseContent( securityRequirements: s_DeleteFineTunesByIdSecurityRequirements, operationName: "DeleteFineTunesByIdAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/fine-tunes/{id}", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("force", force?.ToString().ToLowerInvariant()) - ; - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Delete, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/fine-tunes/{id}", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("force", force?.ToString().ToLowerInvariant()) + ; + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Delete, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -111,189 +175,374 @@ partial void ProcessDeleteFineTunesByIdResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteFineTunesByIdRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - force: force); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteFineTunesByIdRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id!, + force: force); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteFineTunesByIdResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Fine-tune job not found - if ((int)__response.StatusCode == 404) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; - global::Together.ErrorData? __value_404 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "deleteFineTunesById", + methodName: "DeleteFineTunesByIdAsync", + pathTemplate: "$\"/fine-tunes/{id}\"", + httpMethod: "DELETE", + 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 { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "deleteFineTunesById", + methodName: "DeleteFineTunesByIdAsync", + pathTemplate: "$\"/fine-tunes/{id}\"", + httpMethod: "DELETE", + 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; + } - __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_404 = __ex; - } - throw new global::Together.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Internal server error - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - global::Together.ErrorData? __value_500 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "deleteFineTunesById", + methodName: "DeleteFineTunesByIdAsync", + pathTemplate: "$\"/fine-tunes/{id}\"", + httpMethod: "DELETE", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_500 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessDeleteFineTunesByIdResponseContent( + response: __response); + ProcessDeleteFineTunesByIdResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.FinetuneDeleteResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "deleteFineTunesById", + methodName: "DeleteFineTunesByIdAsync", + pathTemplate: "$\"/fine-tunes/{id}\"", + httpMethod: "DELETE", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "deleteFineTunesById", + methodName: "DeleteFineTunesByIdAsync", + pathTemplate: "$\"/fine-tunes/{id}\"", + httpMethod: "DELETE", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Fine-tune job not found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Together.ErrorData? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.FinetuneDeleteResponse.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Together.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal server error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Together.ErrorData? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessDeleteFineTunesByIdResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.FinetuneDeleteResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.FinetuneDeleteResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.FineTuningClient.GetFineTunes.g.cs b/src/libs/Together/Generated/Together.FineTuningClient.GetFineTunes.g.cs index fe78788f..3a5871f2 100644 --- a/src/libs/Together/Generated/Together.FineTuningClient.GetFineTunes.g.cs +++ b/src/libs/Together/Generated/Together.FineTuningClient.GetFineTunes.g.cs @@ -14,6 +14,7 @@ public partial class FineTuningClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -42,6 +43,7 @@ partial void ProcessGetFineTunesResponseContent( /// List all jobs
/// List the metadata for all fine-tuning jobs. Returns a list of FinetuneResponseTruncated objects. ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -56,6 +58,36 @@ partial void ProcessGetFineTunesResponseContent( /// print(f"ID: {fine_tune.id}, Status: {fine_tune.status}") /// public async global::System.Threading.Tasks.Task GetFineTunesAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetFineTunesAsResponseAsync( + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// List all jobs
+ /// List the metadata for all fine-tuning jobs. Returns a list of FinetuneResponseTruncated objects. + ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.fine_tuning.list()
+ /// for fine_tune in response.data:
+ /// print(f"ID: {fine_tune.id}, Status: {fine_tune.status}") + ///
+ public async global::System.Threading.Tasks.Task> GetFineTunesAsResponseAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +101,44 @@ partial void ProcessGetFineTunesResponseContent( securityRequirements: s_GetFineTunesSecurityRequirements, operationName: "GetFineTunesAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/fine-tunes", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/fine-tunes", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -94,111 +148,296 @@ partial void ProcessGetFineTunesResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetFineTunesRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetFineTunesRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetFineTunesResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunes", + methodName: "GetFineTunesAsync", + pathTemplate: "\"/fine-tunes\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunes", + methodName: "GetFineTunesAsync", + pathTemplate: "\"/fine-tunes\"", + httpMethod: "GET", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessGetFineTunesResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunes", + methodName: "GetFineTunesAsync", + pathTemplate: "\"/fine-tunes\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::Together.FinetuneTruncatedList.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Together.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), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return - await global::Together.FinetuneTruncatedList.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetFineTunesResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunes", + methodName: "GetFineTunesAsync", + pathTemplate: "\"/fine-tunes\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunes", + methodName: "GetFineTunesAsync", + pathTemplate: "\"/fine-tunes\"", + httpMethod: "GET", + 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); + ProcessGetFineTunesResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.FinetuneTruncatedList.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.FinetuneTruncatedList.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.FineTuningClient.GetFineTunesById.g.cs b/src/libs/Together/Generated/Together.FineTuningClient.GetFineTunesById.g.cs index 57f6aa6a..b7757bac 100644 --- a/src/libs/Together/Generated/Together.FineTuningClient.GetFineTunesById.g.cs +++ b/src/libs/Together/Generated/Together.FineTuningClient.GetFineTunesById.g.cs @@ -14,6 +14,7 @@ public partial class FineTuningClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,6 +48,7 @@ partial void ProcessGetFineTunesByIdResponseContent( /// /// The ID of the job to retrieve /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -61,6 +63,40 @@ partial void ProcessGetFineTunesByIdResponseContent( /// public async global::System.Threading.Tasks.Task GetFineTunesByIdAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetFineTunesByIdAsResponseAsync( + id: id, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// List job
+ /// List the metadata for a single fine-tuning job. + ///
+ /// + /// The ID of the job to retrieve + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// fine_tune = client.fine_tuning.retrieve(id="ft-id")
+ /// print(fine_tune) + ///
+ public async global::System.Threading.Tasks.Task> GetFineTunesByIdAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -75,22 +111,44 @@ partial void ProcessGetFineTunesByIdResponseContent( securityRequirements: s_GetFineTunesByIdSecurityRequirements, operationName: "GetFineTunesByIdAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/fine-tunes/{id}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/fine-tunes/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -100,112 +158,297 @@ partial void ProcessGetFineTunesByIdResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetFineTunesByIdRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetFineTunesByIdRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id!); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetFineTunesByIdResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunesById", + methodName: "GetFineTunesByIdAsync", + pathTemplate: "$\"/fine-tunes/{id}\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunesById", + methodName: "GetFineTunesByIdAsync", + pathTemplate: "$\"/fine-tunes/{id}\"", + httpMethod: "GET", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessGetFineTunesByIdResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunesById", + methodName: "GetFineTunesByIdAsync", + pathTemplate: "$\"/fine-tunes/{id}\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::Together.FinetuneResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Together.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), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return - await global::Together.FinetuneResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetFineTunesByIdResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunesById", + methodName: "GetFineTunesByIdAsync", + pathTemplate: "$\"/fine-tunes/{id}\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunesById", + methodName: "GetFineTunesByIdAsync", + pathTemplate: "$\"/fine-tunes/{id}\"", + httpMethod: "GET", + 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); + ProcessGetFineTunesByIdResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.FinetuneResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.FinetuneResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.FineTuningClient.GetFineTunesByIdCheckpoints.g.cs b/src/libs/Together/Generated/Together.FineTuningClient.GetFineTunesByIdCheckpoints.g.cs index 4e179b48..19fab9a4 100644 --- a/src/libs/Together/Generated/Together.FineTuningClient.GetFineTunesByIdCheckpoints.g.cs +++ b/src/libs/Together/Generated/Together.FineTuningClient.GetFineTunesByIdCheckpoints.g.cs @@ -14,6 +14,7 @@ public partial class FineTuningClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,6 +48,7 @@ partial void ProcessGetFineTunesByIdCheckpointsResponseContent( /// /// The ID of the fine-tune job to list checkpoints for /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -61,6 +63,40 @@ partial void ProcessGetFineTunesByIdCheckpointsResponseContent( /// public async global::System.Threading.Tasks.Task GetFineTunesByIdCheckpointsAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetFineTunesByIdCheckpointsAsResponseAsync( + id: id, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// List checkpoints
+ /// List the checkpoints for a single fine-tuning job. + ///
+ /// + /// The ID of the fine-tune job to list checkpoints for + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// checkpoints = client.fine_tuning.list_checkpoints(id="ft-id")
+ /// print(checkpoints) + ///
+ public async global::System.Threading.Tasks.Task> GetFineTunesByIdCheckpointsAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -75,22 +111,44 @@ partial void ProcessGetFineTunesByIdCheckpointsResponseContent( securityRequirements: s_GetFineTunesByIdCheckpointsSecurityRequirements, operationName: "GetFineTunesByIdCheckpointsAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/fine-tunes/{id}/checkpoints", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/fine-tunes/{id}/checkpoints", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -100,112 +158,297 @@ partial void ProcessGetFineTunesByIdCheckpointsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetFineTunesByIdCheckpointsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetFineTunesByIdCheckpointsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id!); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetFineTunesByIdCheckpointsResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunesByIdCheckpoints", + methodName: "GetFineTunesByIdCheckpointsAsync", + pathTemplate: "$\"/fine-tunes/{id}/checkpoints\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunesByIdCheckpoints", + methodName: "GetFineTunesByIdCheckpointsAsync", + pathTemplate: "$\"/fine-tunes/{id}/checkpoints\"", + httpMethod: "GET", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessGetFineTunesByIdCheckpointsResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunesByIdCheckpoints", + methodName: "GetFineTunesByIdCheckpointsAsync", + pathTemplate: "$\"/fine-tunes/{id}/checkpoints\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::Together.FinetuneListCheckpoints.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Together.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), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return - await global::Together.FinetuneListCheckpoints.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetFineTunesByIdCheckpointsResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunesByIdCheckpoints", + methodName: "GetFineTunesByIdCheckpointsAsync", + pathTemplate: "$\"/fine-tunes/{id}/checkpoints\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunesByIdCheckpoints", + methodName: "GetFineTunesByIdCheckpointsAsync", + pathTemplate: "$\"/fine-tunes/{id}/checkpoints\"", + httpMethod: "GET", + 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); + ProcessGetFineTunesByIdCheckpointsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.FinetuneListCheckpoints.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.FinetuneListCheckpoints.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.FineTuningClient.GetFineTunesByIdEvents.g.cs b/src/libs/Together/Generated/Together.FineTuningClient.GetFineTunesByIdEvents.g.cs index 5b127d59..d59554f2 100644 --- a/src/libs/Together/Generated/Together.FineTuningClient.GetFineTunesByIdEvents.g.cs +++ b/src/libs/Together/Generated/Together.FineTuningClient.GetFineTunesByIdEvents.g.cs @@ -14,6 +14,7 @@ public partial class FineTuningClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,6 +48,7 @@ partial void ProcessGetFineTunesByIdEventsResponseContent( /// /// The ID of the fine-tune job to list events for /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -62,6 +64,41 @@ partial void ProcessGetFineTunesByIdEventsResponseContent( /// public async global::System.Threading.Tasks.Task GetFineTunesByIdEventsAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetFineTunesByIdEventsAsResponseAsync( + id: id, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// List job events
+ /// List the events for a single fine-tuning job. + ///
+ /// + /// The ID of the fine-tune job to list events for + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.fine_tuning.list_events(id="ft-id")
+ /// for event in response.data:
+ /// print(event) + ///
+ public async global::System.Threading.Tasks.Task> GetFineTunesByIdEventsAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -76,22 +113,44 @@ partial void ProcessGetFineTunesByIdEventsResponseContent( securityRequirements: s_GetFineTunesByIdEventsSecurityRequirements, operationName: "GetFineTunesByIdEventsAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/fine-tunes/{id}/events", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/fine-tunes/{id}/events", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -101,112 +160,297 @@ partial void ProcessGetFineTunesByIdEventsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetFineTunesByIdEventsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetFineTunesByIdEventsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id!); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetFineTunesByIdEventsResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunesByIdEvents", + methodName: "GetFineTunesByIdEventsAsync", + pathTemplate: "$\"/fine-tunes/{id}/events\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunesByIdEvents", + methodName: "GetFineTunesByIdEventsAsync", + pathTemplate: "$\"/fine-tunes/{id}/events\"", + httpMethod: "GET", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessGetFineTunesByIdEventsResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunesByIdEvents", + methodName: "GetFineTunesByIdEventsAsync", + pathTemplate: "$\"/fine-tunes/{id}/events\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::Together.FinetuneListEvents.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Together.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), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return - await global::Together.FinetuneListEvents.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetFineTunesByIdEventsResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunesByIdEvents", + methodName: "GetFineTunesByIdEventsAsync", + pathTemplate: "$\"/fine-tunes/{id}/events\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunesByIdEvents", + methodName: "GetFineTunesByIdEventsAsync", + pathTemplate: "$\"/fine-tunes/{id}/events\"", + httpMethod: "GET", + 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); + ProcessGetFineTunesByIdEventsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.FinetuneListEvents.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.FinetuneListEvents.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.FineTuningClient.GetFineTunesByIdMetrics.g.cs b/src/libs/Together/Generated/Together.FineTuningClient.GetFineTunesByIdMetrics.g.cs new file mode 100644 index 00000000..dd237808 --- /dev/null +++ b/src/libs/Together/Generated/Together.FineTuningClient.GetFineTunesByIdMetrics.g.cs @@ -0,0 +1,593 @@ + +#nullable enable + +namespace Together +{ + public partial class FineTuningClient + { + + + private static readonly global::Together.EndPointSecurityRequirement s_GetFineTunesByIdMetricsSecurityRequirement0 = + new global::Together.EndPointSecurityRequirement + { + Authorizations = new global::Together.EndPointAuthorizationRequirement[] + { new global::Together.EndPointAuthorizationRequirement + { + Type = "Http", + SchemeId = "BearerAuth", + Location = "Header", + Name = "Bearer", + FriendlyName = "Bearer", + }, + }, + }; + private static readonly global::Together.EndPointSecurityRequirement[] s_GetFineTunesByIdMetricsSecurityRequirements = + new global::Together.EndPointSecurityRequirement[] + { s_GetFineTunesByIdMetricsSecurityRequirement0, + }; + partial void PrepareGetFineTunesByIdMetricsArguments( + global::System.Net.Http.HttpClient httpClient, + ref string id, + ref long? globalStepFrom, + ref long? globalStepTo, + ref global::System.DateTime? loggedAtFrom, + ref global::System.DateTime? loggedAtTo, + ref long? resolution); + partial void PrepareGetFineTunesByIdMetricsRequest( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpRequestMessage httpRequestMessage, + string id, + long? globalStepFrom, + long? globalStepTo, + global::System.DateTime? loggedAtFrom, + global::System.DateTime? loggedAtTo, + long? resolution); + partial void ProcessGetFineTunesByIdMetricsResponse( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage); + + partial void ProcessGetFineTunesByIdMetricsResponseContent( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage, + ref string content); + + /// + /// Get metrics
+ /// Retrieves recorded training metrics for a fine-tuning job in chronological order. All query parameters are optional: omit them to retrieve all metrics. + ///
+ /// + /// Fine-tune job ID. A string that starts with `ft-`. + /// + /// + /// + /// + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// curl -X GET "https://api.together.ai/v1/fine-tunes/ft-id/metrics?global_step_from=0&global_step_to=500" \
+ /// -H "Authorization: Bearer $TOGETHER_API_KEY" + ///
+ public async global::System.Threading.Tasks.Task GetFineTunesByIdMetricsAsync( + string id, + long? globalStepFrom = default, + long? globalStepTo = default, + global::System.DateTime? loggedAtFrom = default, + global::System.DateTime? loggedAtTo = default, + long? resolution = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetFineTunesByIdMetricsAsResponseAsync( + id: id, + globalStepFrom: globalStepFrom, + globalStepTo: globalStepTo, + loggedAtFrom: loggedAtFrom, + loggedAtTo: loggedAtTo, + resolution: resolution, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get metrics
+ /// Retrieves recorded training metrics for a fine-tuning job in chronological order. All query parameters are optional: omit them to retrieve all metrics. + ///
+ /// + /// Fine-tune job ID. A string that starts with `ft-`. + /// + /// + /// + /// + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// curl -X GET "https://api.together.ai/v1/fine-tunes/ft-id/metrics?global_step_from=0&global_step_to=500" \
+ /// -H "Authorization: Bearer $TOGETHER_API_KEY" + ///
+ public async global::System.Threading.Tasks.Task> GetFineTunesByIdMetricsAsResponseAsync( + string id, + long? globalStepFrom = default, + long? globalStepTo = default, + global::System.DateTime? loggedAtFrom = default, + global::System.DateTime? loggedAtTo = default, + long? resolution = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareGetFineTunesByIdMetricsArguments( + httpClient: HttpClient, + id: ref id, + globalStepFrom: ref globalStepFrom, + globalStepTo: ref globalStepTo, + loggedAtFrom: ref loggedAtFrom, + loggedAtTo: ref loggedAtTo, + resolution: ref resolution); + + + var __authorizations = global::Together.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_GetFineTunesByIdMetricsSecurityRequirements, + operationName: "GetFineTunesByIdMetricsAsync"); + + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/fine-tunes/{id}/metrics", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("global_step_from", globalStepFrom?.ToString()) + .AddOptionalParameter("global_step_to", globalStepTo?.ToString()) + .AddOptionalParameter("logged_at_from", loggedAtFrom?.ToString("yyyy-MM-ddTHH:mm:ssZ")) + .AddOptionalParameter("logged_at_to", loggedAtTo?.ToString("yyyy-MM-ddTHH:mm:ssZ")) + .AddOptionalParameter("resolution", resolution?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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); + } + } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetFineTunesByIdMetricsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id!, + globalStepFrom: globalStepFrom, + globalStepTo: globalStepTo, + loggedAtFrom: loggedAtFrom, + loggedAtTo: loggedAtTo, + resolution: resolution); + + 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::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunesByIdMetrics", + methodName: "GetFineTunesByIdMetricsAsync", + pathTemplate: "$\"/fine-tunes/{id}/metrics\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunesByIdMetrics", + methodName: "GetFineTunesByIdMetricsAsync", + pathTemplate: "$\"/fine-tunes/{id}/metrics\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunesByIdMetrics", + methodName: "GetFineTunesByIdMetricsAsync", + pathTemplate: "$\"/fine-tunes/{id}/metrics\"", + httpMethod: "GET", + 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::Together.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); + ProcessGetFineTunesByIdMetricsResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunesByIdMetrics", + methodName: "GetFineTunesByIdMetricsAsync", + pathTemplate: "$\"/fine-tunes/{id}/metrics\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunesByIdMetrics", + methodName: "GetFineTunesByIdMetricsAsync", + pathTemplate: "$\"/fine-tunes/{id}/metrics\"", + httpMethod: "GET", + 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 ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Together.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Together.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessGetFineTunesByIdMetricsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.GetFineTunesMetricsResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.GetFineTunesMetricsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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/Together/Generated/Together.FineTuningClient.GetFineTunesModelsLimits.g.cs b/src/libs/Together/Generated/Together.FineTuningClient.GetFineTunesModelsLimits.g.cs index a40e1bec..1c404913 100644 --- a/src/libs/Together/Generated/Together.FineTuningClient.GetFineTunesModelsLimits.g.cs +++ b/src/libs/Together/Generated/Together.FineTuningClient.GetFineTunesModelsLimits.g.cs @@ -14,6 +14,7 @@ public partial class FineTuningClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,14 +48,43 @@ partial void ProcessGetFineTunesModelsLimitsResponseContent( /// /// The model name to get limits for. /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// - /// curl "https://api.together.xyz/v1/fine-tunes/models/limits?model_name=meta-llama/Meta-Llama-3.1-8B-Instruct-Reference" \
+ /// curl "https://api.together.ai/v1/fine-tunes/models/limits?model_name=meta-llama/Meta-Llama-3.1-8B-Instruct-Reference" \
/// -H "Authorization: Bearer $TOGETHER_API_KEY" ///
public async global::System.Threading.Tasks.Task GetFineTunesModelsLimitsAsync( string modelName, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetFineTunesModelsLimitsAsResponseAsync( + modelName: modelName, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get model limits
+ /// Get model limits for a specific fine-tuning model. + ///
+ /// + /// The model name to get limits for. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// curl "https://api.together.ai/v1/fine-tunes/models/limits?model_name=meta-llama/Meta-Llama-3.1-8B-Instruct-Reference" \
+ /// -H "Authorization: Bearer $TOGETHER_API_KEY" + ///
+ public async global::System.Threading.Tasks.Task> GetFineTunesModelsLimitsAsResponseAsync( + string modelName, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,25 +99,47 @@ partial void ProcessGetFineTunesModelsLimitsResponseContent( securityRequirements: s_GetFineTunesModelsLimitsSecurityRequirements, operationName: "GetFineTunesModelsLimitsAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/fine-tunes/models/limits", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddRequiredParameter("model_name", modelName) - ; - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/fine-tunes/models/limits", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddRequiredParameter("model_name", modelName) + ; + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -97,150 +149,335 @@ partial void ProcessGetFineTunesModelsLimitsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetFineTunesModelsLimitsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - modelName: modelName); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetFineTunesModelsLimitsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + modelName: modelName!); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetFineTunesModelsLimitsResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Model not found or not supported for fine-tuning. - if ((int)__response.StatusCode == 404) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; - global::Together.GetFineTunesModelsLimitsResponse? __value_404 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunesModelsLimits", + methodName: "GetFineTunesModelsLimitsAsync", + pathTemplate: "\"/fine-tunes/models/limits\"", + httpMethod: "GET", + 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 { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = global::Together.GetFineTunesModelsLimitsResponse.FromJson(__content_404, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunesModelsLimits", + methodName: "GetFineTunesModelsLimitsAsync", + pathTemplate: "\"/fine-tunes/models/limits\"", + httpMethod: "GET", + 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; + } - __value_404 = global::Together.GetFineTunesModelsLimitsResponse.FromJson(__content_404, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunesModelsLimits", + methodName: "GetFineTunesModelsLimitsAsync", + pathTemplate: "\"/fine-tunes/models/limits\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_404 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessGetFineTunesModelsLimitsResponseContent( + response: __response); + ProcessGetFineTunesModelsLimitsResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.FineTuneModelLimits.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunesModelsLimits", + methodName: "GetFineTunesModelsLimitsAsync", + pathTemplate: "\"/fine-tunes/models/limits\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunesModelsLimits", + methodName: "GetFineTunesModelsLimitsAsync", + pathTemplate: "\"/fine-tunes/models/limits\"", + httpMethod: "GET", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Model not found or not supported for fine-tuning. + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Together.GetFineTunesModelsLimitsResponse? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Together.GetFineTunesModelsLimitsResponse.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.FineTuneModelLimits.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_404 = global::Together.GetFineTunesModelsLimitsResponse.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Together.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessGetFineTunesModelsLimitsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.FineTuneModelLimits.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.FineTuneModelLimits.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.FineTuningClient.GetFineTunesModelsSupported.g.cs b/src/libs/Together/Generated/Together.FineTuningClient.GetFineTunesModelsSupported.g.cs index 29a6c9b5..c4daa08f 100644 --- a/src/libs/Together/Generated/Together.FineTuningClient.GetFineTunesModelsSupported.g.cs +++ b/src/libs/Together/Generated/Together.FineTuningClient.GetFineTunesModelsSupported.g.cs @@ -14,6 +14,7 @@ public partial class FineTuningClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -42,13 +43,37 @@ partial void ProcessGetFineTunesModelsSupportedResponseContent( /// List supported models
/// List models supported for fine-tuning. /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// - /// curl "https://api.together.xyz/v1/fine-tunes/models/supported" \
+ /// curl "https://api.together.ai/v1/fine-tunes/models/supported" \
/// -H "Authorization: Bearer $TOGETHER_API_KEY" ///
public async global::System.Threading.Tasks.Task GetFineTunesModelsSupportedAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetFineTunesModelsSupportedAsResponseAsync( + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// List supported models
+ /// List models supported for fine-tuning. + ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// curl "https://api.together.ai/v1/fine-tunes/models/supported" \
+ /// -H "Authorization: Bearer $TOGETHER_API_KEY" + ///
+ public async global::System.Threading.Tasks.Task> GetFineTunesModelsSupportedAsResponseAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -62,22 +87,44 @@ partial void ProcessGetFineTunesModelsSupportedResponseContent( securityRequirements: s_GetFineTunesModelsSupportedSecurityRequirements, operationName: "GetFineTunesModelsSupportedAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/fine-tunes/models/supported", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/fine-tunes/models/supported", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -87,111 +134,296 @@ partial void ProcessGetFineTunesModelsSupportedResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetFineTunesModelsSupportedRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetFineTunesModelsSupportedRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetFineTunesModelsSupportedResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunesModelsSupported", + methodName: "GetFineTunesModelsSupportedAsync", + pathTemplate: "\"/fine-tunes/models/supported\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunesModelsSupported", + methodName: "GetFineTunesModelsSupportedAsync", + pathTemplate: "\"/fine-tunes/models/supported\"", + httpMethod: "GET", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessGetFineTunesModelsSupportedResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunesModelsSupported", + methodName: "GetFineTunesModelsSupportedAsync", + pathTemplate: "\"/fine-tunes/models/supported\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::Together.GetFineTunesModelsSupportedResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Together.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), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return - await global::Together.GetFineTunesModelsSupportedResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetFineTunesModelsSupportedResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunesModelsSupported", + methodName: "GetFineTunesModelsSupportedAsync", + pathTemplate: "\"/fine-tunes/models/supported\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFineTunesModelsSupported", + methodName: "GetFineTunesModelsSupportedAsync", + pathTemplate: "\"/fine-tunes/models/supported\"", + httpMethod: "GET", + 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); + ProcessGetFineTunesModelsSupportedResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.GetFineTunesModelsSupportedResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.GetFineTunesModelsSupportedResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.FineTuningClient.GetFinetuneDownload.g.cs b/src/libs/Together/Generated/Together.FineTuningClient.GetFinetuneDownload.g.cs index 5ed1c7e8..c88ae981 100644 --- a/src/libs/Together/Generated/Together.FineTuningClient.GetFinetuneDownload.g.cs +++ b/src/libs/Together/Generated/Together.FineTuningClient.GetFinetuneDownload.g.cs @@ -14,6 +14,7 @@ public partial class FineTuningClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,6 +58,7 @@ partial void ProcessGetFinetuneDownloadResponseContent( /// /// Specifies checkpoint type to download - `merged` vs `adapter`. This field is required if the checkpoint_step is not set. /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -76,6 +78,53 @@ partial void ProcessGetFinetuneDownloadResponseContent( string ftId, int? checkpointStep = default, global::Together.GetFinetuneDownloadCheckpoint? checkpoint = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetFinetuneDownloadAsResponseAsync( + ftId: ftId, + checkpointStep: checkpointStep, + checkpoint: checkpoint, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Download model
+ /// Receive a compressed fine-tuned model or checkpoint. + ///
+ /// + /// Fine-tune ID to download. A string that starts with `ft-`. + /// + /// + /// Specifies step number for checkpoint to download. Ignores `checkpoint` value if set. + /// + /// + /// Specifies checkpoint type to download - `merged` vs `adapter`. This field is required if the checkpoint_step is not set. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// # Using `with_streaming_response` gives you control to do what you want with the response.
+ /// stream = client.fine_tuning.with_streaming_response.content(ft_id="ft-id")
+ /// with stream as response:
+ /// for line in response.iter_lines():
+ /// print(line) + ///
+ public async global::System.Threading.Tasks.Task GetFinetuneDownloadAsStreamAsync( + string ftId, + int? checkpointStep = default, + global::Together.GetFinetuneDownloadCheckpoint? checkpoint = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -92,27 +141,49 @@ partial void ProcessGetFinetuneDownloadResponseContent( securityRequirements: s_GetFinetuneDownloadSecurityRequirements, operationName: "GetFinetuneDownloadAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/finetune/download", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddRequiredParameter("ft_id", ftId) - .AddOptionalParameter("checkpoint_step", checkpointStep?.ToString()) - .AddOptionalParameter("checkpoint", checkpoint?.ToValueString()) - ; - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/finetune/download", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddRequiredParameter("ft_id", ftId) + .AddOptionalParameter("checkpoint_step", checkpointStep?.ToString()) + .AddOptionalParameter("checkpoint", checkpoint?.ToValueString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -122,170 +193,770 @@ partial void ProcessGetFinetuneDownloadResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetFinetuneDownloadRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - ftId: ftId, - checkpointStep: checkpointStep, - checkpoint: checkpoint); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetFinetuneDownloadRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ftId: ftId!, + checkpointStep: checkpointStep, + checkpoint: checkpoint); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetFinetuneDownloadResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 400) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFinetuneDownload", + methodName: "GetFinetuneDownloadAsync", + pathTemplate: "\"/finetune/download\"", + httpMethod: "GET", + 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 { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFinetuneDownload", + methodName: "GetFinetuneDownloadAsync", + pathTemplate: "\"/finetune/download\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else + + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFinetuneDownload", + methodName: "GetFinetuneDownloadAsync", + pathTemplate: "\"/finetune/download\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_400 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // - if ((int)__response.StatusCode == 404) - { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; try { - if (ReadResponseAsString) - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - } - else - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - } + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetFinetuneDownloadResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFinetuneDownload", + methodName: "GetFinetuneDownloadAsync", + pathTemplate: "\"/finetune/download\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - __exception_404 = __ex; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFinetuneDownload", + methodName: "GetFinetuneDownloadAsync", + pathTemplate: "\"/finetune/download\"", + httpMethod: "GET", + 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 ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } - throw new global::Together.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } + throw new global::Together.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsByteArrayAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + throw new global::Together.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } - ProcessGetFinetuneDownloadResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + try + { + __response.EnsureSuccessStatusCode(); - try - { - __response.EnsureSuccessStatusCode(); + var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::Together.ResponseStream(__response, __content); + } + 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::Together.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), + }; + } - return __content; } - catch (global::System.Exception __ex) + catch { - throw new global::Together.ApiException( - message: __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + __response.Dispose(); + throw; } } - else + finally { - try - { - __response.EnsureSuccessStatusCode(); - var __content = await __response.Content.ReadAsByteArrayAsync( -#if NET5_0_OR_GREATER - cancellationToken + __httpRequest?.Dispose(); + } + } + /// + /// Download model
+ /// Receive a compressed fine-tuned model or checkpoint. + ///
+ /// + /// Fine-tune ID to download. A string that starts with `ft-`. + /// + /// + /// Specifies step number for checkpoint to download. Ignores `checkpoint` value if set. + /// + /// + /// Specifies checkpoint type to download - `merged` vs `adapter`. This field is required if the checkpoint_step is not set. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// # Using `with_streaming_response` gives you control to do what you want with the response.
+ /// stream = client.fine_tuning.with_streaming_response.content(ft_id="ft-id")
+ /// with stream as response:
+ /// for line in response.iter_lines():
+ /// print(line) + ///
+ public async global::System.Threading.Tasks.Task> GetFinetuneDownloadAsResponseAsync( + string ftId, + int? checkpointStep = default, + global::Together.GetFinetuneDownloadCheckpoint? checkpoint = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareGetFinetuneDownloadArguments( + httpClient: HttpClient, + ftId: ref ftId, + checkpointStep: ref checkpointStep, + checkpoint: ref checkpoint); + + + var __authorizations = global::Together.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_GetFinetuneDownloadSecurityRequirements, + operationName: "GetFinetuneDownloadAsync"); + + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/finetune/download", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddRequiredParameter("ft_id", ftId) + .AddOptionalParameter("checkpoint_step", checkpointStep?.ToString()) + .AddOptionalParameter("checkpoint", checkpoint?.ToValueString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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 - ).ConfigureAwait(false); - return __content; + 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); } - catch (global::System.Exception __ex) + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") { - string? __content = null; + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetFinetuneDownloadRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + ftId: ftId!, + checkpointStep: checkpointStep, + checkpoint: checkpoint); + + 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::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFinetuneDownload", + methodName: "GetFinetuneDownloadAsync", + pathTemplate: "\"/finetune/download\"", + httpMethod: "GET", + 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 { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - catch (global::System.Exception) + catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFinetuneDownload", + methodName: "GetFinetuneDownloadAsync", + pathTemplate: "\"/finetune/download\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - throw new global::Together.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFinetuneDownload", + methodName: "GetFinetuneDownloadAsync", + pathTemplate: "\"/finetune/download\"", + httpMethod: "GET", + 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::Together.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); + ProcessGetFinetuneDownloadResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFinetuneDownload", + methodName: "GetFinetuneDownloadAsync", + pathTemplate: "\"/finetune/download\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getFinetuneDownload", + methodName: "GetFinetuneDownloadAsync", + pathTemplate: "\"/finetune/download\"", + httpMethod: "GET", + 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 ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Together.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Together.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsByteArrayAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessGetFinetuneDownloadResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __content); + } + catch (global::System.Exception __ex) + { + throw new global::Together.ApiException( + message: __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + var __content = await __response.Content.ReadAsByteArrayAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __content); + } + 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::Together.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(); } } } diff --git a/src/libs/Together/Generated/Together.FineTuningClient.g.cs b/src/libs/Together/Generated/Together.FineTuningClient.g.cs index dfbf5c9c..c2d0662e 100644 --- a/src/libs/Together/Generated/Together.FineTuningClient.g.cs +++ b/src/libs/Together/Generated/Together.FineTuningClient.g.cs @@ -12,7 +12,7 @@ public sealed partial class FineTuningClient : global::Together.IFineTuningClien /// /// /// - public const string DefaultBaseUrl = "https://api.together.xyz/v1"; + public const string DefaultBaseUrl = "https://api.together.ai/v1"; private bool _disposeHttpClient = true; @@ -30,6 +30,12 @@ public sealed partial class FineTuningClient : global::Together.IFineTuningClien #if DEBUG = true; #endif + + /// + public global::Together.AutoSDKClientOptions Options { get; } + + + internal global::Together.AutoSDKServerConfiguration AutoSDKServerConfiguration { get; set; } = new global::Together.AutoSDKServerConfiguration(); /// /// /// @@ -49,13 +55,62 @@ public FineTuningClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the FineTuningClient with explicit options but no base URL override. + /// Skips passing baseUri so the default base URL from the OpenAPI spec applies. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public FineTuningClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, + bool disposeHttpClient = true) : this( + httpClient, + baseUri: null, + authorizations, + options, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the FineTuningClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public FineTuningClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Together.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; + AutoSDKServerConfiguration.ExplicitBaseUri = baseUri ?? httpClient?.BaseAddress; + Initialized(HttpClient); } diff --git a/src/libs/Together/Generated/Together.GPUClusterServiceClient.GPUClusterServiceCreate.g.cs b/src/libs/Together/Generated/Together.GPUClusterServiceClient.GPUClusterServiceCreate.g.cs index b6b1cb9e..48e05d58 100644 --- a/src/libs/Together/Generated/Together.GPUClusterServiceClient.GPUClusterServiceCreate.g.cs +++ b/src/libs/Together/Generated/Together.GPUClusterServiceClient.GPUClusterServiceCreate.g.cs @@ -14,6 +14,7 @@ public partial class GPUClusterServiceClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -41,13 +42,14 @@ partial void ProcessGPUClusterServiceCreateResponseContent( ref string content); /// - /// Create GPU Cluster
+ /// Create a GPU cluster
/// Create an Instant Cluster on Together's high-performance GPU clusters.
/// With features like on-demand scaling, long-lived resizable high-bandwidth shared DC-local storage,
/// Kubernetes and Slurm cluster flavors, a REST API, and Terraform support,
/// you can run workloads flexibly without complex infrastructure management. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -66,6 +68,46 @@ partial void ProcessGPUClusterServiceCreateResponseContent( public async global::System.Threading.Tasks.Task GPUClusterServiceCreateAsync( global::Together.GPUClusterCreateRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GPUClusterServiceCreateAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Create a GPU cluster
+ /// Create an Instant Cluster on Together's high-performance GPU clusters.
+ /// With features like on-demand scaling, long-lived resizable high-bandwidth shared DC-local storage,
+ /// Kubernetes and Slurm cluster flavors, a REST API, and Terraform support,
+ /// you can run workloads flexibly without complex infrastructure management. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// response = client.beta.clusters.create(
+ /// cluster_name="my-gpu-cluster",
+ /// region="us-central-8",
+ /// gpu_type="H100_SXM",
+ /// num_gpus=8,
+ /// driver_version="CUDA_12_6_560",
+ /// billint_type="ON_DEMAND",
+ /// )
+ /// print(response.cluster_id) + ///
+ public async global::System.Threading.Tasks.Task> GPUClusterServiceCreateAsResponseAsync( + + global::Together.GPUClusterCreateRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -82,22 +124,44 @@ partial void ProcessGPUClusterServiceCreateResponseContent( securityRequirements: s_GPUClusterServiceCreateSecurityRequirements, operationName: "GPUClusterServiceCreateAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/compute/clusters", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/compute/clusters", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -107,121 +171,306 @@ partial void ProcessGPUClusterServiceCreateResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGPUClusterServiceCreateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGPUClusterServiceCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGPUClusterServiceCreateResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GPUClusterServiceCreate", + methodName: "GPUClusterServiceCreateAsync", + pathTemplate: "\"/compute/clusters\"", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GPUClusterServiceCreate", + methodName: "GPUClusterServiceCreateAsync", + pathTemplate: "\"/compute/clusters\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessGPUClusterServiceCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GPUClusterServiceCreate", + methodName: "GPUClusterServiceCreateAsync", + pathTemplate: "\"/compute/clusters\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::Together.GPUClusterInfo.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Together.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), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return - await global::Together.GPUClusterInfo.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGPUClusterServiceCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GPUClusterServiceCreate", + methodName: "GPUClusterServiceCreateAsync", + pathTemplate: "\"/compute/clusters\"", + 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); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GPUClusterServiceCreate", + methodName: "GPUClusterServiceCreateAsync", + pathTemplate: "\"/compute/clusters\"", + 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); + ProcessGPUClusterServiceCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.GPUClusterInfo.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.GPUClusterInfo.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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 GPU Cluster
+ /// Create a GPU cluster
/// Create an Instant Cluster on Together's high-performance GPU clusters.
/// With features like on-demand scaling, long-lived resizable high-bandwidth shared DC-local storage,
/// Kubernetes and Slurm cluster flavors, a REST API, and Terraform support,
@@ -245,9 +494,6 @@ partial void ProcessGPUClusterServiceCreateResponseContent( /// /// Duration in days to keep the cluster running. /// - /// - /// NVIDIA driver version to use in the cluster. - /// /// /// Inline configuration to create a shared volume with the cluster creation. /// @@ -256,8 +502,46 @@ partial void ProcessGPUClusterServiceCreateResponseContent( /// /// /// RESERVED billing types allow you to specify the duration of the cluster reservation via the duration_days field.
- /// ON_DEMAND billing types will give you ownership of the cluster until you delete it. + /// ON_DEMAND billing types will give you ownership of the cluster until you delete it.
+ /// SCHEDULED_CAPACITY billing types allow you to reserve capacity for a scheduled time window. You must specify the reservation_start_time and reservation_end_time with this request. + /// + /// + /// Whether automated GPU node failover should be enabled for this cluster. By default, it is disabled.
+ /// Default Value: false + /// + /// + /// Whether GPU cluster should be auto-scaled based on the workload. By default, it is not auto-scaled.
+ /// Default Value: false + /// + /// + /// Maximum number of GPUs to which the cluster can be auto-scaled up. This field is required if auto_scaled is true. + /// + /// + /// Shared memory size in GiB for Slurm cluster. This field is required if cluster_type is SLURM. + /// + /// + /// ID of the capacity pool to use for the cluster. This field is optional and only applicable if the cluster is created from a capacity pool. + /// + /// + /// Reservation start time of the cluster. This field is required for SCHEDULED billing to specify the reservation start time for the cluster. If not provided, the cluster provisions immediately. + /// + /// + /// Reservation end time of the cluster. This field is required for SCHEDULED billing to specify the reservation end time for the cluster. + /// + /// + /// Whether to install Traefik ingress controller in the cluster. This field is only applicable for Kubernetes clusters and is false by default.
+ /// Default Value: false + /// + /// + /// CUDA version for this cluster. For example, 12.5 + /// + /// + /// Nvidia driver version for this cluster. For example, 550. Only some combination of cuda_version and nvidia_driver_version are supported. + /// + /// + /// Custom Slurm image for Slurm clusters. /// + /// 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 GPUClusterServiceCreateAsync( @@ -265,12 +549,23 @@ partial void ProcessGPUClusterServiceCreateResponseContent( global::Together.GPUClusterCreateRequestGpuType gpuType, int numGpus, string clusterName, - global::Together.GPUClusterCreateRequestDriverVersion driverVersion, global::Together.GPUClusterCreateRequestBillingType billingType, + string cudaVersion, + string nvidiaDriverVersion, global::Together.GPUClusterCreateRequestClusterType? clusterType = default, int? durationDays = default, global::Together.GPUClustersSharedVolumeCreateRequest? sharedVolume = default, string? volumeId = default, + bool? gpuNodeFailoverEnabled = default, + bool? autoScaled = default, + int? autoScaleMaxGpus = default, + int? slurmShmSizeGib = default, + string? capacityPoolId = default, + global::System.DateTime? reservationStartTime = default, + global::System.DateTime? reservationEndTime = default, + bool? installTraefik = default, + string? slurmImage = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.GPUClusterCreateRequest @@ -281,14 +576,25 @@ partial void ProcessGPUClusterServiceCreateResponseContent( NumGpus = numGpus, ClusterName = clusterName, DurationDays = durationDays, - DriverVersion = driverVersion, SharedVolume = sharedVolume, VolumeId = volumeId, BillingType = billingType, + GpuNodeFailoverEnabled = gpuNodeFailoverEnabled, + AutoScaled = autoScaled, + AutoScaleMaxGpus = autoScaleMaxGpus, + SlurmShmSizeGib = slurmShmSizeGib, + CapacityPoolId = capacityPoolId, + ReservationStartTime = reservationStartTime, + ReservationEndTime = reservationEndTime, + InstallTraefik = installTraefik, + CudaVersion = cudaVersion, + NvidiaDriverVersion = nvidiaDriverVersion, + SlurmImage = slurmImage, }; return await GPUClusterServiceCreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Together/Generated/Together.GPUClusterServiceClient.GPUClusterServiceDelete.g.cs b/src/libs/Together/Generated/Together.GPUClusterServiceClient.GPUClusterServiceDelete.g.cs index eafae5c2..724756a2 100644 --- a/src/libs/Together/Generated/Together.GPUClusterServiceClient.GPUClusterServiceDelete.g.cs +++ b/src/libs/Together/Generated/Together.GPUClusterServiceClient.GPUClusterServiceDelete.g.cs @@ -14,6 +14,7 @@ public partial class GPUClusterServiceClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,6 +48,7 @@ partial void ProcessGPUClusterServiceDeleteResponseContent( /// /// The ID of the cluster to delete /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -57,6 +59,36 @@ partial void ProcessGPUClusterServiceDeleteResponseContent( /// public async global::System.Threading.Tasks.Task GPUClusterServiceDeleteAsync( string clusterId, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GPUClusterServiceDeleteAsResponseAsync( + clusterId: clusterId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Delete GPU cluster by cluster ID
+ /// Delete a GPU cluster by cluster ID. + ///
+ /// + /// The ID of the cluster to delete + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// cluster = client.beta.clusters.delete("cluster_id")
+ /// print(cluster) + ///
+ public async global::System.Threading.Tasks.Task> GPUClusterServiceDeleteAsResponseAsync( + string clusterId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -71,22 +103,44 @@ partial void ProcessGPUClusterServiceDeleteResponseContent( securityRequirements: s_GPUClusterServiceDeleteSecurityRequirements, operationName: "GPUClusterServiceDeleteAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/compute/clusters/{clusterId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Delete, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/compute/clusters/{clusterId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Delete, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -96,112 +150,297 @@ partial void ProcessGPUClusterServiceDeleteResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGPUClusterServiceDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - clusterId: clusterId); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGPUClusterServiceDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + clusterId: clusterId!); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGPUClusterServiceDeleteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GPUClusterServiceDelete", + methodName: "GPUClusterServiceDeleteAsync", + pathTemplate: "$\"/compute/clusters/{clusterId}\"", + httpMethod: "DELETE", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GPUClusterServiceDelete", + methodName: "GPUClusterServiceDeleteAsync", + pathTemplate: "$\"/compute/clusters/{clusterId}\"", + httpMethod: "DELETE", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessGPUClusterServiceDeleteResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GPUClusterServiceDelete", + methodName: "GPUClusterServiceDeleteAsync", + pathTemplate: "$\"/compute/clusters/{clusterId}\"", + httpMethod: "DELETE", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::Together.GPUClusterServiceDeleteResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Together.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), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return - await global::Together.GPUClusterServiceDeleteResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGPUClusterServiceDeleteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GPUClusterServiceDelete", + methodName: "GPUClusterServiceDeleteAsync", + pathTemplate: "$\"/compute/clusters/{clusterId}\"", + httpMethod: "DELETE", + 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); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GPUClusterServiceDelete", + methodName: "GPUClusterServiceDeleteAsync", + pathTemplate: "$\"/compute/clusters/{clusterId}\"", + httpMethod: "DELETE", + 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); + ProcessGPUClusterServiceDeleteResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.GPUClusterServiceDeleteResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.GPUClusterServiceDeleteResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.GPUClusterServiceClient.GPUClusterServiceGet.g.cs b/src/libs/Together/Generated/Together.GPUClusterServiceClient.GPUClusterServiceGet.g.cs index ea440f9e..daab3035 100644 --- a/src/libs/Together/Generated/Together.GPUClusterServiceClient.GPUClusterServiceGet.g.cs +++ b/src/libs/Together/Generated/Together.GPUClusterServiceClient.GPUClusterServiceGet.g.cs @@ -14,6 +14,7 @@ public partial class GPUClusterServiceClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,6 +48,7 @@ partial void ProcessGPUClusterServiceGetResponseContent( /// /// The ID of the cluster to retrieve /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -57,6 +59,36 @@ partial void ProcessGPUClusterServiceGetResponseContent( /// public async global::System.Threading.Tasks.Task GPUClusterServiceGetAsync( string clusterId, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GPUClusterServiceGetAsResponseAsync( + clusterId: clusterId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get GPU cluster by cluster ID
+ /// Retrieve information about a specific GPU cluster. + ///
+ /// + /// The ID of the cluster to retrieve + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// cluster = client.beta.clusters.retrieve("cluster_id")
+ /// print(cluster) + ///
+ public async global::System.Threading.Tasks.Task> GPUClusterServiceGetAsResponseAsync( + string clusterId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -71,22 +103,44 @@ partial void ProcessGPUClusterServiceGetResponseContent( securityRequirements: s_GPUClusterServiceGetSecurityRequirements, operationName: "GPUClusterServiceGetAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/compute/clusters/{clusterId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/compute/clusters/{clusterId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -96,112 +150,297 @@ partial void ProcessGPUClusterServiceGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGPUClusterServiceGetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - clusterId: clusterId); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGPUClusterServiceGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + clusterId: clusterId!); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGPUClusterServiceGetResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GPUClusterServiceGet", + methodName: "GPUClusterServiceGetAsync", + pathTemplate: "$\"/compute/clusters/{clusterId}\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GPUClusterServiceGet", + methodName: "GPUClusterServiceGetAsync", + pathTemplate: "$\"/compute/clusters/{clusterId}\"", + httpMethod: "GET", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessGPUClusterServiceGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GPUClusterServiceGet", + methodName: "GPUClusterServiceGetAsync", + pathTemplate: "$\"/compute/clusters/{clusterId}\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::Together.GPUClusterInfo.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Together.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), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return - await global::Together.GPUClusterInfo.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGPUClusterServiceGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GPUClusterServiceGet", + methodName: "GPUClusterServiceGetAsync", + pathTemplate: "$\"/compute/clusters/{clusterId}\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GPUClusterServiceGet", + methodName: "GPUClusterServiceGetAsync", + pathTemplate: "$\"/compute/clusters/{clusterId}\"", + httpMethod: "GET", + 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); + ProcessGPUClusterServiceGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.GPUClusterInfo.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.GPUClusterInfo.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.GPUClusterServiceClient.GPUClusterServiceList.g.cs b/src/libs/Together/Generated/Together.GPUClusterServiceClient.GPUClusterServiceList.g.cs index 996640e1..aa806d33 100644 --- a/src/libs/Together/Generated/Together.GPUClusterServiceClient.GPUClusterServiceList.g.cs +++ b/src/libs/Together/Generated/Together.GPUClusterServiceClient.GPUClusterServiceList.g.cs @@ -14,6 +14,7 @@ public partial class GPUClusterServiceClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -39,9 +40,10 @@ partial void ProcessGPUClusterServiceListResponseContent( ref string content); /// - /// List all GPU clusters.
+ /// List all GPU clusters
/// List all GPU clusters. ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -54,6 +56,34 @@ partial void ProcessGPUClusterServiceListResponseContent( /// print(response.clusters) /// public async global::System.Threading.Tasks.Task GPUClusterServiceListAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GPUClusterServiceListAsResponseAsync( + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// List all GPU clusters
+ /// List all GPU clusters. + ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.beta.clusters.list()
+ /// print(response.clusters) + ///
+ public async global::System.Threading.Tasks.Task> GPUClusterServiceListAsResponseAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -67,22 +97,44 @@ partial void ProcessGPUClusterServiceListResponseContent( securityRequirements: s_GPUClusterServiceListSecurityRequirements, operationName: "GPUClusterServiceListAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/compute/clusters", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/compute/clusters", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -92,111 +144,296 @@ partial void ProcessGPUClusterServiceListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGPUClusterServiceListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGPUClusterServiceListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGPUClusterServiceListResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GPUClusterServiceList", + methodName: "GPUClusterServiceListAsync", + pathTemplate: "\"/compute/clusters\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GPUClusterServiceList", + methodName: "GPUClusterServiceListAsync", + pathTemplate: "\"/compute/clusters\"", + httpMethod: "GET", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessGPUClusterServiceListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GPUClusterServiceList", + methodName: "GPUClusterServiceListAsync", + pathTemplate: "\"/compute/clusters\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::Together.GPUClusters.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Together.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), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return - await global::Together.GPUClusters.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGPUClusterServiceListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GPUClusterServiceList", + methodName: "GPUClusterServiceListAsync", + pathTemplate: "\"/compute/clusters\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GPUClusterServiceList", + methodName: "GPUClusterServiceListAsync", + pathTemplate: "\"/compute/clusters\"", + httpMethod: "GET", + 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); + ProcessGPUClusterServiceListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.GPUClusters.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.GPUClusters.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.GPUClusterServiceClient.GPUClusterServiceUpdate.g.cs b/src/libs/Together/Generated/Together.GPUClusterServiceClient.GPUClusterServiceUpdate.g.cs index e7e4d231..b2a3af41 100644 --- a/src/libs/Together/Generated/Together.GPUClusterServiceClient.GPUClusterServiceUpdate.g.cs +++ b/src/libs/Together/Generated/Together.GPUClusterServiceClient.GPUClusterServiceUpdate.g.cs @@ -14,6 +14,7 @@ public partial class GPUClusterServiceClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -43,13 +44,14 @@ partial void ProcessGPUClusterServiceUpdateResponseContent( ref string content); /// - /// Update a GPU Cluster.
+ /// Update a GPU cluster
/// Update the configuration of an existing GPU cluster. ///
/// /// The ID of the cluster to update /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -62,6 +64,41 @@ partial void ProcessGPUClusterServiceUpdateResponseContent( string clusterId, global::Together.GPUClusterUpdateRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GPUClusterServiceUpdateAsResponseAsync( + clusterId: clusterId, + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Update a GPU cluster
+ /// Update the configuration of an existing GPU cluster. + ///
+ /// + /// The ID of the cluster to update + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// cluster = client.beta.clusters.update("cluster_id", cluster_type="KUBERNETES", num_gpus=24)
+ /// print(cluster) + ///
+ public async global::System.Threading.Tasks.Task> GPUClusterServiceUpdateAsResponseAsync( + string clusterId, + + global::Together.GPUClusterUpdateRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -79,22 +116,44 @@ partial void ProcessGPUClusterServiceUpdateResponseContent( securityRequirements: s_GPUClusterServiceUpdateSecurityRequirements, operationName: "GPUClusterServiceUpdateAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/compute/clusters/{clusterId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Put, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/compute/clusters/{clusterId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Put, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -104,122 +163,307 @@ partial void ProcessGPUClusterServiceUpdateResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGPUClusterServiceUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - clusterId: clusterId, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGPUClusterServiceUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + clusterId: clusterId!, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGPUClusterServiceUpdateResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GPUClusterServiceUpdate", + methodName: "GPUClusterServiceUpdateAsync", + pathTemplate: "$\"/compute/clusters/{clusterId}\"", + httpMethod: "PUT", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GPUClusterServiceUpdate", + methodName: "GPUClusterServiceUpdateAsync", + pathTemplate: "$\"/compute/clusters/{clusterId}\"", + httpMethod: "PUT", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessGPUClusterServiceUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GPUClusterServiceUpdate", + methodName: "GPUClusterServiceUpdateAsync", + pathTemplate: "$\"/compute/clusters/{clusterId}\"", + httpMethod: "PUT", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::Together.GPUClusterInfo.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Together.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), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return - await global::Together.GPUClusterInfo.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGPUClusterServiceUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GPUClusterServiceUpdate", + methodName: "GPUClusterServiceUpdateAsync", + pathTemplate: "$\"/compute/clusters/{clusterId}\"", + httpMethod: "PUT", + 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); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GPUClusterServiceUpdate", + methodName: "GPUClusterServiceUpdateAsync", + pathTemplate: "$\"/compute/clusters/{clusterId}\"", + httpMethod: "PUT", + 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); + ProcessGPUClusterServiceUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.GPUClusterInfo.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.GPUClusterInfo.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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(); + } } /// - /// Update a GPU Cluster.
+ /// Update a GPU cluster
/// Update the configuration of an existing GPU cluster. ///
/// @@ -231,23 +475,31 @@ partial void ProcessGPUClusterServiceUpdateResponseContent( /// /// Number of GPUs to allocate in the cluster. This must be multiple of 8. For example, 8, 16 or 24 /// + /// + /// Timestamp at which the cluster should be decommissioned. Only accepted for prepaid clusters. + /// + /// 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 GPUClusterServiceUpdateAsync( string clusterId, global::Together.GPUClusterUpdateRequestClusterType? clusterType = default, int? numGpus = default, + global::System.DateTime? reservationEndTime = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.GPUClusterUpdateRequest { ClusterType = clusterType, NumGpus = numGpus, + ReservationEndTime = reservationEndTime, }; return await GPUClusterServiceUpdateAsync( clusterId: clusterId, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Together/Generated/Together.GPUClusterServiceClient.g.cs b/src/libs/Together/Generated/Together.GPUClusterServiceClient.g.cs index 865ed4fb..7d0e66a2 100644 --- a/src/libs/Together/Generated/Together.GPUClusterServiceClient.g.cs +++ b/src/libs/Together/Generated/Together.GPUClusterServiceClient.g.cs @@ -12,7 +12,7 @@ public sealed partial class GPUClusterServiceClient : global::Together.IGPUClust /// /// /// - public const string DefaultBaseUrl = "https://api.together.xyz/v1"; + public const string DefaultBaseUrl = "https://api.together.ai/v1"; private bool _disposeHttpClient = true; @@ -30,6 +30,12 @@ public sealed partial class GPUClusterServiceClient : global::Together.IGPUClust #if DEBUG = true; #endif + + /// + public global::Together.AutoSDKClientOptions Options { get; } + + + internal global::Together.AutoSDKServerConfiguration AutoSDKServerConfiguration { get; set; } = new global::Together.AutoSDKServerConfiguration(); /// /// /// @@ -49,13 +55,62 @@ public GPUClusterServiceClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the GPUClusterServiceClient with explicit options but no base URL override. + /// Skips passing baseUri so the default base URL from the OpenAPI spec applies. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public GPUClusterServiceClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, + bool disposeHttpClient = true) : this( + httpClient, + baseUri: null, + authorizations, + options, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the GPUClusterServiceClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public GPUClusterServiceClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Together.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; + AutoSDKServerConfiguration.ExplicitBaseUri = baseUri ?? httpClient?.BaseAddress; + Initialized(HttpClient); } diff --git a/src/libs/Together/Generated/Together.HardwareClient.ListHardware.g.cs b/src/libs/Together/Generated/Together.HardwareClient.ListHardware.g.cs index b7d9e551..b86330ab 100644 --- a/src/libs/Together/Generated/Together.HardwareClient.ListHardware.g.cs +++ b/src/libs/Together/Generated/Together.HardwareClient.ListHardware.g.cs @@ -14,6 +14,7 @@ public partial class HardwareClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -50,6 +51,7 @@ partial void ProcessListHardwareResponseContent( /// [See all of Together AI's dedicated models](https://docs.together.ai/docs/dedicated-models)
/// Example: deepseek-ai/DeepSeek-R1 /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -65,6 +67,44 @@ partial void ProcessListHardwareResponseContent( /// public async global::System.Threading.Tasks.Task ListHardwareAsync( string? model = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await ListHardwareAsResponseAsync( + model: model, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// List available hardware configurations
+ /// Returns a list of available hardware configurations for deploying models. When a model parameter is provided, it returns only hardware configurations compatible with that model, including their current availability status. + ///
+ /// + /// Filter hardware configurations by model compatibility. When provided,
+ /// the response includes availability status for each compatible configuration.
+ /// [See all of Together AI's dedicated models](https://docs.together.ai/docs/dedicated-models)
+ /// Example: deepseek-ai/DeepSeek-R1 + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.endpoints.list_hardware()
+ /// for hardware in response.data:
+ /// print(hardware.id) + ///
+ public async global::System.Threading.Tasks.Task> ListHardwareAsResponseAsync( + string? model = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -79,25 +119,47 @@ partial void ProcessListHardwareResponseContent( securityRequirements: s_ListHardwareSecurityRequirements, operationName: "ListHardwareAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/hardware", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("model", model) - ; - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/hardware", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("model", model) + ; + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -107,188 +169,373 @@ partial void ProcessListHardwareResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListHardwareRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - model: model); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListHardwareRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + model: model); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListHardwareResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Unauthorized - if ((int)__response.StatusCode == 403) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_403 = null; - global::System.Exception? __exception_403 = null; - global::Together.ErrorData? __value_403 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListHardware", + methodName: "ListHardwareAsync", + pathTemplate: "\"/hardware\"", + httpMethod: "GET", + 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 { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_403 = global::Together.ErrorData.FromJson(__content_403, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_403 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListHardware", + methodName: "ListHardwareAsync", + pathTemplate: "\"/hardware\"", + httpMethod: "GET", + 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; + } - __value_403 = global::Together.ErrorData.FromJson(__content_403, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_403 = __ex; - } - throw new global::Together.ApiException( - message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_403, - statusCode: __response.StatusCode) - { - ResponseBody = __content_403, - ResponseObject = __value_403, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Internal error - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - global::Together.ErrorData? __value_500 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListHardware", + methodName: "ListHardwareAsync", + pathTemplate: "\"/hardware\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_500 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessListHardwareResponseContent( + response: __response); + ProcessListHardwareResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.ListHardwareResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListHardware", + methodName: "ListHardwareAsync", + pathTemplate: "\"/hardware\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListHardware", + methodName: "ListHardwareAsync", + pathTemplate: "\"/hardware\"", + httpMethod: "GET", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Unauthorized + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Together.ErrorData? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Together.ErrorData.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.ListHardwareResponse.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_403 = global::Together.ErrorData.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::Together.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseObject = __value_403, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Together.ErrorData? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::Together.ErrorData.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessListHardwareResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.ListHardwareResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.ListHardwareResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.HardwareClient.g.cs b/src/libs/Together/Generated/Together.HardwareClient.g.cs index c789a82c..add6a31f 100644 --- a/src/libs/Together/Generated/Together.HardwareClient.g.cs +++ b/src/libs/Together/Generated/Together.HardwareClient.g.cs @@ -12,7 +12,7 @@ public sealed partial class HardwareClient : global::Together.IHardwareClient, g /// /// /// - public const string DefaultBaseUrl = "https://api.together.xyz/v1"; + public const string DefaultBaseUrl = "https://api.together.ai/v1"; private bool _disposeHttpClient = true; @@ -30,6 +30,12 @@ public sealed partial class HardwareClient : global::Together.IHardwareClient, g #if DEBUG = true; #endif + + /// + public global::Together.AutoSDKClientOptions Options { get; } + + + internal global::Together.AutoSDKServerConfiguration AutoSDKServerConfiguration { get; set; } = new global::Together.AutoSDKServerConfiguration(); /// /// /// @@ -49,13 +55,62 @@ public HardwareClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the HardwareClient with explicit options but no base URL override. + /// Skips passing baseUri so the default base URL from the OpenAPI spec applies. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public HardwareClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, + bool disposeHttpClient = true) : this( + httpClient, + baseUri: null, + authorizations, + options, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the HardwareClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public HardwareClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Together.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; + AutoSDKServerConfiguration.ExplicitBaseUri = baseUri ?? httpClient?.BaseAddress; + Initialized(HttpClient); } diff --git a/src/libs/Together/Generated/Together.IAudioClient.AudioSpeech.g.cs b/src/libs/Together/Generated/Together.IAudioClient.AudioSpeech.g.cs index 6e90a5e6..d6fa62a9 100644 --- a/src/libs/Together/Generated/Together.IAudioClient.AudioSpeech.g.cs +++ b/src/libs/Together/Generated/Together.IAudioClient.AudioSpeech.g.cs @@ -9,6 +9,7 @@ public partial interface IAudioClient /// Generate audio from input text ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -29,6 +30,7 @@ public partial interface IAudioClient global::System.Collections.Generic.IAsyncEnumerable AudioSpeechAsync( global::Together.AudioSpeechRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create audio generation request
@@ -42,22 +44,23 @@ public partial interface IAudioClient /// Input text to generate the audio for /// /// - /// The voice to use for generating the audio. The voices supported are different for each model. For eg - for canopylabs/orpheus-3b-0.1-ft, one of the voices supported is tara, for hexgrad/Kokoro-82M, one of the voices supported is af_alloy and for cartesia/sonic, one of the voices supported is "friendly sidekick". You can view the voices supported for each model using the /v1/voices endpoint sending the model name as the query parameter. [View all supported voices here](https://docs.together.ai/docs/text-to-speech#supported-voices). + /// The voice to use for generating the audio. The voices supported are different for each model. For eg - for canopylabs/orpheus-3b-0.1-ft, one of the voices supported is tara, for hexgrad/Kokoro-82M, one of the voices supported is af_alloy and for cartesia/sonic, one of the voices supported is "friendly sidekick". You can view the voices supported for each model using the /v1/voices endpoint sending the model name as the query parameter. [View all supported voices here](https://docs.together.ai/docs/text-to-speech#supported-voices). `hexgrad/Kokoro-82M` additionally supports voice mixing, where two or more voices are combined into a single blended voice by joining their names with `+` (e.g. `af_bella+af_heart`). Optional per-voice weights can be provided in parentheses (e.g. `af_bella(2)+af_heart(1)`). Other models require a single voice name. /// /// /// The format of audio output. Supported formats are mp3, wav, raw if streaming is false. If streaming is true, the only supported format is raw.
/// Default Value: wav /// /// - /// Language of input text.
- /// Default Value: en + /// Language or locale of input text. Accepts ISO 639-1 language codes (e.g., `en`, `fr`, `es`, `zh`) as well as locale codes for region-specific variants. Locale codes must be lowercase (e.g., `zh-hk` for Cantonese).
+ /// Default Value: en
+ /// Example: en /// /// - /// Audio encoding of response
+ /// Audio encoding of response. Only applicable when response_format is raw or pcm. Cartesia models respect this parameter and support all values. Orpheus, Kokoro, and Minimax models always return pcm_s16le regardless of this setting.
/// Default Value: pcm_f32le /// /// - /// Sampling rate to use for the output audio. The default sampling rate for canopylabs/orpheus-3b-0.1-ft and hexgrad/Kokoro-82M is 24000 and for cartesia/sonic is 44100.
+ /// Sampling rate in Hz for the output audio. Cartesia and Minimax models respect this parameter. Orpheus and Kokoro models always output at 24000 Hz regardless of this setting.
/// Default Value: 44100 /// /// @@ -68,6 +71,10 @@ public partial interface IAudioClient /// If true, output is streamed for several characters at a time instead of waiting for the full response. The stream terminates with `data: [DONE]`. If false, return the encoded audio as octet stream
/// Default Value: false /// + /// + /// Additional model-specific parameters that fine-tune speech generation behavior. + /// + /// 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 AudioSpeechAsync( @@ -75,11 +82,13 @@ public partial interface IAudioClient string input, string voice, global::Together.AudioSpeechRequestResponseFormat? responseFormat = default, - global::Together.AudioSpeechRequestLanguage? language = default, + string? language = default, global::Together.AudioSpeechRequestResponseEncoding? responseEncoding = default, int? sampleRate = default, int? bitRate = default, bool? stream = default, + global::Together.AudioSpeechRequestExtraParams? extraParams = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IAudioClient.AudioTranscriptions.g.cs b/src/libs/Together/Generated/Together.IAudioClient.AudioTranscriptions.g.cs index 78dd34e6..562853f9 100644 --- a/src/libs/Together/Generated/Together.IAudioClient.AudioTranscriptions.g.cs +++ b/src/libs/Together/Generated/Together.IAudioClient.AudioTranscriptions.g.cs @@ -9,6 +9,7 @@ public partial interface IAudioClient /// Transcribes audio into text ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -27,13 +28,40 @@ public partial interface IAudioClient global::System.Threading.Tasks.Task AudioTranscriptionsAsync( global::Together.AudioTranscriptionRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create audio transcription request
+ /// Transcribes audio into text + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// file = open("audio.wav", "rb")
+ /// response = client.audio.transcriptions.create(
+ /// model="openai/whisper-large-v3",
+ /// file=file,
+ /// )
+ /// print(response.text) + ///
+ global::System.Threading.Tasks.Task> AudioTranscriptionsAsResponseAsync( + + global::Together.AudioTranscriptionRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create audio transcription request
/// Transcribes audio into text ///
/// - /// Audio file upload or public HTTP/HTTPS URL. Supported formats .wav, .mp3, .m4a, .webm, .flac. + /// Audio file upload or public HTTP/HTTPS URL. Supported formats .wav, .mp3, .m4a, .webm, .flac, .ogg, .opus, .aac. /// /// /// Model to use for transcription
@@ -45,7 +73,7 @@ public partial interface IAudioClient /// Example: en /// /// - /// Optional text to bias decoding. + /// Optional text to bias decoding. Supported only on Whisper-family models (e.g. `openai/whisper-large-v3`). Other STT models (e.g. `nvidia/parakeet-tdt-0.6b-v3`) accept the field for API compatibility but ignore it. /// /// /// The format of the response
@@ -82,6 +110,7 @@ public partial interface IAudioClient /// /// Maximum number of speakers expected in the audio. Used to improve diarization accuracy when the approximate number of speakers is known. /// + /// 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 AudioTranscriptionsAsync( @@ -95,6 +124,7 @@ public partial interface IAudioClient bool? diarize = default, int? minSpeakers = default, int? maxSpeakers = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IAudioClient.AudioTranslations.g.cs b/src/libs/Together/Generated/Together.IAudioClient.AudioTranslations.g.cs index 8ee90fb4..82120db1 100644 --- a/src/libs/Together/Generated/Together.IAudioClient.AudioTranslations.g.cs +++ b/src/libs/Together/Generated/Together.IAudioClient.AudioTranslations.g.cs @@ -9,6 +9,7 @@ public partial interface IAudioClient /// Translates audio into English /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -29,13 +30,42 @@ public partial interface IAudioClient global::System.Threading.Tasks.Task AudioTranslationsAsync( global::Together.AudioTranslationRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create audio translation request
+ /// Translates audio into English + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// file = open("audio.wav", "rb")
+ /// response = client.audio.translations.create(
+ /// model="openai/whisper-large-v3",
+ /// file=file,
+ /// language="es",
+ /// )
+ /// print(response.text) + ///
+ global::System.Threading.Tasks.Task> AudioTranslationsAsResponseAsync( + + global::Together.AudioTranslationRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create audio translation request
/// Translates audio into English ///
/// - /// Audio file upload or public HTTP/HTTPS URL. Supported formats .wav, .mp3, .m4a, .webm, .flac. + /// Audio file upload or public HTTP/HTTPS URL. Supported formats .wav, .mp3, .m4a, .webm, .flac, .ogg, .opus, .aac. /// /// /// Model to use for translation
@@ -47,7 +77,7 @@ public partial interface IAudioClient /// Example: en /// /// - /// Optional text to bias decoding. + /// Optional text to bias decoding. Supported only on Whisper-family models (e.g. `openai/whisper-large-v3`). Other STT models (e.g. `nvidia/parakeet-tdt-0.6b-v3`) accept the field for API compatibility but ignore it. /// /// /// The format of the response
@@ -62,6 +92,7 @@ public partial interface IAudioClient /// Default Value: segment
/// Example: [word, segment] /// + /// 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 AudioTranslationsAsync( @@ -72,6 +103,7 @@ public partial interface IAudioClient global::Together.AudioTranslationRequestResponseFormat? responseFormat = default, float? temperature = default, global::Together.OneOf>? timestampGranularities = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IAudioClient.RealtimeTranscription.g.cs b/src/libs/Together/Generated/Together.IAudioClient.RealtimeTranscription.g.cs index d7365d27..00c0b57d 100644 --- a/src/libs/Together/Generated/Together.IAudioClient.RealtimeTranscription.g.cs +++ b/src/libs/Together/Generated/Together.IAudioClient.RealtimeTranscription.g.cs @@ -19,12 +19,53 @@ public partial interface IAudioClient /// "audio": "<base64_encoded_audio_chunk>"
/// }
/// ```
- /// - `input_audio_buffer.commit`: Signal end of audio stream
+ /// - `input_audio_buffer.commit`: Signal end of audio stream. When VAD is enabled, the server automatically detects speech boundaries and emits `completed` events. When VAD is disabled, you must send `commit` to trigger transcription of the buffered audio.
/// ```json
/// {
/// "type": "input_audio_buffer.commit"
/// }
/// ```
+ /// - `transcription_session.updated`: Update session configuration, including Voice Activity Detection (VAD) parameters. Send this after receiving `session.created`. Can also be sent at any time during the session to change VAD settings.
+ /// ```json
+ /// {
+ /// "type": "transcription_session.updated",
+ /// "session": {
+ /// "turn_detection": {
+ /// "type": "server_vad",
+ /// "threshold": 0.3,
+ /// "min_silence_duration_ms": 500,
+ /// "min_speech_duration_ms": 250,
+ /// "max_speech_duration_s": 5.0,
+ /// "speech_pad_ms": 250
+ /// }
+ /// }
+ /// }
+ /// ```
+ /// To disable VAD entirely (manual commit mode), set `turn_detection` to `null`:
+ /// ```json
+ /// {
+ /// "type": "transcription_session.updated",
+ /// "session": {
+ /// "turn_detection": null
+ /// }
+ /// }
+ /// ```
+ /// **Voice Activity Detection (VAD)**
+ /// VAD controls how the server automatically detects speech segments in the audio stream. When enabled (the default), the server uses Silero VAD to identify speech regions and emits transcription events as each segment completes. When disabled, you must manually call `input_audio_buffer.commit` to trigger transcription.
+ /// VAD can be configured in two ways:
+ /// 1. **Query parameters** at connection time: `turn_detection=server_vad&threshold=0.3&min_silence_duration_ms=500`
+ /// 2. **Session message** after connection: Send `transcription_session.updated` with a `turn_detection` object (see above)
+ /// To disable VAD at connection time, use `turn_detection=none` as a query parameter.
+ /// **VAD Parameters:**
+ /// All parameters are optional. Omitted fields use their defaults.
+ /// | Parameter | Type | Default | Description |
+ /// |-----------|------|---------|-------------|
+ /// | `type` | string | `server_vad` | VAD mode. Use `server_vad` to enable, or set `turn_detection` to `null` to disable. |
+ /// | `threshold` | float | `0.3` | Speech probability threshold (0.0–1.0). Audio frames with probability above this value are classified as speech. Lower values detect more speech but may increase false positives. For low-SNR audio (e.g., 8kHz phone calls), values of 0.01–0.2 may work better. |
+ /// | `min_silence_duration_ms` | int | `500` | Minimum silence duration in milliseconds before ending a speech segment. Higher values merge nearby speech bursts into single segments. For phone calls with mid-sentence pauses, 2000–5000ms prevents over-segmentation. |
+ /// | `min_speech_duration_ms` | int | `250` | Minimum speech segment duration in milliseconds. Segments shorter than this are discarded. Filters out brief noise bursts or clicks. |
+ /// | `max_speech_duration_s` | float | `5.0` | Maximum speech segment duration in seconds. Segments longer than this are force-split at the longest internal silence gap. Useful for continuous speech without natural pauses. |
+ /// | `speech_pad_ms` | int | `250` | Padding in milliseconds added to the start and end of each detected segment. Prevents clipping speech edges. When padding would cause adjacent segments to overlap, the gap is split at the midpoint instead. |
/// **Server Events:**
/// - `session.created`: Initial session confirmation (sent first)
/// ```json
@@ -38,6 +79,22 @@ public partial interface IAudioClient /// }
/// }
/// ```
+ /// - `transcription_session.updated`: Confirms session configuration was applied. Sent in response to a client `transcription_session.updated` message.
+ /// ```json
+ /// {
+ /// "type": "transcription_session.updated",
+ /// "session": {
+ /// "turn_detection": {
+ /// "type": "server_vad",
+ /// "threshold": 0.3,
+ /// "min_silence_duration_ms": 500,
+ /// "min_speech_duration_ms": 250,
+ /// "max_speech_duration_s": 5.0,
+ /// "speech_pad_ms": 250
+ /// }
+ /// }
+ /// }
+ /// ```
/// - `conversation.item.input_audio_transcription.delta`: Partial transcription results
/// ```json
/// {
@@ -76,6 +133,7 @@ public partial interface IAudioClient /// /// Default Value: pcm_s16le_16000 /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -129,6 +187,192 @@ public partial interface IAudioClient global::System.Threading.Tasks.Task RealtimeTranscriptionAsync( string model, global::Together.RealtimeTranscriptionInputAudioFormat inputAudioFormat = global::Together.RealtimeTranscriptionInputAudioFormat.PcmS16le16000, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Real-time audio transcription via WebSocket
+ /// Establishes a WebSocket connection for real-time audio transcription. This endpoint uses WebSocket protocol (wss://api.together.ai/v1/realtime) for bidirectional streaming communication.
+ /// **Connection Setup:**
+ /// - Protocol: WebSocket (wss://)
+ /// - Authentication: Pass API key as Bearer token in Authorization header
+ /// - Parameters: Sent as query parameters (model, input_audio_format)
+ /// **Client Events:**
+ /// - `input_audio_buffer.append`: Send audio chunks as base64-encoded data
+ /// ```json
+ /// {
+ /// "type": "input_audio_buffer.append",
+ /// "audio": "<base64_encoded_audio_chunk>"
+ /// }
+ /// ```
+ /// - `input_audio_buffer.commit`: Signal end of audio stream. When VAD is enabled, the server automatically detects speech boundaries and emits `completed` events. When VAD is disabled, you must send `commit` to trigger transcription of the buffered audio.
+ /// ```json
+ /// {
+ /// "type": "input_audio_buffer.commit"
+ /// }
+ /// ```
+ /// - `transcription_session.updated`: Update session configuration, including Voice Activity Detection (VAD) parameters. Send this after receiving `session.created`. Can also be sent at any time during the session to change VAD settings.
+ /// ```json
+ /// {
+ /// "type": "transcription_session.updated",
+ /// "session": {
+ /// "turn_detection": {
+ /// "type": "server_vad",
+ /// "threshold": 0.3,
+ /// "min_silence_duration_ms": 500,
+ /// "min_speech_duration_ms": 250,
+ /// "max_speech_duration_s": 5.0,
+ /// "speech_pad_ms": 250
+ /// }
+ /// }
+ /// }
+ /// ```
+ /// To disable VAD entirely (manual commit mode), set `turn_detection` to `null`:
+ /// ```json
+ /// {
+ /// "type": "transcription_session.updated",
+ /// "session": {
+ /// "turn_detection": null
+ /// }
+ /// }
+ /// ```
+ /// **Voice Activity Detection (VAD)**
+ /// VAD controls how the server automatically detects speech segments in the audio stream. When enabled (the default), the server uses Silero VAD to identify speech regions and emits transcription events as each segment completes. When disabled, you must manually call `input_audio_buffer.commit` to trigger transcription.
+ /// VAD can be configured in two ways:
+ /// 1. **Query parameters** at connection time: `turn_detection=server_vad&threshold=0.3&min_silence_duration_ms=500`
+ /// 2. **Session message** after connection: Send `transcription_session.updated` with a `turn_detection` object (see above)
+ /// To disable VAD at connection time, use `turn_detection=none` as a query parameter.
+ /// **VAD Parameters:**
+ /// All parameters are optional. Omitted fields use their defaults.
+ /// | Parameter | Type | Default | Description |
+ /// |-----------|------|---------|-------------|
+ /// | `type` | string | `server_vad` | VAD mode. Use `server_vad` to enable, or set `turn_detection` to `null` to disable. |
+ /// | `threshold` | float | `0.3` | Speech probability threshold (0.0–1.0). Audio frames with probability above this value are classified as speech. Lower values detect more speech but may increase false positives. For low-SNR audio (e.g., 8kHz phone calls), values of 0.01–0.2 may work better. |
+ /// | `min_silence_duration_ms` | int | `500` | Minimum silence duration in milliseconds before ending a speech segment. Higher values merge nearby speech bursts into single segments. For phone calls with mid-sentence pauses, 2000–5000ms prevents over-segmentation. |
+ /// | `min_speech_duration_ms` | int | `250` | Minimum speech segment duration in milliseconds. Segments shorter than this are discarded. Filters out brief noise bursts or clicks. |
+ /// | `max_speech_duration_s` | float | `5.0` | Maximum speech segment duration in seconds. Segments longer than this are force-split at the longest internal silence gap. Useful for continuous speech without natural pauses. |
+ /// | `speech_pad_ms` | int | `250` | Padding in milliseconds added to the start and end of each detected segment. Prevents clipping speech edges. When padding would cause adjacent segments to overlap, the gap is split at the midpoint instead. |
+ /// **Server Events:**
+ /// - `session.created`: Initial session confirmation (sent first)
+ /// ```json
+ /// {
+ /// "type": "session.created",
+ /// "session": {
+ /// "id": "session-id",
+ /// "object": "realtime.session",
+ /// "modalities": ["audio"],
+ /// "model": "openai/whisper-large-v3"
+ /// }
+ /// }
+ /// ```
+ /// - `transcription_session.updated`: Confirms session configuration was applied. Sent in response to a client `transcription_session.updated` message.
+ /// ```json
+ /// {
+ /// "type": "transcription_session.updated",
+ /// "session": {
+ /// "turn_detection": {
+ /// "type": "server_vad",
+ /// "threshold": 0.3,
+ /// "min_silence_duration_ms": 500,
+ /// "min_speech_duration_ms": 250,
+ /// "max_speech_duration_s": 5.0,
+ /// "speech_pad_ms": 250
+ /// }
+ /// }
+ /// }
+ /// ```
+ /// - `conversation.item.input_audio_transcription.delta`: Partial transcription results
+ /// ```json
+ /// {
+ /// "type": "conversation.item.input_audio_transcription.delta",
+ /// "delta": "The quick brown"
+ /// }
+ /// ```
+ /// - `conversation.item.input_audio_transcription.completed`: Final transcription
+ /// ```json
+ /// {
+ /// "type": "conversation.item.input_audio_transcription.completed",
+ /// "transcript": "The quick brown fox jumps over the lazy dog"
+ /// }
+ /// ```
+ /// - `conversation.item.input_audio_transcription.failed`: Error occurred
+ /// ```json
+ /// {
+ /// "type": "conversation.item.input_audio_transcription.failed",
+ /// "error": {
+ /// "message": "Error description",
+ /// "type": "invalid_request_error",
+ /// "param": null,
+ /// "code": "invalid_api_key"
+ /// }
+ /// }
+ /// ```
+ /// **Error Codes:**
+ /// - `invalid_api_key`: Invalid API key provided (401)
+ /// - `missing_api_key`: Authorization header missing (401)
+ /// - `model_not_available`: Invalid or unavailable model (400)
+ /// - Unsupported audio format errors (400) + ///
+ /// + /// The Whisper model to use for transcription + /// + /// + /// Default Value: pcm_s16le_16000 + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// import asyncio
+ /// import websockets
+ /// import json
+ /// import base64
+ /// import os
+ /// async def transcribe_audio():
+ /// api_key = os.environ.get("TOGETHER_API_KEY")
+ /// url = "wss://api.together.ai/v1/realtime?model=openai/whisper-large-v3&input_audio_format=pcm_s16le_16000"
+ /// headers = {
+ /// "Authorization": f"Bearer {api_key}"
+ /// }
+ /// async with websockets.connect(url, additional_headers=headers) as ws:
+ /// # Read audio file
+ /// with open("audio.wav", "rb") as f:
+ /// audio_data = f.read()
+ /// # Send audio in chunks with delay to simulate real-time
+ /// chunk_size = 8192
+ /// bytes_per_second = 16000 * 2 # 16kHz * 2 bytes (16-bit)
+ /// delay_per_chunk = chunk_size / bytes_per_second
+ /// for i in range(0, len(audio_data), chunk_size):
+ /// chunk = audio_data[i:i+chunk_size]
+ /// base64_chunk = base64.b64encode(chunk).decode('utf-8')
+ /// await ws.send(json.dumps({
+ /// "type": "input_audio_buffer.append",
+ /// "audio": base64_chunk
+ /// }))
+ /// # Simulate real-time streaming
+ /// if i + chunk_size < len(audio_data):
+ /// await asyncio.sleep(delay_per_chunk)
+ /// # Commit the audio buffer
+ /// await ws.send(json.dumps({
+ /// "type": "input_audio_buffer.commit"
+ /// }))
+ /// # Receive transcription results
+ /// async for message in ws:
+ /// data = json.loads(message)
+ /// if data["type"] == "conversation.item.input_audio_transcription.delta":
+ /// print(f"Partial: {data['delta']}")
+ /// elif data["type"] == "conversation.item.input_audio_transcription.completed":
+ /// print(f"Final: {data['transcript']}")
+ /// break
+ /// elif data["type"] == "conversation.item.input_audio_transcription.failed":
+ /// error = data.get("error", {})
+ /// print(f"Error: {error.get('message')}")
+ /// break
+ /// asyncio.run(transcribe_audio()) + ///
+ global::System.Threading.Tasks.Task RealtimeTranscriptionAsResponseAsync( + string model, + global::Together.RealtimeTranscriptionInputAudioFormat inputAudioFormat = global::Together.RealtimeTranscriptionInputAudioFormat.PcmS16le16000, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IAudioClient.RealtimeTts.g.cs b/src/libs/Together/Generated/Together.IAudioClient.RealtimeTts.g.cs index 467bb575..be8b606d 100644 --- a/src/libs/Together/Generated/Together.IAudioClient.RealtimeTts.g.cs +++ b/src/libs/Together/Generated/Together.IAudioClient.RealtimeTts.g.cs @@ -10,14 +10,17 @@ public partial interface IAudioClient /// **Connection Setup:**
/// - Protocol: WebSocket (wss://)
/// - Authentication: Pass API key as Bearer token in Authorization header
- /// - Parameters: Sent as query parameters (model, voice, max_partial_length)
+ /// - Parameters: Sent as query parameters (model, voice, max_partial_length, language)
/// **Client Events:**
- /// - `tts_session.updated`: Update session parameters like voice
+ /// - `tts_session.updated`: Update session parameters like voice. The `session` object also accepts an `extra_params` field for additional model-specific parameters that fine-tune speech generation behavior, such as `pronunciation_dict` (a list of pronunciation rules for specific characters or symbols, where each entry uses the format `"<source>/<replacement>"` (e.g., `["omg/oh my god"]`) to override how the model pronounces matching tokens).
/// ```json
/// {
/// "type": "tts_session.updated",
/// "session": {
- /// "voice": "tara"
+ /// "voice": "tara",
+ /// "extra_params": {
+ /// "pronunciation_dict": ["omg/oh my god"]
+ /// }
/// }
/// }
/// ```
@@ -95,9 +98,9 @@ public partial interface IAudioClient /// - The partial text exceeds `max_partial_length` characters (default: 250)
/// - The `input_text_buffer.commit` event is received
/// **Audio Format:**
- /// - Format: WAV (PCM s16le)
+ /// - Format: Raw PCM (s16le, mono)
/// - Sample Rate: 24000 Hz
- /// - Encoding: Base64
+ /// - Encoding: Base64 (per delta event)
/// - Delivered via `conversation.item.audio_output.delta` events
/// **Error Codes:**
/// - `invalid_api_key`: Invalid API key provided (401)
@@ -118,6 +121,12 @@ public partial interface IAudioClient /// even without a sentence ending. Helps reduce latency for long text without punctuation.
/// Default Value: 250 /// + /// + /// Language or locale of input text. Accepts ISO 639-1 language codes (e.g., `en`, `fr`, `es`, `zh`) as well as locale codes for region-specific variants. Locale codes must be lowercase (e.g., `zh-hk` for Cantonese). Can also be set via `tts_session.updated` event.
+ /// Default Value: en
+ /// Example: en + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -128,7 +137,7 @@ public partial interface IAudioClient /// import os
/// async def generate_speech():
/// api_key = os.environ.get("TOGETHER_API_KEY")
- /// url = "wss://api.together.ai/v1/audio/speech/websocket?model=hexgrad/Kokoro-82M&voice=tara"
+ /// url = "wss://api.together.ai/v1/audio/speech/websocket?model=hexgrad/Kokoro-82M&voice=af_heart"
/// headers = {
/// "Authorization": f"Bearer {api_key}"
/// }
@@ -136,6 +145,9 @@ public partial interface IAudioClient /// # Wait for session created
/// session_msg = await ws.recv()
/// session_data = json.loads(session_msg)
+ /// if session_data.get("type") != "session.created":
+ /// print(f"Failed to start session: {session_data}")
+ /// return
/// print(f"Session created: {session_data['session']['id']}")
/// # Send text for TTS
/// text_chunks = [
@@ -171,10 +183,10 @@ public partial interface IAudioClient /// error = data.get("error", {})
/// print(f"Error: {error.get('message')}")
/// break
- /// # Save the audio to a file
- /// with open("output.wav", "wb") as f:
+ /// # Save the raw PCM samples to a file
+ /// with open("output.pcm", "wb") as f:
/// f.write(audio_data)
- /// print("Audio saved to output.wav")
+ /// print("Audio saved to output.pcm")
/// # Run send and receive concurrently
/// await asyncio.gather(send_text(), receive_audio())
/// asyncio.run(generate_speech()) @@ -183,6 +195,202 @@ public partial interface IAudioClient global::Together.RealtimeTtsModel? model = default, string? voice = default, int? maxPartialLength = default, + string? language = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Real-time text-to-speech via WebSocket
+ /// Establishes a WebSocket connection for real-time text-to-speech generation. This endpoint uses WebSocket protocol (wss://api.together.ai/v1/audio/speech/websocket) for bidirectional streaming communication.
+ /// **Connection Setup:**
+ /// - Protocol: WebSocket (wss://)
+ /// - Authentication: Pass API key as Bearer token in Authorization header
+ /// - Parameters: Sent as query parameters (model, voice, max_partial_length, language)
+ /// **Client Events:**
+ /// - `tts_session.updated`: Update session parameters like voice. The `session` object also accepts an `extra_params` field for additional model-specific parameters that fine-tune speech generation behavior, such as `pronunciation_dict` (a list of pronunciation rules for specific characters or symbols, where each entry uses the format `"<source>/<replacement>"` (e.g., `["omg/oh my god"]`) to override how the model pronounces matching tokens).
+ /// ```json
+ /// {
+ /// "type": "tts_session.updated",
+ /// "session": {
+ /// "voice": "tara",
+ /// "extra_params": {
+ /// "pronunciation_dict": ["omg/oh my god"]
+ /// }
+ /// }
+ /// }
+ /// ```
+ /// - `input_text_buffer.append`: Send text chunks for TTS generation
+ /// ```json
+ /// {
+ /// "type": "input_text_buffer.append",
+ /// "text": "Hello, this is a test."
+ /// }
+ /// ```
+ /// - `input_text_buffer.clear`: Clear the buffered text
+ /// ```json
+ /// {
+ /// "type": "input_text_buffer.clear"
+ /// }
+ /// ```
+ /// - `input_text_buffer.commit`: Signal end of text input and process remaining text
+ /// ```json
+ /// {
+ /// "type": "input_text_buffer.commit"
+ /// }
+ /// ```
+ /// **Server Events:**
+ /// - `session.created`: Initial session confirmation (sent first)
+ /// ```json
+ /// {
+ /// "event_id": "evt_123456",
+ /// "type": "session.created",
+ /// "session": {
+ /// "id": "session-id",
+ /// "object": "realtime.tts.session",
+ /// "modalities": ["text", "audio"],
+ /// "model": "hexgrad/Kokoro-82M",
+ /// "voice": "tara"
+ /// }
+ /// }
+ /// ```
+ /// - `conversation.item.input_text.received`: Acknowledgment that text was received
+ /// ```json
+ /// {
+ /// "type": "conversation.item.input_text.received",
+ /// "text": "Hello, this is a test."
+ /// }
+ /// ```
+ /// - `conversation.item.audio_output.delta`: Audio chunks as base64-encoded data
+ /// ```json
+ /// {
+ /// "type": "conversation.item.audio_output.delta",
+ /// "item_id": "tts_1",
+ /// "delta": "<base64_encoded_audio_chunk>"
+ /// }
+ /// ```
+ /// - `conversation.item.audio_output.done`: Audio generation complete for an item
+ /// ```json
+ /// {
+ /// "type": "conversation.item.audio_output.done",
+ /// "item_id": "tts_1"
+ /// }
+ /// ```
+ /// - `conversation.item.tts.failed`: Error occurred
+ /// ```json
+ /// {
+ /// "type": "conversation.item.tts.failed",
+ /// "error": {
+ /// "message": "Error description",
+ /// "type": "invalid_request_error",
+ /// "param": null,
+ /// "code": "invalid_api_key"
+ /// }
+ /// }
+ /// ```
+ /// **Text Processing:**
+ /// - Partial text (no sentence ending) is held in buffer until:
+ /// - We believe that the text is complete enough to be processed for TTS generation
+ /// - The partial text exceeds `max_partial_length` characters (default: 250)
+ /// - The `input_text_buffer.commit` event is received
+ /// **Audio Format:**
+ /// - Format: Raw PCM (s16le, mono)
+ /// - Sample Rate: 24000 Hz
+ /// - Encoding: Base64 (per delta event)
+ /// - Delivered via `conversation.item.audio_output.delta` events
+ /// **Error Codes:**
+ /// - `invalid_api_key`: Invalid API key provided (401)
+ /// - `missing_api_key`: Authorization header missing (401)
+ /// - `model_not_available`: Invalid or unavailable model (400)
+ /// - Invalid text format errors (400) + ///
+ /// + /// The TTS model to use for speech generation. Can also be set via `tts_session.updated` event.
+ /// Default Value: hexgrad/Kokoro-82M + /// + /// + /// The voice to use for speech generation. Default is 'tara'.
+ /// Available voices vary by model. Can also be updated via `tts_session.updated` event. + /// + /// + /// Maximum number of characters in partial text before forcing TTS generation
+ /// even without a sentence ending. Helps reduce latency for long text without punctuation.
+ /// Default Value: 250 + /// + /// + /// Language or locale of input text. Accepts ISO 639-1 language codes (e.g., `en`, `fr`, `es`, `zh`) as well as locale codes for region-specific variants. Locale codes must be lowercase (e.g., `zh-hk` for Cantonese). Can also be set via `tts_session.updated` event.
+ /// Default Value: en
+ /// Example: en + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// import asyncio
+ /// import websockets
+ /// import json
+ /// import base64
+ /// import os
+ /// async def generate_speech():
+ /// api_key = os.environ.get("TOGETHER_API_KEY")
+ /// url = "wss://api.together.ai/v1/audio/speech/websocket?model=hexgrad/Kokoro-82M&voice=af_heart"
+ /// headers = {
+ /// "Authorization": f"Bearer {api_key}"
+ /// }
+ /// async with websockets.connect(url, additional_headers=headers) as ws:
+ /// # Wait for session created
+ /// session_msg = await ws.recv()
+ /// session_data = json.loads(session_msg)
+ /// if session_data.get("type") != "session.created":
+ /// print(f"Failed to start session: {session_data}")
+ /// return
+ /// print(f"Session created: {session_data['session']['id']}")
+ /// # Send text for TTS
+ /// text_chunks = [
+ /// "Hello, this is a test.",
+ /// "This is the second sentence.",
+ /// "And this is the final one."
+ /// ]
+ /// async def send_text():
+ /// for chunk in text_chunks:
+ /// await ws.send(json.dumps({
+ /// "type": "input_text_buffer.append",
+ /// "text": chunk
+ /// }))
+ /// await asyncio.sleep(0.5) # Simulate typing
+ /// # Commit to process any remaining text
+ /// await ws.send(json.dumps({
+ /// "type": "input_text_buffer.commit"
+ /// }))
+ /// async def receive_audio():
+ /// audio_data = bytearray()
+ /// async for message in ws:
+ /// data = json.loads(message)
+ /// if data["type"] == "conversation.item.input_text.received":
+ /// print(f"Text received: {data['text']}")
+ /// elif data["type"] == "conversation.item.audio_output.delta":
+ /// # Decode base64 audio chunk
+ /// audio_chunk = base64.b64decode(data['delta'])
+ /// audio_data.extend(audio_chunk)
+ /// print(f"Received audio chunk for item {data['item_id']}")
+ /// elif data["type"] == "conversation.item.audio_output.done":
+ /// print(f"Audio generation complete for item {data['item_id']}")
+ /// elif data["type"] == "conversation.item.tts.failed":
+ /// error = data.get("error", {})
+ /// print(f"Error: {error.get('message')}")
+ /// break
+ /// # Save the raw PCM samples to a file
+ /// with open("output.pcm", "wb") as f:
+ /// f.write(audio_data)
+ /// print("Audio saved to output.pcm")
+ /// # Run send and receive concurrently
+ /// await asyncio.gather(send_text(), receive_audio())
+ /// asyncio.run(generate_speech()) + ///
+ global::System.Threading.Tasks.Task RealtimeTtsAsResponseAsync( + global::Together.RealtimeTtsModel? model = default, + string? voice = default, + int? maxPartialLength = default, + string? language = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IAudioClient.g.cs b/src/libs/Together/Generated/Together.IAudioClient.g.cs index 44ac0980..da79cd0c 100644 --- a/src/libs/Together/Generated/Together.IAudioClient.g.cs +++ b/src/libs/Together/Generated/Together.IAudioClient.g.cs @@ -32,6 +32,11 @@ public partial interface IAudioClient : global::System.IDisposable /// ensuring is populated. /// public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Together.AutoSDKClientOptions Options { get; } + /// /// diff --git a/src/libs/Together/Generated/Together.IBatchesClient.CreateBatches.g.cs b/src/libs/Together/Generated/Together.IBatchesClient.CreateBatches.g.cs index 0b20bf3e..bb32a1c1 100644 --- a/src/libs/Together/Generated/Together.IBatchesClient.CreateBatches.g.cs +++ b/src/libs/Together/Generated/Together.IBatchesClient.CreateBatches.g.cs @@ -9,6 +9,7 @@ public partial interface IBatchesClient /// Create a new batch job with the given input file and endpoint /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -24,13 +25,40 @@ public partial interface IBatchesClient global::System.Threading.Tasks.Task CreateBatchesAsync( global::Together.CreateBatchRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create a batch job
+ /// Create a new batch job with the given input file and endpoint + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// batch = client.batches.create(input_file_id="file_id", endpoint="/v1/chat/completions")
+ /// print(batch.job) + ///
+ global::System.Threading.Tasks.Task> CreateBatchesAsResponseAsync( + + global::Together.CreateBatchRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create a batch job
/// Create a new batch job with the given input file and endpoint ///
/// - /// The endpoint to use for batch processing
+ /// The endpoint to use for batch processing. Each line of the uploaded input file is dispatched against this endpoint.
+ /// - `/v1/chat/completions` — chat completion batches
+ /// - `/v1/audio/transcriptions` — audio transcription batches (e.g. `openai/whisper-large-v3`)
+ /// - `/v1/audio/translations` — audio translation batches
/// Example: /v1/chat/completions /// /// @@ -49,14 +77,16 @@ public partial interface IBatchesClient /// Model to use for processing batch requests
/// Example: Qwen/Qwen3.5-9B /// + /// 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 CreateBatchesAsync( - string endpoint, + global::Together.CreateBatchRequestEndpoint endpoint, string inputFileId, string? completionWindow = default, int? priority = default, string? modelId = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IBatchesClient.CreateBatchesByIdCancel.g.cs b/src/libs/Together/Generated/Together.IBatchesClient.CreateBatchesByIdCancel.g.cs index 88c3e127..6afc023c 100644 --- a/src/libs/Together/Generated/Together.IBatchesClient.CreateBatchesByIdCancel.g.cs +++ b/src/libs/Together/Generated/Together.IBatchesClient.CreateBatchesByIdCancel.g.cs @@ -12,6 +12,7 @@ public partial interface IBatchesClient /// The ID of the batch job to cancel
/// Example: batch_job_abc123def456 /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -26,6 +27,32 @@ public partial interface IBatchesClient /// global::System.Threading.Tasks.Task CreateBatchesByIdCancelAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Cancel a batch job
+ /// Cancel a batch job by ID + ///
+ /// + /// The ID of the batch job to cancel
+ /// Example: batch_job_abc123def456 + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// batch = client.batches.cancel("batch_id")
+ /// print(batch) + ///
+ global::System.Threading.Tasks.Task> CreateBatchesByIdCancelAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IBatchesClient.GetBatches.g.cs b/src/libs/Together/Generated/Together.IBatchesClient.GetBatches.g.cs index 62436b59..917b2371 100644 --- a/src/libs/Together/Generated/Together.IBatchesClient.GetBatches.g.cs +++ b/src/libs/Together/Generated/Together.IBatchesClient.GetBatches.g.cs @@ -8,6 +8,7 @@ public partial interface IBatchesClient /// List batch jobs
/// List all batch jobs for the authenticated user /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -22,6 +23,28 @@ public partial interface IBatchesClient /// print(batch.id) /// global::System.Threading.Tasks.Task> GetBatchesAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// List batch jobs
+ /// List all batch jobs for the authenticated user + ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// batches = client.batches.list()
+ /// for batch in batches:
+ /// print(batch.id) + ///
+ global::System.Threading.Tasks.Task>> GetBatchesAsResponseAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IBatchesClient.GetBatchesById.g.cs b/src/libs/Together/Generated/Together.IBatchesClient.GetBatchesById.g.cs index 5cca244f..2fa371ba 100644 --- a/src/libs/Together/Generated/Together.IBatchesClient.GetBatchesById.g.cs +++ b/src/libs/Together/Generated/Together.IBatchesClient.GetBatchesById.g.cs @@ -12,6 +12,7 @@ public partial interface IBatchesClient /// The ID of the batch job to retrieve
/// Example: batch_job_abc123def456 /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -26,6 +27,32 @@ public partial interface IBatchesClient /// global::System.Threading.Tasks.Task GetBatchesByIdAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get a batch job
+ /// Get details of a batch job by ID + ///
+ /// + /// The ID of the batch job to retrieve
+ /// Example: batch_job_abc123def456 + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// batch = client.batches.retrieve("batch_id")
+ /// print(batch) + ///
+ global::System.Threading.Tasks.Task> GetBatchesByIdAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IBatchesClient.g.cs b/src/libs/Together/Generated/Together.IBatchesClient.g.cs index 47236ac6..542e6ccb 100644 --- a/src/libs/Together/Generated/Together.IBatchesClient.g.cs +++ b/src/libs/Together/Generated/Together.IBatchesClient.g.cs @@ -32,6 +32,11 @@ public partial interface IBatchesClient : global::System.IDisposable /// ensuring is populated. /// public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Together.AutoSDKClientOptions Options { get; } + /// /// diff --git a/src/libs/Together/Generated/Together.IChatClient.ChatCompletions.g.cs b/src/libs/Together/Generated/Together.IChatClient.ChatCompletions.g.cs index 1c540f70..f6797008 100644 --- a/src/libs/Together/Generated/Together.IChatClient.ChatCompletions.g.cs +++ b/src/libs/Together/Generated/Together.IChatClient.ChatCompletions.g.cs @@ -11,6 +11,7 @@ public partial interface IChatClient /// Generate a model response for a given chat conversation. Supports single queries and multi-turn conversations with system, user, and assistant messages. /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -32,6 +33,36 @@ public partial interface IChatClient global::System.Threading.Tasks.Task ChatCompletionsAsync( global::Together.ChatCompletionRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create chat completion
+ /// Generate a model response for a given chat conversation. Supports single queries and multi-turn conversations with system, user, and assistant messages. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.chat.completions.create(
+ /// model="Qwen/Qwen3.5-9B",
+ /// messages=[
+ /// {"role": "system", "content": "You are a helpful assistant."},
+ /// {"role": "user", "content": "What are some fun things to do in New York?"},
+ /// ],
+ /// reasoning={"enabled": False}
+ /// ) + ///
+ global::System.Threading.Tasks.Task> ChatCompletionsAsResponseAsync( + + global::Together.ChatCompletionRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create chat completion
@@ -47,7 +78,7 @@ public partial interface IChatClient /// The maximum number of tokens to generate. /// /// - /// A list of string sequences that will truncate (stop) inference text output. For example, "</s>" will stop generation as soon as the model generates the given token. + /// A list of string sequences that truncate (stop) inference text output. For example, "</s>" stops generation as soon as the model generates the given token. /// /// /// A decimal number from 0-1 that determines the degree of randomness in the response. A temperature less than 1 favors more correctness and is appropriate for question answering or summarization. A value closer to 1 introduces more randomness in the output. @@ -59,17 +90,17 @@ public partial interface IChatClient /// An integer that's used to limit the number of choices for the next predicted word or token. It specifies the maximum number of tokens to consider at each step, based on their probability of occurrence. This technique helps to speed up the generation process and can improve the quality of the generated text by focusing on the most likely options. /// /// - /// Defined the behavior of the API when max_tokens exceed the maximum context length of the model. When set to 'error', API will return 400 with appropriate error message. When set to 'truncate', override the max_tokens with maximum context length of the model.
+ /// Defines the behavior of the API when max_tokens exceed the maximum context length of the model. When set to 'error', the API returns 400 with an appropriate error message. When set to 'truncate', overrides max_tokens with the maximum context length of the model.
/// Default Value: error /// /// /// A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition. /// /// - /// An integer between 0 and 20 of the top k tokens to return log probabilities for at each generation step, instead of just the sampled token. Log probabilities help assess model confidence in token predictions. + /// An integer between 0 and 20 of the top k tokens to return log probabilities for at each generation step, instead of only the sampled token. Log probabilities help assess model confidence in token predictions. /// /// - /// If true, the response will contain the prompt. Can be used with `logprobs` to return prompt logprobs. + /// If true, the response contains the prompt. Can be used with `logprobs` to return prompt logprobs. /// /// /// The number of completions to generate for each prompt. @@ -123,6 +154,7 @@ public partial interface IChatClient /// /// For models that support toggling reasoning functionality, this object can be used to control that functionality. /// + /// 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 ChatCompletionsAsync( @@ -152,6 +184,7 @@ public partial interface IChatClient string? safetyModel = default, global::Together.ChatCompletionRequestReasoningEffort? reasoningEffort = default, global::Together.ChatCompletionRequestReasoning? reasoning = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IChatClient.ChatCompletionsAsStream.g.cs b/src/libs/Together/Generated/Together.IChatClient.ChatCompletionsAsStream.g.cs index a2bcba9e..6c52d4b6 100644 --- a/src/libs/Together/Generated/Together.IChatClient.ChatCompletionsAsStream.g.cs +++ b/src/libs/Together/Generated/Together.IChatClient.ChatCompletionsAsStream.g.cs @@ -11,6 +11,7 @@ public partial interface IChatClient /// Generate a model response for a given chat conversation. Supports single queries and multi-turn conversations with system, user, and assistant messages. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -32,6 +33,7 @@ public partial interface IChatClient global::System.Collections.Generic.IAsyncEnumerable ChatCompletionsAsStreamAsync( global::Together.ChatCompletionRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create chat completion
@@ -47,7 +49,7 @@ public partial interface IChatClient /// The maximum number of tokens to generate. /// /// - /// A list of string sequences that will truncate (stop) inference text output. For example, "</s>" will stop generation as soon as the model generates the given token. + /// A list of string sequences that truncate (stop) inference text output. For example, "</s>" stops generation as soon as the model generates the given token. /// /// /// A decimal number from 0-1 that determines the degree of randomness in the response. A temperature less than 1 favors more correctness and is appropriate for question answering or summarization. A value closer to 1 introduces more randomness in the output. @@ -59,17 +61,17 @@ public partial interface IChatClient /// An integer that's used to limit the number of choices for the next predicted word or token. It specifies the maximum number of tokens to consider at each step, based on their probability of occurrence. This technique helps to speed up the generation process and can improve the quality of the generated text by focusing on the most likely options. /// /// - /// Defined the behavior of the API when max_tokens exceed the maximum context length of the model. When set to 'error', API will return 400 with appropriate error message. When set to 'truncate', override the max_tokens with maximum context length of the model.
+ /// Defines the behavior of the API when max_tokens exceed the maximum context length of the model. When set to 'error', the API returns 400 with an appropriate error message. When set to 'truncate', overrides max_tokens with the maximum context length of the model.
/// Default Value: error /// /// /// A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition. /// /// - /// An integer between 0 and 20 of the top k tokens to return log probabilities for at each generation step, instead of just the sampled token. Log probabilities help assess model confidence in token predictions. + /// An integer between 0 and 20 of the top k tokens to return log probabilities for at each generation step, instead of only the sampled token. Log probabilities help assess model confidence in token predictions. /// /// - /// If true, the response will contain the prompt. Can be used with `logprobs` to return prompt logprobs. + /// If true, the response contains the prompt. Can be used with `logprobs` to return prompt logprobs. /// /// /// The number of completions to generate for each prompt. @@ -123,6 +125,7 @@ public partial interface IChatClient /// /// For models that support toggling reasoning functionality, this object can be used to control that functionality. /// + /// 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 ChatCompletionsAsStreamAsync( @@ -152,6 +155,7 @@ public partial interface IChatClient string? safetyModel = default, global::Together.ChatCompletionRequestReasoningEffort? reasoningEffort = default, global::Together.ChatCompletionRequestReasoning? reasoning = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IChatClient.g.cs b/src/libs/Together/Generated/Together.IChatClient.g.cs index abac5853..bf5771ff 100644 --- a/src/libs/Together/Generated/Together.IChatClient.g.cs +++ b/src/libs/Together/Generated/Together.IChatClient.g.cs @@ -32,6 +32,11 @@ public partial interface IChatClient : global::System.IDisposable /// ensuring is populated. ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Together.AutoSDKClientOptions Options { get; } + /// /// diff --git a/src/libs/Together/Generated/Together.ICodeInterpreterClient.SessionsList.g.cs b/src/libs/Together/Generated/Together.ICodeInterpreterClient.SessionsList.g.cs index a9514e5a..9c4f42e9 100644 --- a/src/libs/Together/Generated/Together.ICodeInterpreterClient.SessionsList.g.cs +++ b/src/libs/Together/Generated/Together.ICodeInterpreterClient.SessionsList.g.cs @@ -5,8 +5,10 @@ namespace Together public partial interface ICodeInterpreterClient { /// + /// List active sessions
/// Lists all your currently active sessions. ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -21,6 +23,28 @@ public partial interface ICodeInterpreterClient /// print(session.id) /// global::System.Threading.Tasks.Task SessionsListAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// List active sessions
+ /// Lists all your currently active sessions. + ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.code_interpreter.sessions.list()
+ /// for session in response.data.sessions:
+ /// print(session.id) + ///
+ global::System.Threading.Tasks.Task> SessionsListAsResponseAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.ICodeInterpreterClient.TciExecute.g.cs b/src/libs/Together/Generated/Together.ICodeInterpreterClient.TciExecute.g.cs index f0ef6cd2..699c4677 100644 --- a/src/libs/Together/Generated/Together.ICodeInterpreterClient.TciExecute.g.cs +++ b/src/libs/Together/Generated/Together.ICodeInterpreterClient.TciExecute.g.cs @@ -5,10 +5,12 @@ namespace Together public partial interface ICodeInterpreterClient { /// - /// Executes the given code snippet and returns the output. Without a session_id, a new session will be created to run the code. If you do pass in a valid session_id, the code will be run in that session. This is useful for running multiple code snippets in the same environment, because dependencies and similar things are persisted
+ /// Execute code
+ /// Executes the given code snippet and returns the output. Without a session_id, a new session is created to run the code. If you pass a valid session_id, the code runs in that session. This is useful for running multiple code snippets in the same environment, because dependencies and similar things are persisted
/// between calls to the same session. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -27,9 +29,38 @@ public partial interface ICodeInterpreterClient global::System.Threading.Tasks.Task TciExecuteAsync( global::Together.ExecuteRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// - /// Executes the given code snippet and returns the output. Without a session_id, a new session will be created to run the code. If you do pass in a valid session_id, the code will be run in that session. This is useful for running multiple code snippets in the same environment, because dependencies and similar things are persisted
+ /// Execute code
+ /// Executes the given code snippet and returns the output. Without a session_id, a new session is created to run the code. If you pass a valid session_id, the code runs in that session. This is useful for running multiple code snippets in the same environment, because dependencies and similar things are persisted
+ /// between calls to the same session. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.code_interpreter.execute(
+ /// code="print('Hello world!')",
+ /// language="python",
+ /// )
+ /// print(response.data.outputs[0].data); + ///
+ global::System.Threading.Tasks.Task> TciExecuteAsResponseAsync( + + global::Together.ExecuteRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Execute code
+ /// Executes the given code snippet and returns the output. Without a session_id, a new session is created to run the code. If you pass a valid session_id, the code runs in that session. This is useful for running multiple code snippets in the same environment, because dependencies and similar things are persisted
/// between calls to the same session. ///
/// @@ -37,16 +68,17 @@ public partial interface ICodeInterpreterClient /// Example: print('Hello, world!') /// /// - /// Files to upload to the session. If present, files will be uploaded before executing the given code. + /// Files to upload to the session. If present, files are uploaded before executing the given code. /// /// - /// Programming language for the code to execute. Currently only supports Python, but more will be added.
+ /// Programming language for the code to execute. Currently only supports Python.
/// Default Value: python /// /// - /// Identifier of the current session. Used to make follow-up calls. Requests will return an error if the session does not belong to the caller or has expired.
+ /// Identifier of the current session. Used to make follow-up calls. Returns an error if the session does not belong to the caller or has expired.
/// Example: ses_abcDEF123 /// + /// 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 TciExecuteAsync( @@ -54,6 +86,7 @@ public partial interface ICodeInterpreterClient global::System.Collections.Generic.IList? files = default, global::Together.ExecuteRequestLanguage language = global::Together.ExecuteRequestLanguage.Python, string? sessionId = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.ICodeInterpreterClient.g.cs b/src/libs/Together/Generated/Together.ICodeInterpreterClient.g.cs index fe5dfe84..579acee4 100644 --- a/src/libs/Together/Generated/Together.ICodeInterpreterClient.g.cs +++ b/src/libs/Together/Generated/Together.ICodeInterpreterClient.g.cs @@ -32,6 +32,11 @@ public partial interface ICodeInterpreterClient : global::System.IDisposable /// ensuring is populated. ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Together.AutoSDKClientOptions Options { get; } + /// /// diff --git a/src/libs/Together/Generated/Together.ICompletionClient.Completions.g.cs b/src/libs/Together/Generated/Together.ICompletionClient.Completions.g.cs index 87fbec9a..ca439d93 100644 --- a/src/libs/Together/Generated/Together.ICompletionClient.Completions.g.cs +++ b/src/libs/Together/Generated/Together.ICompletionClient.Completions.g.cs @@ -9,6 +9,7 @@ public partial interface ICompletionClient /// Generate text completions for a given prompt using a language, code, or image model. /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -28,6 +29,34 @@ public partial interface ICompletionClient global::System.Threading.Tasks.Task CompletionsAsync( global::Together.CompletionRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create completion
+ /// Generate text completions for a given prompt using a language, code, or image model. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.completions.create(
+ /// model="Qwen/Qwen3.5-9B",
+ /// prompt="The largest city in France is",
+ /// max_tokens=1
+ /// )
+ /// print(response.choices[0].text) + ///
+ global::System.Threading.Tasks.Task> CompletionsAsResponseAsync( + + global::Together.CompletionRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create completion
@@ -45,7 +74,7 @@ public partial interface ICompletionClient /// The maximum number of tokens to generate. /// /// - /// A list of string sequences that will truncate (stop) inference text output. For example, "</s>" will stop generation as soon as the model generates the given token. + /// A list of string sequences that truncate (stop) inference text output. For example, "</s>" stops generation as soon as the model generates the given token. /// /// /// A decimal number from 0-1 that determines the degree of randomness in the response. A temperature less than 1 favors more correctness and is appropriate for question answering or summarization. A value closer to 1 introduces more randomness in the output. @@ -60,10 +89,10 @@ public partial interface ICompletionClient /// A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition. /// /// - /// An integer between 0 and 20 of the top k tokens to return log probabilities for at each generation step, instead of just the sampled token. Log probabilities help assess model confidence in token predictions. + /// An integer between 0 and 20 of the top k tokens to return log probabilities for at each generation step, instead of only the sampled token. Log probabilities help assess model confidence in token predictions. /// /// - /// If true, the response will contain the prompt. Can be used with `logprobs` to return prompt logprobs. + /// If true, the response contains the prompt. Can be used with `logprobs` to return prompt logprobs. /// /// /// The number of completions to generate for each prompt. @@ -89,6 +118,7 @@ public partial interface ICompletionClient /// Seed value for reproducibility.
/// Example: 42 /// + /// 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 CompletionsAsync( @@ -109,6 +139,7 @@ public partial interface ICompletionClient float? frequencyPenalty = default, global::System.Collections.Generic.Dictionary? logitBias = default, int? seed = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.ICompletionClient.CompletionsAsStream.g.cs b/src/libs/Together/Generated/Together.ICompletionClient.CompletionsAsStream.g.cs index 3d047ad4..3d74feac 100644 --- a/src/libs/Together/Generated/Together.ICompletionClient.CompletionsAsStream.g.cs +++ b/src/libs/Together/Generated/Together.ICompletionClient.CompletionsAsStream.g.cs @@ -9,6 +9,7 @@ public partial interface ICompletionClient /// Generate text completions for a given prompt using a language, code, or image model. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -28,6 +29,7 @@ public partial interface ICompletionClient global::System.Collections.Generic.IAsyncEnumerable CompletionsAsStreamAsync( global::Together.CompletionRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create completion
@@ -45,7 +47,7 @@ public partial interface ICompletionClient /// The maximum number of tokens to generate. /// /// - /// A list of string sequences that will truncate (stop) inference text output. For example, "</s>" will stop generation as soon as the model generates the given token. + /// A list of string sequences that truncate (stop) inference text output. For example, "</s>" stops generation as soon as the model generates the given token. /// /// /// A decimal number from 0-1 that determines the degree of randomness in the response. A temperature less than 1 favors more correctness and is appropriate for question answering or summarization. A value closer to 1 introduces more randomness in the output. @@ -60,10 +62,10 @@ public partial interface ICompletionClient /// A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition. /// /// - /// An integer between 0 and 20 of the top k tokens to return log probabilities for at each generation step, instead of just the sampled token. Log probabilities help assess model confidence in token predictions. + /// An integer between 0 and 20 of the top k tokens to return log probabilities for at each generation step, instead of only the sampled token. Log probabilities help assess model confidence in token predictions. /// /// - /// If true, the response will contain the prompt. Can be used with `logprobs` to return prompt logprobs. + /// If true, the response contains the prompt. Can be used with `logprobs` to return prompt logprobs. /// /// /// The number of completions to generate for each prompt. @@ -89,6 +91,7 @@ public partial interface ICompletionClient /// Seed value for reproducibility.
/// Example: 42 /// + /// 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 CompletionsAsStreamAsync( @@ -109,6 +112,7 @@ public partial interface ICompletionClient float? frequencyPenalty = default, global::System.Collections.Generic.Dictionary? logitBias = default, int? seed = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.ICompletionClient.g.cs b/src/libs/Together/Generated/Together.ICompletionClient.g.cs index 0c7d8685..af6f5447 100644 --- a/src/libs/Together/Generated/Together.ICompletionClient.g.cs +++ b/src/libs/Together/Generated/Together.ICompletionClient.g.cs @@ -32,6 +32,11 @@ public partial interface ICompletionClient : global::System.IDisposable /// ensuring is populated. ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Together.AutoSDKClientOptions Options { get; } + /// /// diff --git a/src/libs/Together/Generated/Together.IDeploymentsClient.CreateDeployments.g.cs b/src/libs/Together/Generated/Together.IDeploymentsClient.CreateDeployments.g.cs index f3a41d3e..786ef2b2 100644 --- a/src/libs/Together/Generated/Together.IDeploymentsClient.CreateDeployments.g.cs +++ b/src/libs/Together/Generated/Together.IDeploymentsClient.CreateDeployments.g.cs @@ -9,6 +9,7 @@ public partial interface IDeploymentsClient /// Create a new deployment with specified configuration /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -17,13 +18,37 @@ public partial interface IDeploymentsClient /// deployment = client.beta.jig.deploy(
/// name="my-deployment",
/// gpu_type="h100-80gb",
- /// image="registry.together.xyz/proj_abcdefg1234567890/my-image:latest"
+ /// image="registry.together.ai/proj_abcdefg1234567890/my-image:latest"
/// )
/// print(deployment) ///
global::System.Threading.Tasks.Task CreateDeploymentsAsync( global::Together.CreateDeploymentRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create a new deployment
+ /// Create a new deployment with specified configuration + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// deployment = client.beta.jig.deploy(
+ /// name="my-deployment",
+ /// gpu_type="h100-80gb",
+ /// image="registry.together.ai/proj_abcdefg1234567890/my-image:latest"
+ /// )
+ /// print(deployment) + ///
+ global::System.Threading.Tasks.Task> CreateDeploymentsAsResponseAsync( + + global::Together.CreateDeploymentRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create a new deployment
@@ -54,13 +79,13 @@ public partial interface IDeploymentsClient /// GPUType specifies the GPU hardware to use (e.g., "h100-80gb"). /// /// - /// HealthCheckPath is the HTTP path for health checks (e.g., "/health"). If set, the platform will check this endpoint to determine container health + /// HealthCheckPath is the HTTP path for health checks (e.g., "/health"). If set, the platform checks this endpoint to determine container health. /// /// /// Image is the container image to deploy from registry.together.ai. /// /// - /// MaxReplicas is the maximum number of container instances that can be scaled up to. If not set, will be set to MinReplicas + /// MaxReplicas is the maximum number of container instances. Defaults to MinReplicas if not set. /// /// /// Memory is the amount of RAM to allocate per container instance in GiB (e.g., 0.5 = 512MiB) @@ -83,9 +108,11 @@ public partial interface IDeploymentsClient /// /// Volumes is a list of volume mounts to attach to the container. Each mount must reference an existing volume by name /// + /// 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 CreateDeploymentsAsync( + global::Together.CreateDeploymentRequestGpuType gpuType, string image, string name, global::System.Collections.Generic.IList? args = default, @@ -95,7 +122,6 @@ public partial interface IDeploymentsClient string? description = default, global::System.Collections.Generic.IList? environmentVariables = default, int? gpuCount = default, - global::Together.CreateDeploymentRequestGpuType gpuType = default, string? healthCheckPath = default, int? maxReplicas = default, double? memory = default, @@ -104,6 +130,7 @@ public partial interface IDeploymentsClient int? storage = default, int? terminationGracePeriodSeconds = default, global::System.Collections.Generic.IList? volumes = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IDeploymentsClient.DeleteDeploymentsById.g.cs b/src/libs/Together/Generated/Together.IDeploymentsClient.DeleteDeploymentsById.g.cs index a50e7181..0cbe2631 100644 --- a/src/libs/Together/Generated/Together.IDeploymentsClient.DeleteDeploymentsById.g.cs +++ b/src/libs/Together/Generated/Together.IDeploymentsClient.DeleteDeploymentsById.g.cs @@ -11,6 +11,7 @@ public partial interface IDeploymentsClient /// /// Deployment ID or name /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -21,6 +22,27 @@ public partial interface IDeploymentsClient /// global::System.Threading.Tasks.Task DeleteDeploymentsByIdAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Delete a deployment
+ /// Delete an existing deployment + ///
+ /// + /// Deployment ID or name + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// deployment = client.beta.jig.destroy("my-deployment")
+ /// print(deployment) + ///
+ global::System.Threading.Tasks.Task> DeleteDeploymentsByIdAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IDeploymentsClient.EditDeploymentsById.g.cs b/src/libs/Together/Generated/Together.IDeploymentsClient.EditDeploymentsById.g.cs index 60a2a798..8eb28198 100644 --- a/src/libs/Together/Generated/Together.IDeploymentsClient.EditDeploymentsById.g.cs +++ b/src/libs/Together/Generated/Together.IDeploymentsClient.EditDeploymentsById.g.cs @@ -12,6 +12,7 @@ public partial interface IDeploymentsClient /// Deployment ID or name /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -24,6 +25,30 @@ public partial interface IDeploymentsClient string id, global::Together.UpdateDeploymentRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Update a deployment
+ /// Update an existing deployment configuration + ///
+ /// + /// Deployment ID or name + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// deployment = client.beta.jig.update("my-deployment", gpu_count=2)
+ /// print(deployment) + ///
+ global::System.Threading.Tasks.Task> EditDeploymentsByIdAsResponseAsync( + string id, + + global::Together.UpdateDeploymentRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update a deployment
@@ -48,7 +73,7 @@ public partial interface IDeploymentsClient /// Description is an optional human-readable description of your deployment /// /// - /// EnvironmentVariables is a list of environment variables to set in the container. This will replace all existing environment variables + /// EnvironmentVariables is a list of environment variables to set in the container. Replaces all existing environment variables. /// /// /// GPUCount is the number of GPUs to allocate per container instance @@ -84,8 +109,9 @@ public partial interface IDeploymentsClient /// TerminationGracePeriodSeconds is the time in seconds to wait for graceful shutdown before forcefully terminating the replica /// /// - /// Volumes is a list of volume mounts to attach to the container. This will replace all existing volumes + /// Volumes is a list of volume mounts to attach to the container. Replaces all existing volumes. /// + /// 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 EditDeploymentsByIdAsync( @@ -108,6 +134,7 @@ public partial interface IDeploymentsClient int? storage = default, int? terminationGracePeriodSeconds = default, global::System.Collections.Generic.IList? volumes = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IDeploymentsClient.GetDeployments.g.cs b/src/libs/Together/Generated/Together.IDeploymentsClient.GetDeployments.g.cs index 6e825b54..3c8e1847 100644 --- a/src/libs/Together/Generated/Together.IDeploymentsClient.GetDeployments.g.cs +++ b/src/libs/Together/Generated/Together.IDeploymentsClient.GetDeployments.g.cs @@ -8,6 +8,7 @@ public partial interface IDeploymentsClient /// Get the list of deployments
/// Get a list of all deployments in your project ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -17,6 +18,23 @@ public partial interface IDeploymentsClient /// print(deployments) /// global::System.Threading.Tasks.Task GetDeploymentsAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get the list of deployments
+ /// Get a list of all deployments in your project + ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// deployments = client.beta.jig.list()
+ /// print(deployments) + ///
+ global::System.Threading.Tasks.Task> GetDeploymentsAsResponseAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IDeploymentsClient.GetDeploymentsById.g.cs b/src/libs/Together/Generated/Together.IDeploymentsClient.GetDeploymentsById.g.cs index 595643ab..f982ca4b 100644 --- a/src/libs/Together/Generated/Together.IDeploymentsClient.GetDeploymentsById.g.cs +++ b/src/libs/Together/Generated/Together.IDeploymentsClient.GetDeploymentsById.g.cs @@ -11,6 +11,7 @@ public partial interface IDeploymentsClient /// /// Deployment ID or name /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -21,6 +22,27 @@ public partial interface IDeploymentsClient /// global::System.Threading.Tasks.Task GetDeploymentsByIdAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get a deployment by ID or name
+ /// Retrieve details of a specific deployment by its ID or name + ///
+ /// + /// Deployment ID or name + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// deployment = client.beta.jig.retrieve("my-deployment")
+ /// print(deployment) + ///
+ global::System.Threading.Tasks.Task> GetDeploymentsByIdAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IDeploymentsClient.GetDeploymentsByIdLogs.g.cs b/src/libs/Together/Generated/Together.IDeploymentsClient.GetDeploymentsByIdLogs.g.cs index 23743adb..249b2c67 100644 --- a/src/libs/Together/Generated/Together.IDeploymentsClient.GetDeploymentsByIdLogs.g.cs +++ b/src/libs/Together/Generated/Together.IDeploymentsClient.GetDeploymentsByIdLogs.g.cs @@ -14,6 +14,7 @@ public partial interface IDeploymentsClient /// /// Replica ID to filter logs /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -25,6 +26,31 @@ public partial interface IDeploymentsClient global::System.Threading.Tasks.Task GetDeploymentsByIdLogsAsync( string id, string? replicaId = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get logs for a deployment
+ /// Retrieve logs from a deployment, optionally filtered by replica ID. + ///
+ /// + /// Deployment ID or name + /// + /// + /// Replica ID to filter logs + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// deployment = client.beta.jig.logs("my-deployment")
+ /// print(deployment) + ///
+ global::System.Threading.Tasks.Task> GetDeploymentsByIdLogsAsResponseAsync( + string id, + string? replicaId = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IDeploymentsClient.g.cs b/src/libs/Together/Generated/Together.IDeploymentsClient.g.cs index 15d19410..9c01c1c7 100644 --- a/src/libs/Together/Generated/Together.IDeploymentsClient.g.cs +++ b/src/libs/Together/Generated/Together.IDeploymentsClient.g.cs @@ -32,6 +32,11 @@ public partial interface IDeploymentsClient : global::System.IDisposable /// ensuring is populated. ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Together.AutoSDKClientOptions Options { get; } + /// /// diff --git a/src/libs/Together/Generated/Together.IDeploymentsStorageClient.GetDeploymentsStorageByFilename.g.cs b/src/libs/Together/Generated/Together.IDeploymentsStorageClient.GetDeploymentsStorageByFilename.g.cs index 157e263f..46046699 100644 --- a/src/libs/Together/Generated/Together.IDeploymentsStorageClient.GetDeploymentsStorageByFilename.g.cs +++ b/src/libs/Together/Generated/Together.IDeploymentsStorageClient.GetDeploymentsStorageByFilename.g.cs @@ -11,10 +11,26 @@ public partial interface IDeploymentsStorageClient /// /// Filename /// + /// 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 GetDeploymentsStorageByFilenameAsync( string filename, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Download a file
+ /// Download a file by redirecting to a signed URL + ///
+ /// + /// Filename + /// + /// 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 GetDeploymentsStorageByFilenameAsResponseAsync( + string filename, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IDeploymentsStorageClient.g.cs b/src/libs/Together/Generated/Together.IDeploymentsStorageClient.g.cs index 60ba240a..bfe1a15a 100644 --- a/src/libs/Together/Generated/Together.IDeploymentsStorageClient.g.cs +++ b/src/libs/Together/Generated/Together.IDeploymentsStorageClient.g.cs @@ -32,6 +32,11 @@ public partial interface IDeploymentsStorageClient : global::System.IDisposable /// ensuring is populated. ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Together.AutoSDKClientOptions Options { get; } + /// /// diff --git a/src/libs/Together/Generated/Together.IDeploymentsVolumesClient.CreateDeploymentsStorageVolumes.g.cs b/src/libs/Together/Generated/Together.IDeploymentsVolumesClient.CreateDeploymentsStorageVolumes.g.cs index 134261ea..7262b91d 100644 --- a/src/libs/Together/Generated/Together.IDeploymentsVolumesClient.CreateDeploymentsStorageVolumes.g.cs +++ b/src/libs/Together/Generated/Together.IDeploymentsVolumesClient.CreateDeploymentsStorageVolumes.g.cs @@ -9,6 +9,7 @@ public partial interface IDeploymentsVolumesClient /// Create a new volume to preload files in deployments /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -20,6 +21,26 @@ public partial interface IDeploymentsVolumesClient global::System.Threading.Tasks.Task CreateDeploymentsStorageVolumesAsync( global::Together.CreateVolumeRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create a new volume
+ /// Create a new volume to preload files in deployments + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// volumes = client.beta.jig.volumes.create(name="my-volume")
+ /// print(volumes) + ///
+ global::System.Threading.Tasks.Task> CreateDeploymentsStorageVolumesAsResponseAsync( + + global::Together.CreateVolumeRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create a new volume
@@ -34,12 +55,14 @@ public partial interface IDeploymentsVolumesClient /// /// Type is the volume type (currently only "readOnly" is supported) /// + /// 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 CreateDeploymentsStorageVolumesAsync( global::Together.VolumeContentRequest content, string name, global::Together.VolumeType type = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IDeploymentsVolumesClient.GetDeploymentsStorageVolumes.g.cs b/src/libs/Together/Generated/Together.IDeploymentsVolumesClient.GetDeploymentsStorageVolumes.g.cs index 85e188fe..d346c9a7 100644 --- a/src/libs/Together/Generated/Together.IDeploymentsVolumesClient.GetDeploymentsStorageVolumes.g.cs +++ b/src/libs/Together/Generated/Together.IDeploymentsVolumesClient.GetDeploymentsStorageVolumes.g.cs @@ -8,6 +8,7 @@ public partial interface IDeploymentsVolumesClient /// Get the list of project volumes
/// Retrieve all volumes in your project ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -17,6 +18,23 @@ public partial interface IDeploymentsVolumesClient /// print(volumes) /// global::System.Threading.Tasks.Task GetDeploymentsStorageVolumesAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get the list of project volumes
+ /// Retrieve all volumes in your project + ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// volumes = client.beta.jig.storage.volumes.list()
+ /// print(volumes) + ///
+ global::System.Threading.Tasks.Task> GetDeploymentsStorageVolumesAsResponseAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IDeploymentsVolumesClient.g.cs b/src/libs/Together/Generated/Together.IDeploymentsVolumesClient.g.cs index 49021d43..b9cc47a9 100644 --- a/src/libs/Together/Generated/Together.IDeploymentsVolumesClient.g.cs +++ b/src/libs/Together/Generated/Together.IDeploymentsVolumesClient.g.cs @@ -32,6 +32,11 @@ public partial interface IDeploymentsVolumesClient : global::System.IDisposable /// ensuring is populated. /// public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Together.AutoSDKClientOptions Options { get; } + /// /// diff --git a/src/libs/Together/Generated/Together.IEmbeddingsClient.Embeddings.g.cs b/src/libs/Together/Generated/Together.IEmbeddingsClient.Embeddings.g.cs index 41ff12ea..13b794ec 100644 --- a/src/libs/Together/Generated/Together.IEmbeddingsClient.Embeddings.g.cs +++ b/src/libs/Together/Generated/Together.IEmbeddingsClient.Embeddings.g.cs @@ -9,6 +9,7 @@ public partial interface IEmbeddingsClient /// Generate vector embeddings for one or more text inputs. Returns numerical arrays representing semantic meaning, useful for search, classification, and retrieval. /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -27,6 +28,33 @@ public partial interface IEmbeddingsClient global::System.Threading.Tasks.Task EmbeddingsAsync( global::Together.EmbeddingsRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create embedding
+ /// Generate vector embeddings for one or more text inputs. Returns numerical arrays representing semantic meaning, useful for search, classification, and retrieval. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.embeddings.create(
+ /// model="BAAI/bge-large-en-v1.5",
+ /// input="New York City",
+ /// )
+ /// print(response.data[0].embedding) + ///
+ global::System.Threading.Tasks.Task> EmbeddingsAsResponseAsync( + + global::Together.EmbeddingsRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create embedding
@@ -39,11 +67,13 @@ public partial interface IEmbeddingsClient /// /// Example: Our solar system orbits the Milky Way galaxy at about 515,000 mph /// + /// 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 EmbeddingsAsync( global::Together.AnyOf model, global::Together.OneOf> input, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IEmbeddingsClient.g.cs b/src/libs/Together/Generated/Together.IEmbeddingsClient.g.cs index 02a892e2..d2bc410c 100644 --- a/src/libs/Together/Generated/Together.IEmbeddingsClient.g.cs +++ b/src/libs/Together/Generated/Together.IEmbeddingsClient.g.cs @@ -32,6 +32,11 @@ public partial interface IEmbeddingsClient : global::System.IDisposable /// ensuring is populated. ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Together.AutoSDKClientOptions Options { get; } + /// /// diff --git a/src/libs/Together/Generated/Together.IEndpoints2Client.AvailabilityZones.g.cs b/src/libs/Together/Generated/Together.IEndpoints2Client.AvailabilityZones.g.cs index 1a66720c..a21e8282 100644 --- a/src/libs/Together/Generated/Together.IEndpoints2Client.AvailabilityZones.g.cs +++ b/src/libs/Together/Generated/Together.IEndpoints2Client.AvailabilityZones.g.cs @@ -5,9 +5,10 @@ namespace Together public partial interface IEndpoints2Client { /// - /// List all available availability zones.
+ /// List all available availability zones
/// List all available availability zones. ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -20,6 +21,26 @@ public partial interface IEndpoints2Client /// print(response.avzones) /// global::System.Threading.Tasks.Task AvailabilityZonesAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// List all available availability zones
+ /// List all available availability zones. + ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.endpoints.list_avzones()
+ /// print(response.avzones) + ///
+ global::System.Threading.Tasks.Task> AvailabilityZonesAsResponseAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IEndpoints2Client.g.cs b/src/libs/Together/Generated/Together.IEndpoints2Client.g.cs index 774e4832..f87c4c92 100644 --- a/src/libs/Together/Generated/Together.IEndpoints2Client.g.cs +++ b/src/libs/Together/Generated/Together.IEndpoints2Client.g.cs @@ -32,6 +32,11 @@ public partial interface IEndpoints2Client : global::System.IDisposable /// ensuring is populated. ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Together.AutoSDKClientOptions Options { get; } + /// /// diff --git a/src/libs/Together/Generated/Together.IEndpointsClient.CreateEndpoint.g.cs b/src/libs/Together/Generated/Together.IEndpointsClient.CreateEndpoint.g.cs index b8a4d6c4..319f027c 100644 --- a/src/libs/Together/Generated/Together.IEndpointsClient.CreateEndpoint.g.cs +++ b/src/libs/Together/Generated/Together.IEndpointsClient.CreateEndpoint.g.cs @@ -7,10 +7,11 @@ namespace Together public partial interface IEndpointsClient { /// - /// Create a dedicated endpoint, it will start automatically
- /// Creates a new dedicated endpoint for serving models. The endpoint will automatically start after creation. You can deploy any supported model on hardware configurations that meet the model's requirements. + /// Create a dedicated endpoint
+ /// Creates a new dedicated endpoint for serving models. The endpoint starts automatically after creation. You can deploy any supported model on hardware configurations that meet the model's requirements. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -33,10 +34,41 @@ public partial interface IEndpointsClient global::System.Threading.Tasks.Task CreateEndpointAsync( global::Together.CreateEndpointRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// - /// Create a dedicated endpoint, it will start automatically
- /// Creates a new dedicated endpoint for serving models. The endpoint will automatically start after creation. You can deploy any supported model on hardware configurations that meet the model's requirements. + /// Create a dedicated endpoint
+ /// Creates a new dedicated endpoint for serving models. The endpoint starts automatically after creation. You can deploy any supported model on hardware configurations that meet the model's requirements. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// endpoint = client.endpoints.create(
+ /// model="Qwen/Qwen3.5-9B-FP8",
+ /// hardware="1x_nvidia_a100_80gb_sxm",
+ /// autoscaling={
+ /// "min_replicas": 2,
+ /// "max_replicas": 5,
+ /// }
+ /// )
+ /// print(endpoint.id) + ///
+ global::System.Threading.Tasks.Task> CreateEndpointAsResponseAsync( + + global::Together.CreateEndpointRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create a dedicated endpoint
+ /// Creates a new dedicated endpoint for serving models. The endpoint starts automatically after creation. You can deploy any supported model on hardware configurations that meet the model's requirements. ///
/// /// A human-readable name for the endpoint
@@ -63,12 +95,13 @@ public partial interface IEndpointsClient /// Example: STARTED /// /// - /// The number of minutes of inactivity after which the endpoint will be automatically stopped. Set to null, omit or set to 0 to disable automatic timeout.
+ /// The number of minutes of inactivity after which the endpoint stops automatically. Set to null, omit, or set to 0 to disable automatic timeout.
/// Example: 60 /// /// /// Create the endpoint in a specified availability zone (e.g., us-central-4b) /// + /// 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 CreateEndpointAsync( @@ -80,6 +113,7 @@ public partial interface IEndpointsClient global::Together.CreateEndpointRequestState? state = default, int? inactiveTimeout = default, string? availabilityZone = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IEndpointsClient.DeleteEndpoint.g.cs b/src/libs/Together/Generated/Together.IEndpointsClient.DeleteEndpoint.g.cs index 10b2b70d..b6a79bff 100644 --- a/src/libs/Together/Generated/Together.IEndpointsClient.DeleteEndpoint.g.cs +++ b/src/libs/Together/Generated/Together.IEndpointsClient.DeleteEndpoint.g.cs @@ -12,6 +12,7 @@ public partial interface IEndpointsClient /// The ID of the endpoint to delete
/// Example: endpoint-d23901de-ef8f-44bf-b3e7-de9c1ca8f2d7 /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -26,6 +27,32 @@ public partial interface IEndpointsClient /// global::System.Threading.Tasks.Task DeleteEndpointAsync( string endpointId, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Delete endpoint
+ /// Permanently deletes an endpoint. This action cannot be undone. + ///
+ /// + /// The ID of the endpoint to delete
+ /// Example: endpoint-d23901de-ef8f-44bf-b3e7-de9c1ca8f2d7 + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// endpoint = client.endpoints.delete("endpoint-id")
+ /// print(endpoint) + ///
+ global::System.Threading.Tasks.Task DeleteEndpointAsResponseAsync( + string endpointId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IEndpointsClient.GetEndpoint.g.cs b/src/libs/Together/Generated/Together.IEndpointsClient.GetEndpoint.g.cs index 821457a4..b0d675c4 100644 --- a/src/libs/Together/Generated/Together.IEndpointsClient.GetEndpoint.g.cs +++ b/src/libs/Together/Generated/Together.IEndpointsClient.GetEndpoint.g.cs @@ -12,6 +12,7 @@ public partial interface IEndpointsClient /// The ID of the endpoint to retrieve
/// Example: endpoint-d23901de-ef8f-44bf-b3e7-de9c1ca8f2d7 /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -26,6 +27,32 @@ public partial interface IEndpointsClient /// global::System.Threading.Tasks.Task GetEndpointAsync( string endpointId, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get endpoint by ID
+ /// Retrieves details about a specific endpoint, including its current state, configuration, and scaling settings. + ///
+ /// + /// The ID of the endpoint to retrieve
+ /// Example: endpoint-d23901de-ef8f-44bf-b3e7-de9c1ca8f2d7 + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// endpoint = client.endpoints.retrieve("endpoint-id")
+ /// print(endpoint.id) + ///
+ global::System.Threading.Tasks.Task> GetEndpointAsResponseAsync( + string endpointId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IEndpointsClient.ListEndpoints.g.cs b/src/libs/Together/Generated/Together.IEndpointsClient.ListEndpoints.g.cs index 36826251..c9ee1497 100644 --- a/src/libs/Together/Generated/Together.IEndpointsClient.ListEndpoints.g.cs +++ b/src/libs/Together/Generated/Together.IEndpointsClient.ListEndpoints.g.cs @@ -5,7 +5,7 @@ namespace Together public partial interface IEndpointsClient { /// - /// List all endpoints, can be filtered by type
+ /// List all endpoints
/// Returns a list of all endpoints associated with your account. You can filter the results by type (dedicated or serverless). ///
/// @@ -17,6 +17,7 @@ public partial interface IEndpointsClient /// /// If true, return only endpoints owned by the caller /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -34,6 +35,40 @@ public partial interface IEndpointsClient global::Together.ListEndpointsType? type = default, global::Together.ListEndpointsUsageType? usageType = default, bool? mine = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// List all endpoints
+ /// Returns a list of all endpoints associated with your account. You can filter the results by type (dedicated or serverless). + ///
+ /// + /// Filter endpoints by type + /// + /// + /// Filter endpoints by usage type + /// + /// + /// If true, return only endpoints owned by the caller + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.endpoints.list()
+ /// for endpoint in response.data:
+ /// print(endpoint.id) + ///
+ global::System.Threading.Tasks.Task> ListEndpointsAsResponseAsync( + global::Together.ListEndpointsType? type = default, + global::Together.ListEndpointsUsageType? usageType = default, + bool? mine = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IEndpointsClient.UpdateEndpoint.g.cs b/src/libs/Together/Generated/Together.IEndpointsClient.UpdateEndpoint.g.cs index 2d97403a..8440a087 100644 --- a/src/libs/Together/Generated/Together.IEndpointsClient.UpdateEndpoint.g.cs +++ b/src/libs/Together/Generated/Together.IEndpointsClient.UpdateEndpoint.g.cs @@ -13,6 +13,7 @@ public partial interface IEndpointsClient /// Example: endpoint-d23901de-ef8f-44bf-b3e7-de9c1ca8f2d7 /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -32,6 +33,38 @@ public partial interface IEndpointsClient string endpointId, global::Together.UpdateEndpointRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Update endpoint, this can also be used to start or stop a dedicated endpoint
+ /// Updates an existing endpoint's configuration. You can modify the display name, autoscaling settings, or change the endpoint's state (start/stop). + ///
+ /// + /// The ID of the endpoint to update
+ /// Example: endpoint-d23901de-ef8f-44bf-b3e7-de9c1ca8f2d7 + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// endpoint = client.endpoints.update(
+ /// "endpoint-id",
+ /// state="STOPPED"
+ /// )
+ /// print(endpoint) + ///
+ global::System.Threading.Tasks.Task> UpdateEndpointAsResponseAsync( + string endpointId, + + global::Together.UpdateEndpointRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update endpoint, this can also be used to start or stop a dedicated endpoint
@@ -53,9 +86,10 @@ public partial interface IEndpointsClient /// New autoscaling configuration for the endpoint /// /// - /// The number of minutes of inactivity after which the endpoint will be automatically stopped. Set to 0 to disable automatic timeout.
+ /// The number of minutes of inactivity after which the endpoint stops automatically. Set to 0 to disable automatic timeout.
/// Example: 60 /// + /// 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 UpdateEndpointAsync( @@ -64,6 +98,7 @@ public partial interface IEndpointsClient global::Together.UpdateEndpointRequestState? state = default, global::Together.Autoscaling? autoscaling = default, int? inactiveTimeout = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IEndpointsClient.g.cs b/src/libs/Together/Generated/Together.IEndpointsClient.g.cs index 60334949..c6aafc8a 100644 --- a/src/libs/Together/Generated/Together.IEndpointsClient.g.cs +++ b/src/libs/Together/Generated/Together.IEndpointsClient.g.cs @@ -32,6 +32,11 @@ public partial interface IEndpointsClient : global::System.IDisposable /// ensuring is populated. ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Together.AutoSDKClientOptions Options { get; } + /// /// diff --git a/src/libs/Together/Generated/Together.IEvaluationClient.CreateEvaluationJob.g.cs b/src/libs/Together/Generated/Together.IEvaluationClient.CreateEvaluationJob.g.cs index a1ae5a57..31bf33dc 100644 --- a/src/libs/Together/Generated/Together.IEvaluationClient.CreateEvaluationJob.g.cs +++ b/src/libs/Together/Generated/Together.IEvaluationClient.CreateEvaluationJob.g.cs @@ -8,6 +8,7 @@ public partial interface IEvaluationClient /// Create an evaluation job /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -36,6 +37,42 @@ public partial interface IEvaluationClient global::System.Threading.Tasks.Task CreateEvaluationJobAsync( global::Together.EvaluationTypedRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create an evaluation job + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.evals.create(
+ /// type="classify",
+ /// parameters=ParametersEvaluationClassifyParameters(
+ /// judge=ParametersEvaluationClassifyParametersJudge(
+ /// model="openai/gpt-oss-120b",
+ /// model_source="serverless",
+ /// system_template="You are an expert evaluator...",
+ /// ),
+ /// input_data_file_path="file-abc123",
+ /// labels=["good", "bad"],
+ /// pass_labels=["good"],
+ /// model_to_evaluate="Qwen/Qwen3.5-9B"
+ /// )
+ /// )
+ /// print(response.workflow_id) + ///
+ global::System.Threading.Tasks.Task> CreateEvaluationJobAsResponseAsync( + + global::Together.EvaluationTypedRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create an evaluation job @@ -47,11 +84,13 @@ public partial interface IEvaluationClient /// /// Type-specific parameters for the evaluation /// + /// 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 CreateEvaluationJobAsync( global::Together.EvaluationTypedRequestType type, global::Together.OneOf parameters, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IEvaluationClient.GetAllEvaluationJobs.g.cs b/src/libs/Together/Generated/Together.IEvaluationClient.GetAllEvaluationJobs.g.cs index e3b2b72f..16238a47 100644 --- a/src/libs/Together/Generated/Together.IEvaluationClient.GetAllEvaluationJobs.g.cs +++ b/src/libs/Together/Generated/Together.IEvaluationClient.GetAllEvaluationJobs.g.cs @@ -14,6 +14,7 @@ public partial interface IEvaluationClient /// Limit the number of results
/// Default Value: 10 /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -30,6 +31,36 @@ public partial interface IEvaluationClient global::System.Threading.Tasks.Task> GetAllEvaluationJobsAsync( string? status = default, int? limit = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get all evaluation jobs + /// + /// + /// Filter evaluation jobs by status + /// + /// + /// Limit the number of results
+ /// Default Value: 10 + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.evals.list()
+ /// for job in response:
+ /// print(job.workflow_id) + ///
+ global::System.Threading.Tasks.Task>> GetAllEvaluationJobsAsResponseAsync( + string? status = default, + int? limit = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IEvaluationClient.GetEvaluationJobDetails.g.cs b/src/libs/Together/Generated/Together.IEvaluationClient.GetEvaluationJobDetails.g.cs index 5abdacc1..fa7ac552 100644 --- a/src/libs/Together/Generated/Together.IEvaluationClient.GetEvaluationJobDetails.g.cs +++ b/src/libs/Together/Generated/Together.IEvaluationClient.GetEvaluationJobDetails.g.cs @@ -10,6 +10,7 @@ public partial interface IEvaluationClient /// /// The ID of the evaluation job to retrieve /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -24,6 +25,30 @@ public partial interface IEvaluationClient /// global::System.Threading.Tasks.Task GetEvaluationJobDetailsAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get evaluation job details + /// + /// + /// The ID of the evaluation job to retrieve + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.evals.retrieve('eval_id')
+ /// print(response) + ///
+ global::System.Threading.Tasks.Task> GetEvaluationJobDetailsAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IEvaluationClient.GetEvaluationJobStatusAndResults.g.cs b/src/libs/Together/Generated/Together.IEvaluationClient.GetEvaluationJobStatusAndResults.g.cs index 79220bed..9c0b2806 100644 --- a/src/libs/Together/Generated/Together.IEvaluationClient.GetEvaluationJobStatusAndResults.g.cs +++ b/src/libs/Together/Generated/Together.IEvaluationClient.GetEvaluationJobStatusAndResults.g.cs @@ -10,6 +10,7 @@ public partial interface IEvaluationClient /// /// The ID of the evaluation job to get the status of /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -25,6 +26,31 @@ public partial interface IEvaluationClient /// global::System.Threading.Tasks.Task GetEvaluationJobStatusAndResultsAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get evaluation job status and results + /// + /// + /// The ID of the evaluation job to get the status of + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.evals.status('eval_id')
+ /// print(response.status)
+ /// print(response.results) + ///
+ global::System.Threading.Tasks.Task> GetEvaluationJobStatusAndResultsAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IEvaluationClient.GetModelList.g.cs b/src/libs/Together/Generated/Together.IEvaluationClient.GetModelList.g.cs index 33124c02..43bda01b 100644 --- a/src/libs/Together/Generated/Together.IEvaluationClient.GetModelList.g.cs +++ b/src/libs/Together/Generated/Together.IEvaluationClient.GetModelList.g.cs @@ -11,10 +11,26 @@ public partial interface IEvaluationClient /// Filter models by source
/// Default Value: all /// + /// 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 GetModelListAsync( string? modelSource = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get model list + /// + /// + /// Filter models by source
+ /// Default Value: all + /// + /// 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> GetModelListAsResponseAsync( + string? modelSource = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IEvaluationClient.g.cs b/src/libs/Together/Generated/Together.IEvaluationClient.g.cs index 09dd8889..eb63fd71 100644 --- a/src/libs/Together/Generated/Together.IEvaluationClient.g.cs +++ b/src/libs/Together/Generated/Together.IEvaluationClient.g.cs @@ -32,6 +32,11 @@ public partial interface IEvaluationClient : global::System.IDisposable /// ensuring is populated. ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Together.AutoSDKClientOptions Options { get; } + /// /// diff --git a/src/libs/Together/Generated/Together.IFilesClient.CreateFilesUpload.g.cs b/src/libs/Together/Generated/Together.IFilesClient.CreateFilesUpload.g.cs index fa9dde95..c2be80fb 100644 --- a/src/libs/Together/Generated/Together.IFilesClient.CreateFilesUpload.g.cs +++ b/src/libs/Together/Generated/Together.IFilesClient.CreateFilesUpload.g.cs @@ -9,6 +9,7 @@ public partial interface IFilesClient /// Upload a file with specified purpose, file name, and file type. /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -26,6 +27,32 @@ public partial interface IFilesClient global::System.Threading.Tasks.Task CreateFilesUploadAsync( global::Together.CreateFilesUploadRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Upload a file
+ /// Upload a file with specified purpose, file name, and file type. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// current_dir = os.path.dirname(os.path.abspath(__file__))
+ /// file_path = os.path.join(current_dir, "data.jsonl")
+ /// file = client.files.upload(file=file_path)
+ /// print(file.id) + ///
+ global::System.Threading.Tasks.Task> CreateFilesUploadAsResponseAsync( + + global::Together.CreateFilesUploadRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Upload a file
@@ -47,6 +74,7 @@ public partial interface IFilesClient /// /// The content of the file being uploaded /// + /// 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 CreateFilesUploadAsync( @@ -54,6 +82,92 @@ public partial interface IFilesClient string fileName, byte[] file, global::Together.FileType? fileType = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Upload a file
+ /// Upload a file with specified purpose, file name, and file type. + ///
+ /// + /// The purpose of the file
+ /// Example: fine-tune + /// + /// + /// The name of the file being uploaded
+ /// Example: dataset.csv + /// + /// + /// The type of the file
+ /// Default Value: jsonl
+ /// Example: jsonl + /// + /// + /// The content of the file being uploaded + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// current_dir = os.path.dirname(os.path.abspath(__file__))
+ /// file_path = os.path.join(current_dir, "data.jsonl")
+ /// file = client.files.upload(file=file_path)
+ /// print(file.id) + ///
+ global::System.Threading.Tasks.Task CreateFilesUploadAsync( + global::Together.FilePurpose purpose, + string fileName, + global::System.IO.Stream file, + global::Together.FileType? fileType = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Upload a file
+ /// Upload a file with specified purpose, file name, and file type. + ///
+ /// + /// The purpose of the file
+ /// Example: fine-tune + /// + /// + /// The name of the file being uploaded
+ /// Example: dataset.csv + /// + /// + /// The type of the file
+ /// Default Value: jsonl
+ /// Example: jsonl + /// + /// + /// The content of the file being uploaded + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// current_dir = os.path.dirname(os.path.abspath(__file__))
+ /// file_path = os.path.join(current_dir, "data.jsonl")
+ /// file = client.files.upload(file=file_path)
+ /// print(file.id) + ///
+ global::System.Threading.Tasks.Task> CreateFilesUploadAsResponseAsync( + global::Together.FilePurpose purpose, + string fileName, + global::System.IO.Stream file, + global::Together.FileType? fileType = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IFilesClient.DeleteFilesById.g.cs b/src/libs/Together/Generated/Together.IFilesClient.DeleteFilesById.g.cs index 93815146..1efc65f9 100644 --- a/src/libs/Together/Generated/Together.IFilesClient.DeleteFilesById.g.cs +++ b/src/libs/Together/Generated/Together.IFilesClient.DeleteFilesById.g.cs @@ -11,6 +11,7 @@ public partial interface IFilesClient /// /// The ID of the file to delete /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -25,6 +26,31 @@ public partial interface IFilesClient /// global::System.Threading.Tasks.Task DeleteFilesByIdAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Delete a file
+ /// Delete a previously uploaded data file. + ///
+ /// + /// The ID of the file to delete + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.files.delete(id="file-id")
+ /// print(response) + ///
+ global::System.Threading.Tasks.Task> DeleteFilesByIdAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IFilesClient.GetFiles.g.cs b/src/libs/Together/Generated/Together.IFilesClient.GetFiles.g.cs index 684487fc..fb8b8dad 100644 --- a/src/libs/Together/Generated/Together.IFilesClient.GetFiles.g.cs +++ b/src/libs/Together/Generated/Together.IFilesClient.GetFiles.g.cs @@ -8,6 +8,7 @@ public partial interface IFilesClient /// List all files
/// List the metadata for all uploaded data files. ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -22,6 +23,28 @@ public partial interface IFilesClient /// print(file.id) /// global::System.Threading.Tasks.Task GetFilesAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// List all files
+ /// List the metadata for all uploaded data files. + ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.files.list()
+ /// for file in response.data:
+ /// print(file.id) + ///
+ global::System.Threading.Tasks.Task> GetFilesAsResponseAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IFilesClient.GetFilesById.g.cs b/src/libs/Together/Generated/Together.IFilesClient.GetFilesById.g.cs index c2e85c1f..4fe1ffb5 100644 --- a/src/libs/Together/Generated/Together.IFilesClient.GetFilesById.g.cs +++ b/src/libs/Together/Generated/Together.IFilesClient.GetFilesById.g.cs @@ -11,6 +11,7 @@ public partial interface IFilesClient /// /// The ID of the file to retrieve /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -25,6 +26,31 @@ public partial interface IFilesClient /// global::System.Threading.Tasks.Task GetFilesByIdAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Retrieve file metadata
+ /// Retrieve the metadata for a single uploaded data file. + ///
+ /// + /// The ID of the file to retrieve + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// file = client.files.retrieve(id="file-id")
+ /// print(file) + ///
+ global::System.Threading.Tasks.Task> GetFilesByIdAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IFilesClient.GetFilesByIdContent.g.cs b/src/libs/Together/Generated/Together.IFilesClient.GetFilesByIdContent.g.cs index 954091c3..cf121f2c 100644 --- a/src/libs/Together/Generated/Together.IFilesClient.GetFilesByIdContent.g.cs +++ b/src/libs/Together/Generated/Together.IFilesClient.GetFilesByIdContent.g.cs @@ -11,6 +11,7 @@ public partial interface IFilesClient /// /// The ID of the file to get the content of /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -26,6 +27,57 @@ public partial interface IFilesClient /// global::System.Threading.Tasks.Task GetFilesByIdContentAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get file contents
+ /// Get the contents of a single uploaded data file. + ///
+ /// + /// The ID of the file to get the content of + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// with client.files.with_streaming_response.content(id="file-id") as response:
+ /// for line in response.iter_lines():
+ /// print(line) + ///
+ global::System.Threading.Tasks.Task GetFilesByIdContentAsStreamAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get file contents
+ /// Get the contents of a single uploaded data file. + ///
+ /// + /// The ID of the file to get the content of + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// with client.files.with_streaming_response.content(id="file-id") as response:
+ /// for line in response.iter_lines():
+ /// print(line) + ///
+ global::System.Threading.Tasks.Task> GetFilesByIdContentAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IFilesClient.g.cs b/src/libs/Together/Generated/Together.IFilesClient.g.cs index 629d69e0..af2489ee 100644 --- a/src/libs/Together/Generated/Together.IFilesClient.g.cs +++ b/src/libs/Together/Generated/Together.IFilesClient.g.cs @@ -32,6 +32,11 @@ public partial interface IFilesClient : global::System.IDisposable /// ensuring is populated. ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Together.AutoSDKClientOptions Options { get; } + /// /// diff --git a/src/libs/Together/Generated/Together.IFineTuningClient.CreateFineTunes.g.cs b/src/libs/Together/Generated/Together.IFineTuningClient.CreateFineTunes.g.cs index 65eff1f6..0087f127 100644 --- a/src/libs/Together/Generated/Together.IFineTuningClient.CreateFineTunes.g.cs +++ b/src/libs/Together/Generated/Together.IFineTuningClient.CreateFineTunes.g.cs @@ -11,6 +11,7 @@ public partial interface IFineTuningClient /// Create a fine-tuning job with the provided model and training data. /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -29,6 +30,33 @@ public partial interface IFineTuningClient global::System.Threading.Tasks.Task CreateFineTunesAsync( global::Together.CreateFineTunesRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create job
+ /// Create a fine-tuning job with the provided model and training data. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.fine_tuning.create(
+ /// model="meta-llama/Meta-Llama-3.1-8B-Instruct-Reference",
+ /// training_file="file-id"
+ /// )
+ /// print(response) + ///
+ global::System.Threading.Tasks.Task> CreateFineTunesAsResponseAsync( + + global::Together.CreateFineTunesRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create job
@@ -44,6 +72,9 @@ public partial interface IFineTuningClient /// Whether to use sequence packing for training.
/// Default Value: true /// + /// + /// Maximum sequence length to use for training. If not specified, the maximum allowed for the model and training method will be used. + /// /// /// Name of the base model to run fine-tune job on /// @@ -63,6 +94,10 @@ public partial interface IFineTuningClient /// Number of training examples processed together (larger batches use more memory but may train faster). Defaults to "max". We use training optimizations like packing, so the effective batch size may be different than the value you set.
/// Default Value: max /// + /// + /// Number of steps to accumulate gradients before performing a weight update. Effectively increases the batch size without requiring more memory. For example, with batch_size=4 and gradient_accumulation_steps=8, the effective batch size is 32.
+ /// Default Value: 1 + /// /// /// Controls how quickly the model adapts to new information (too high may cause instability, too low may slow convergence)
/// Default Value: 0.00001 @@ -87,7 +122,7 @@ public partial interface IFineTuningClient /// Random seed for reproducible training. When set, the same seed produces the same run (e.g. data shuffle, init). If omitted or null, the server applies its default seed (e.g. 42). /// /// - /// Suffix that will be added to your fine-tuned model name + /// Suffix to add to your fine-tuned model name. Must be at most 64 characters long. /// /// /// Integration key for tracking experiments and model metrics on W&B platform @@ -96,7 +131,7 @@ public partial interface IFineTuningClient /// The base URL of a dedicated Weights & Biases instance. /// /// - /// The Weights & Biases project for your run. If not specified, will use `together` as the project name. + /// The Weights & Biases project for your run. If not specified, uses `together` as the project name. /// /// /// The Weights & Biases name for your run. @@ -108,12 +143,12 @@ public partial interface IFineTuningClient /// The training method to use. 'sft' for Supervised Fine-Tuning or 'dpo' for Direct Preference Optimization. /// /// - /// The training type to use. If not provided, the job will default to LoRA training type.
+ /// The training type to use. Defaults to LoRA if not provided.
/// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 /// /// /// - /// The checkpoint identifier to continue training from a previous fine-tuning job. Format is `{$JOB_ID}` or `{$OUTPUT_MODEL_NAME}` or `{$JOB_ID}:{$STEP}` or `{$OUTPUT_MODEL_NAME}:{$STEP}`. The step value is optional; without it, the final checkpoint will be used. + /// The checkpoint identifier to continue training from a previous fine-tuning job. Format is `{$JOB_ID}` or `{$OUTPUT_MODEL_NAME}` or `{$JOB_ID}:{$STEP}` or `{$OUTPUT_MODEL_NAME}:{$STEP}`. The step value is optional; without it, uses the final checkpoint. /// /// /// The Hugging Face Hub repo to start training from. Should be as close as possible to the base model (specified by the `model` argument) in terms of architecture and size. @@ -127,6 +162,7 @@ public partial interface IFineTuningClient /// /// The name of the Hugging Face repository to upload the fine-tuned model to. /// + /// 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 CreateFineTunesAsync( @@ -134,10 +170,12 @@ public partial interface IFineTuningClient string model, string? validationFile = default, bool? packing = default, + int? maxSeqLength = default, int? nEpochs = default, int? nCheckpoints = default, int? nEvals = default, global::Together.OneOf? batchSize = default, + int? gradientAccumulationSteps = default, float? learningRate = default, global::Together.LRScheduler? lrScheduler = default, float? warmupRatio = default, @@ -158,6 +196,7 @@ public partial interface IFineTuningClient string? hfModelRevision = default, string? hfApiToken = default, string? hfOutputRepoName = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IFineTuningClient.CreateFineTunesByIdCancel.g.cs b/src/libs/Together/Generated/Together.IFineTuningClient.CreateFineTunesByIdCancel.g.cs index 9370c329..19512be8 100644 --- a/src/libs/Together/Generated/Together.IFineTuningClient.CreateFineTunesByIdCancel.g.cs +++ b/src/libs/Together/Generated/Together.IFineTuningClient.CreateFineTunesByIdCancel.g.cs @@ -11,6 +11,7 @@ public partial interface IFineTuningClient /// /// Fine-tune ID to cancel. A string that starts with `ft-`. /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -25,6 +26,31 @@ public partial interface IFineTuningClient /// global::System.Threading.Tasks.Task CreateFineTunesByIdCancelAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Cancel job
+ /// Cancel a currently running fine-tuning job. Returns a FinetuneResponseTruncated object. + ///
+ /// + /// Fine-tune ID to cancel. A string that starts with `ft-`. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.fine_tuning.cancel(id="ft-id")
+ /// print(response) + ///
+ global::System.Threading.Tasks.Task> CreateFineTunesByIdCancelAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IFineTuningClient.CreateFineTunesEstimatePrice.g.cs b/src/libs/Together/Generated/Together.IFineTuningClient.CreateFineTunesEstimatePrice.g.cs index e9e02e6c..722e71d7 100644 --- a/src/libs/Together/Generated/Together.IFineTuningClient.CreateFineTunesEstimatePrice.g.cs +++ b/src/libs/Together/Generated/Together.IFineTuningClient.CreateFineTunesEstimatePrice.g.cs @@ -9,11 +9,26 @@ public partial interface IFineTuningClient /// Estimate the price of a fine-tuning job. ///
/// + /// 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 CreateFineTunesEstimatePriceAsync( global::Together.CreateFineTunesEstimatePriceRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Estimate price
+ /// Estimate the price of a fine-tuning job. + ///
+ /// + /// 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> CreateFineTunesEstimatePriceAsResponseAsync( + + global::Together.CreateFineTunesEstimatePriceRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Estimate price
@@ -40,12 +55,13 @@ public partial interface IFineTuningClient /// The training method to use. 'sft' for Supervised Fine-Tuning or 'dpo' for Direct Preference Optimization. /// /// - /// The training type to use. If not provided, the job will default to LoRA training type.
+ /// The training type to use. Defaults to LoRA if not provided.
/// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 /// /// - /// The checkpoint identifier to continue training from a previous fine-tuning job. Format is `{$JOB_ID}` or `{$OUTPUT_MODEL_NAME}` or `{$JOB_ID}:{$STEP}` or `{$OUTPUT_MODEL_NAME}:{$STEP}`. The step value is optional; without it, the final checkpoint will be used. + /// The checkpoint identifier to continue training from a previous fine-tuning job. Format is `{$JOB_ID}` or `{$OUTPUT_MODEL_NAME}` or `{$JOB_ID}:{$STEP}` or `{$OUTPUT_MODEL_NAME}:{$STEP}`. The step value is optional; without it, uses the final checkpoint. /// + /// 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 CreateFineTunesEstimatePriceAsync( @@ -57,6 +73,7 @@ public partial interface IFineTuningClient global::Together.OneOf? trainingMethod = default, global::Together.OneOf? trainingType = default, string? fromCheckpoint = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IFineTuningClient.DeleteFineTunesById.g.cs b/src/libs/Together/Generated/Together.IFineTuningClient.DeleteFineTunesById.g.cs index 279a72ae..41cefd61 100644 --- a/src/libs/Together/Generated/Together.IFineTuningClient.DeleteFineTunesById.g.cs +++ b/src/libs/Together/Generated/Together.IFineTuningClient.DeleteFineTunesById.g.cs @@ -15,6 +15,7 @@ public partial interface IFineTuningClient /// Deprecated and unused parameter.
/// Default Value: false /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -30,6 +31,36 @@ public partial interface IFineTuningClient global::System.Threading.Tasks.Task DeleteFineTunesByIdAsync( string id, bool? force = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Delete a fine-tune job
+ /// Delete a fine-tuning job. + ///
+ /// + /// The ID of the fine-tune job to delete + /// + /// + /// Deprecated and unused parameter.
+ /// Default Value: false + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.fine_tuning.delete(id="ft-id")
+ /// print(response) + ///
+ global::System.Threading.Tasks.Task> DeleteFineTunesByIdAsResponseAsync( + string id, + bool? force = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IFineTuningClient.GetFineTunes.g.cs b/src/libs/Together/Generated/Together.IFineTuningClient.GetFineTunes.g.cs index b8889f9b..177abf93 100644 --- a/src/libs/Together/Generated/Together.IFineTuningClient.GetFineTunes.g.cs +++ b/src/libs/Together/Generated/Together.IFineTuningClient.GetFineTunes.g.cs @@ -8,6 +8,7 @@ public partial interface IFineTuningClient /// List all jobs
/// List the metadata for all fine-tuning jobs. Returns a list of FinetuneResponseTruncated objects. ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -22,6 +23,28 @@ public partial interface IFineTuningClient /// print(f"ID: {fine_tune.id}, Status: {fine_tune.status}") /// global::System.Threading.Tasks.Task GetFineTunesAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// List all jobs
+ /// List the metadata for all fine-tuning jobs. Returns a list of FinetuneResponseTruncated objects. + ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.fine_tuning.list()
+ /// for fine_tune in response.data:
+ /// print(f"ID: {fine_tune.id}, Status: {fine_tune.status}") + ///
+ global::System.Threading.Tasks.Task> GetFineTunesAsResponseAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IFineTuningClient.GetFineTunesById.g.cs b/src/libs/Together/Generated/Together.IFineTuningClient.GetFineTunesById.g.cs index 3bfbadeb..ee183959 100644 --- a/src/libs/Together/Generated/Together.IFineTuningClient.GetFineTunesById.g.cs +++ b/src/libs/Together/Generated/Together.IFineTuningClient.GetFineTunesById.g.cs @@ -11,6 +11,7 @@ public partial interface IFineTuningClient /// /// The ID of the job to retrieve /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -25,6 +26,31 @@ public partial interface IFineTuningClient /// global::System.Threading.Tasks.Task GetFineTunesByIdAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// List job
+ /// List the metadata for a single fine-tuning job. + ///
+ /// + /// The ID of the job to retrieve + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// fine_tune = client.fine_tuning.retrieve(id="ft-id")
+ /// print(fine_tune) + ///
+ global::System.Threading.Tasks.Task> GetFineTunesByIdAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IFineTuningClient.GetFineTunesByIdCheckpoints.g.cs b/src/libs/Together/Generated/Together.IFineTuningClient.GetFineTunesByIdCheckpoints.g.cs index ed2400e1..49f541f8 100644 --- a/src/libs/Together/Generated/Together.IFineTuningClient.GetFineTunesByIdCheckpoints.g.cs +++ b/src/libs/Together/Generated/Together.IFineTuningClient.GetFineTunesByIdCheckpoints.g.cs @@ -11,6 +11,7 @@ public partial interface IFineTuningClient /// /// The ID of the fine-tune job to list checkpoints for /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -25,6 +26,31 @@ public partial interface IFineTuningClient /// global::System.Threading.Tasks.Task GetFineTunesByIdCheckpointsAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// List checkpoints
+ /// List the checkpoints for a single fine-tuning job. + ///
+ /// + /// The ID of the fine-tune job to list checkpoints for + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// checkpoints = client.fine_tuning.list_checkpoints(id="ft-id")
+ /// print(checkpoints) + ///
+ global::System.Threading.Tasks.Task> GetFineTunesByIdCheckpointsAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IFineTuningClient.GetFineTunesByIdEvents.g.cs b/src/libs/Together/Generated/Together.IFineTuningClient.GetFineTunesByIdEvents.g.cs index e7bfe2d7..1b699b21 100644 --- a/src/libs/Together/Generated/Together.IFineTuningClient.GetFineTunesByIdEvents.g.cs +++ b/src/libs/Together/Generated/Together.IFineTuningClient.GetFineTunesByIdEvents.g.cs @@ -11,6 +11,7 @@ public partial interface IFineTuningClient /// /// The ID of the fine-tune job to list events for /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -26,6 +27,32 @@ public partial interface IFineTuningClient /// global::System.Threading.Tasks.Task GetFineTunesByIdEventsAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// List job events
+ /// List the events for a single fine-tuning job. + ///
+ /// + /// The ID of the fine-tune job to list events for + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.fine_tuning.list_events(id="ft-id")
+ /// for event in response.data:
+ /// print(event) + ///
+ global::System.Threading.Tasks.Task> GetFineTunesByIdEventsAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IFineTuningClient.GetFineTunesByIdMetrics.g.cs b/src/libs/Together/Generated/Together.IFineTuningClient.GetFineTunesByIdMetrics.g.cs new file mode 100644 index 00000000..24014ef4 --- /dev/null +++ b/src/libs/Together/Generated/Together.IFineTuningClient.GetFineTunesByIdMetrics.g.cs @@ -0,0 +1,64 @@ +#nullable enable + +namespace Together +{ + public partial interface IFineTuningClient + { + /// + /// Get metrics
+ /// Retrieves recorded training metrics for a fine-tuning job in chronological order. All query parameters are optional: omit them to retrieve all metrics. + ///
+ /// + /// Fine-tune job ID. A string that starts with `ft-`. + /// + /// + /// + /// + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// curl -X GET "https://api.together.ai/v1/fine-tunes/ft-id/metrics?global_step_from=0&global_step_to=500" \
+ /// -H "Authorization: Bearer $TOGETHER_API_KEY" + ///
+ global::System.Threading.Tasks.Task GetFineTunesByIdMetricsAsync( + string id, + long? globalStepFrom = default, + long? globalStepTo = default, + global::System.DateTime? loggedAtFrom = default, + global::System.DateTime? loggedAtTo = default, + long? resolution = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get metrics
+ /// Retrieves recorded training metrics for a fine-tuning job in chronological order. All query parameters are optional: omit them to retrieve all metrics. + ///
+ /// + /// Fine-tune job ID. A string that starts with `ft-`. + /// + /// + /// + /// + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// curl -X GET "https://api.together.ai/v1/fine-tunes/ft-id/metrics?global_step_from=0&global_step_to=500" \
+ /// -H "Authorization: Bearer $TOGETHER_API_KEY" + ///
+ global::System.Threading.Tasks.Task> GetFineTunesByIdMetricsAsResponseAsync( + string id, + long? globalStepFrom = default, + long? globalStepTo = default, + global::System.DateTime? loggedAtFrom = default, + global::System.DateTime? loggedAtTo = default, + long? resolution = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + } +} \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IFineTuningClient.GetFineTunesModelsLimits.g.cs b/src/libs/Together/Generated/Together.IFineTuningClient.GetFineTunesModelsLimits.g.cs index b395f775..885a6984 100644 --- a/src/libs/Together/Generated/Together.IFineTuningClient.GetFineTunesModelsLimits.g.cs +++ b/src/libs/Together/Generated/Together.IFineTuningClient.GetFineTunesModelsLimits.g.cs @@ -11,14 +11,34 @@ public partial interface IFineTuningClient /// /// The model name to get limits for. /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// - /// curl "https://api.together.xyz/v1/fine-tunes/models/limits?model_name=meta-llama/Meta-Llama-3.1-8B-Instruct-Reference" \
+ /// curl "https://api.together.ai/v1/fine-tunes/models/limits?model_name=meta-llama/Meta-Llama-3.1-8B-Instruct-Reference" \
/// -H "Authorization: Bearer $TOGETHER_API_KEY" ///
global::System.Threading.Tasks.Task GetFineTunesModelsLimitsAsync( string modelName, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get model limits
+ /// Get model limits for a specific fine-tuning model. + ///
+ /// + /// The model name to get limits for. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// curl "https://api.together.ai/v1/fine-tunes/models/limits?model_name=meta-llama/Meta-Llama-3.1-8B-Instruct-Reference" \
+ /// -H "Authorization: Bearer $TOGETHER_API_KEY" + ///
+ global::System.Threading.Tasks.Task> GetFineTunesModelsLimitsAsResponseAsync( + string modelName, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IFineTuningClient.GetFineTunesModelsSupported.g.cs b/src/libs/Together/Generated/Together.IFineTuningClient.GetFineTunesModelsSupported.g.cs index 707fbefb..0bb0896c 100644 --- a/src/libs/Together/Generated/Together.IFineTuningClient.GetFineTunesModelsSupported.g.cs +++ b/src/libs/Together/Generated/Together.IFineTuningClient.GetFineTunesModelsSupported.g.cs @@ -8,13 +8,29 @@ public partial interface IFineTuningClient /// List supported models
/// List models supported for fine-tuning. /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// - /// curl "https://api.together.xyz/v1/fine-tunes/models/supported" \
+ /// curl "https://api.together.ai/v1/fine-tunes/models/supported" \
/// -H "Authorization: Bearer $TOGETHER_API_KEY" ///
global::System.Threading.Tasks.Task GetFineTunesModelsSupportedAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// List supported models
+ /// List models supported for fine-tuning. + ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// curl "https://api.together.ai/v1/fine-tunes/models/supported" \
+ /// -H "Authorization: Bearer $TOGETHER_API_KEY" + ///
+ global::System.Threading.Tasks.Task> GetFineTunesModelsSupportedAsResponseAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IFineTuningClient.GetFinetuneDownload.g.cs b/src/libs/Together/Generated/Together.IFineTuningClient.GetFinetuneDownload.g.cs index 3c19d759..f23c2373 100644 --- a/src/libs/Together/Generated/Together.IFineTuningClient.GetFinetuneDownload.g.cs +++ b/src/libs/Together/Generated/Together.IFineTuningClient.GetFinetuneDownload.g.cs @@ -17,6 +17,7 @@ public partial interface IFineTuningClient /// /// Specifies checkpoint type to download - `merged` vs `adapter`. This field is required if the checkpoint_step is not set. /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -36,6 +37,77 @@ public partial interface IFineTuningClient string ftId, int? checkpointStep = default, global::Together.GetFinetuneDownloadCheckpoint? checkpoint = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Download model
+ /// Receive a compressed fine-tuned model or checkpoint. + ///
+ /// + /// Fine-tune ID to download. A string that starts with `ft-`. + /// + /// + /// Specifies step number for checkpoint to download. Ignores `checkpoint` value if set. + /// + /// + /// Specifies checkpoint type to download - `merged` vs `adapter`. This field is required if the checkpoint_step is not set. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// # Using `with_streaming_response` gives you control to do what you want with the response.
+ /// stream = client.fine_tuning.with_streaming_response.content(ft_id="ft-id")
+ /// with stream as response:
+ /// for line in response.iter_lines():
+ /// print(line) + ///
+ global::System.Threading.Tasks.Task GetFinetuneDownloadAsStreamAsync( + string ftId, + int? checkpointStep = default, + global::Together.GetFinetuneDownloadCheckpoint? checkpoint = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Download model
+ /// Receive a compressed fine-tuned model or checkpoint. + ///
+ /// + /// Fine-tune ID to download. A string that starts with `ft-`. + /// + /// + /// Specifies step number for checkpoint to download. Ignores `checkpoint` value if set. + /// + /// + /// Specifies checkpoint type to download - `merged` vs `adapter`. This field is required if the checkpoint_step is not set. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// # Using `with_streaming_response` gives you control to do what you want with the response.
+ /// stream = client.fine_tuning.with_streaming_response.content(ft_id="ft-id")
+ /// with stream as response:
+ /// for line in response.iter_lines():
+ /// print(line) + ///
+ global::System.Threading.Tasks.Task> GetFinetuneDownloadAsResponseAsync( + string ftId, + int? checkpointStep = default, + global::Together.GetFinetuneDownloadCheckpoint? checkpoint = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IFineTuningClient.g.cs b/src/libs/Together/Generated/Together.IFineTuningClient.g.cs index fd04bf2a..98ca966e 100644 --- a/src/libs/Together/Generated/Together.IFineTuningClient.g.cs +++ b/src/libs/Together/Generated/Together.IFineTuningClient.g.cs @@ -32,6 +32,11 @@ public partial interface IFineTuningClient : global::System.IDisposable /// ensuring is populated. /// public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Together.AutoSDKClientOptions Options { get; } + /// /// diff --git a/src/libs/Together/Generated/Together.IGPUClusterServiceClient.GPUClusterServiceCreate.g.cs b/src/libs/Together/Generated/Together.IGPUClusterServiceClient.GPUClusterServiceCreate.g.cs index 17c678fa..7d688e90 100644 --- a/src/libs/Together/Generated/Together.IGPUClusterServiceClient.GPUClusterServiceCreate.g.cs +++ b/src/libs/Together/Generated/Together.IGPUClusterServiceClient.GPUClusterServiceCreate.g.cs @@ -5,13 +5,14 @@ namespace Together public partial interface IGPUClusterServiceClient { /// - /// Create GPU Cluster
+ /// Create a GPU cluster
/// Create an Instant Cluster on Together's high-performance GPU clusters.
/// With features like on-demand scaling, long-lived resizable high-bandwidth shared DC-local storage,
/// Kubernetes and Slurm cluster flavors, a REST API, and Terraform support,
/// you can run workloads flexibly without complex infrastructure management. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -30,9 +31,39 @@ public partial interface IGPUClusterServiceClient global::System.Threading.Tasks.Task GPUClusterServiceCreateAsync( global::Together.GPUClusterCreateRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// - /// Create GPU Cluster
+ /// Create a GPU cluster
+ /// Create an Instant Cluster on Together's high-performance GPU clusters.
+ /// With features like on-demand scaling, long-lived resizable high-bandwidth shared DC-local storage,
+ /// Kubernetes and Slurm cluster flavors, a REST API, and Terraform support,
+ /// you can run workloads flexibly without complex infrastructure management. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// response = client.beta.clusters.create(
+ /// cluster_name="my-gpu-cluster",
+ /// region="us-central-8",
+ /// gpu_type="H100_SXM",
+ /// num_gpus=8,
+ /// driver_version="CUDA_12_6_560",
+ /// billint_type="ON_DEMAND",
+ /// )
+ /// print(response.cluster_id) + ///
+ global::System.Threading.Tasks.Task> GPUClusterServiceCreateAsResponseAsync( + + global::Together.GPUClusterCreateRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create a GPU cluster
/// Create an Instant Cluster on Together's high-performance GPU clusters.
/// With features like on-demand scaling, long-lived resizable high-bandwidth shared DC-local storage,
/// Kubernetes and Slurm cluster flavors, a REST API, and Terraform support,
@@ -56,9 +87,6 @@ public partial interface IGPUClusterServiceClient /// /// Duration in days to keep the cluster running. /// - /// - /// NVIDIA driver version to use in the cluster. - /// /// /// Inline configuration to create a shared volume with the cluster creation. /// @@ -67,8 +95,46 @@ public partial interface IGPUClusterServiceClient /// /// /// RESERVED billing types allow you to specify the duration of the cluster reservation via the duration_days field.
- /// ON_DEMAND billing types will give you ownership of the cluster until you delete it. + /// ON_DEMAND billing types will give you ownership of the cluster until you delete it.
+ /// SCHEDULED_CAPACITY billing types allow you to reserve capacity for a scheduled time window. You must specify the reservation_start_time and reservation_end_time with this request. + /// + /// + /// Whether automated GPU node failover should be enabled for this cluster. By default, it is disabled.
+ /// Default Value: false + /// + /// + /// Whether GPU cluster should be auto-scaled based on the workload. By default, it is not auto-scaled.
+ /// Default Value: false + /// + /// + /// Maximum number of GPUs to which the cluster can be auto-scaled up. This field is required if auto_scaled is true. + /// + /// + /// Shared memory size in GiB for Slurm cluster. This field is required if cluster_type is SLURM. + /// + /// + /// ID of the capacity pool to use for the cluster. This field is optional and only applicable if the cluster is created from a capacity pool. + /// + /// + /// Reservation start time of the cluster. This field is required for SCHEDULED billing to specify the reservation start time for the cluster. If not provided, the cluster provisions immediately. + /// + /// + /// Reservation end time of the cluster. This field is required for SCHEDULED billing to specify the reservation end time for the cluster. + /// + /// + /// Whether to install Traefik ingress controller in the cluster. This field is only applicable for Kubernetes clusters and is false by default.
+ /// Default Value: false + /// + /// + /// CUDA version for this cluster. For example, 12.5 + /// + /// + /// Nvidia driver version for this cluster. For example, 550. Only some combination of cuda_version and nvidia_driver_version are supported. + /// + /// + /// Custom Slurm image for Slurm clusters. /// + /// 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 GPUClusterServiceCreateAsync( @@ -76,12 +142,23 @@ public partial interface IGPUClusterServiceClient global::Together.GPUClusterCreateRequestGpuType gpuType, int numGpus, string clusterName, - global::Together.GPUClusterCreateRequestDriverVersion driverVersion, global::Together.GPUClusterCreateRequestBillingType billingType, + string cudaVersion, + string nvidiaDriverVersion, global::Together.GPUClusterCreateRequestClusterType? clusterType = default, int? durationDays = default, global::Together.GPUClustersSharedVolumeCreateRequest? sharedVolume = default, string? volumeId = default, + bool? gpuNodeFailoverEnabled = default, + bool? autoScaled = default, + int? autoScaleMaxGpus = default, + int? slurmShmSizeGib = default, + string? capacityPoolId = default, + global::System.DateTime? reservationStartTime = default, + global::System.DateTime? reservationEndTime = default, + bool? installTraefik = default, + string? slurmImage = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IGPUClusterServiceClient.GPUClusterServiceDelete.g.cs b/src/libs/Together/Generated/Together.IGPUClusterServiceClient.GPUClusterServiceDelete.g.cs index 186126a2..d48718c2 100644 --- a/src/libs/Together/Generated/Together.IGPUClusterServiceClient.GPUClusterServiceDelete.g.cs +++ b/src/libs/Together/Generated/Together.IGPUClusterServiceClient.GPUClusterServiceDelete.g.cs @@ -11,6 +11,7 @@ public partial interface IGPUClusterServiceClient /// /// The ID of the cluster to delete /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -21,6 +22,27 @@ public partial interface IGPUClusterServiceClient /// global::System.Threading.Tasks.Task GPUClusterServiceDeleteAsync( string clusterId, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Delete GPU cluster by cluster ID
+ /// Delete a GPU cluster by cluster ID. + ///
+ /// + /// The ID of the cluster to delete + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// cluster = client.beta.clusters.delete("cluster_id")
+ /// print(cluster) + ///
+ global::System.Threading.Tasks.Task> GPUClusterServiceDeleteAsResponseAsync( + string clusterId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IGPUClusterServiceClient.GPUClusterServiceGet.g.cs b/src/libs/Together/Generated/Together.IGPUClusterServiceClient.GPUClusterServiceGet.g.cs index ba19d670..2a6cc9be 100644 --- a/src/libs/Together/Generated/Together.IGPUClusterServiceClient.GPUClusterServiceGet.g.cs +++ b/src/libs/Together/Generated/Together.IGPUClusterServiceClient.GPUClusterServiceGet.g.cs @@ -11,6 +11,7 @@ public partial interface IGPUClusterServiceClient /// /// The ID of the cluster to retrieve /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -21,6 +22,27 @@ public partial interface IGPUClusterServiceClient /// global::System.Threading.Tasks.Task GPUClusterServiceGetAsync( string clusterId, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get GPU cluster by cluster ID
+ /// Retrieve information about a specific GPU cluster. + ///
+ /// + /// The ID of the cluster to retrieve + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// cluster = client.beta.clusters.retrieve("cluster_id")
+ /// print(cluster) + ///
+ global::System.Threading.Tasks.Task> GPUClusterServiceGetAsResponseAsync( + string clusterId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IGPUClusterServiceClient.GPUClusterServiceList.g.cs b/src/libs/Together/Generated/Together.IGPUClusterServiceClient.GPUClusterServiceList.g.cs index 8ae663a7..31540629 100644 --- a/src/libs/Together/Generated/Together.IGPUClusterServiceClient.GPUClusterServiceList.g.cs +++ b/src/libs/Together/Generated/Together.IGPUClusterServiceClient.GPUClusterServiceList.g.cs @@ -5,9 +5,10 @@ namespace Together public partial interface IGPUClusterServiceClient { /// - /// List all GPU clusters.
+ /// List all GPU clusters
/// List all GPU clusters. ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -20,6 +21,26 @@ public partial interface IGPUClusterServiceClient /// print(response.clusters) /// global::System.Threading.Tasks.Task GPUClusterServiceListAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// List all GPU clusters
+ /// List all GPU clusters. + ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.beta.clusters.list()
+ /// print(response.clusters) + ///
+ global::System.Threading.Tasks.Task> GPUClusterServiceListAsResponseAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IGPUClusterServiceClient.GPUClusterServiceUpdate.g.cs b/src/libs/Together/Generated/Together.IGPUClusterServiceClient.GPUClusterServiceUpdate.g.cs index 2b0cf550..dc2c8a83 100644 --- a/src/libs/Together/Generated/Together.IGPUClusterServiceClient.GPUClusterServiceUpdate.g.cs +++ b/src/libs/Together/Generated/Together.IGPUClusterServiceClient.GPUClusterServiceUpdate.g.cs @@ -5,13 +5,14 @@ namespace Together public partial interface IGPUClusterServiceClient { /// - /// Update a GPU Cluster.
+ /// Update a GPU cluster
/// Update the configuration of an existing GPU cluster. ///
/// /// The ID of the cluster to update /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -24,9 +25,33 @@ public partial interface IGPUClusterServiceClient string clusterId, global::Together.GPUClusterUpdateRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// - /// Update a GPU Cluster.
+ /// Update a GPU cluster
+ /// Update the configuration of an existing GPU cluster. + ///
+ /// + /// The ID of the cluster to update + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// cluster = client.beta.clusters.update("cluster_id", cluster_type="KUBERNETES", num_gpus=24)
+ /// print(cluster) + ///
+ global::System.Threading.Tasks.Task> GPUClusterServiceUpdateAsResponseAsync( + string clusterId, + + global::Together.GPUClusterUpdateRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Update a GPU cluster
/// Update the configuration of an existing GPU cluster. ///
/// @@ -38,12 +63,18 @@ public partial interface IGPUClusterServiceClient /// /// Number of GPUs to allocate in the cluster. This must be multiple of 8. For example, 8, 16 or 24 /// + /// + /// Timestamp at which the cluster should be decommissioned. Only accepted for prepaid clusters. + /// + /// 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 GPUClusterServiceUpdateAsync( string clusterId, global::Together.GPUClusterUpdateRequestClusterType? clusterType = default, int? numGpus = default, + global::System.DateTime? reservationEndTime = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IGPUClusterServiceClient.g.cs b/src/libs/Together/Generated/Together.IGPUClusterServiceClient.g.cs index 4f7985ac..dff63e51 100644 --- a/src/libs/Together/Generated/Together.IGPUClusterServiceClient.g.cs +++ b/src/libs/Together/Generated/Together.IGPUClusterServiceClient.g.cs @@ -32,6 +32,11 @@ public partial interface IGPUClusterServiceClient : global::System.IDisposable /// ensuring is populated. ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Together.AutoSDKClientOptions Options { get; } + /// /// diff --git a/src/libs/Together/Generated/Together.IHardwareClient.ListHardware.g.cs b/src/libs/Together/Generated/Together.IHardwareClient.ListHardware.g.cs index 9e33933b..6f7fd290 100644 --- a/src/libs/Together/Generated/Together.IHardwareClient.ListHardware.g.cs +++ b/src/libs/Together/Generated/Together.IHardwareClient.ListHardware.g.cs @@ -14,6 +14,7 @@ public partial interface IHardwareClient /// [See all of Together AI's dedicated models](https://docs.together.ai/docs/dedicated-models)
/// Example: deepseek-ai/DeepSeek-R1 /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -29,6 +30,35 @@ public partial interface IHardwareClient /// global::System.Threading.Tasks.Task ListHardwareAsync( string? model = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// List available hardware configurations
+ /// Returns a list of available hardware configurations for deploying models. When a model parameter is provided, it returns only hardware configurations compatible with that model, including their current availability status. + ///
+ /// + /// Filter hardware configurations by model compatibility. When provided,
+ /// the response includes availability status for each compatible configuration.
+ /// [See all of Together AI's dedicated models](https://docs.together.ai/docs/dedicated-models)
+ /// Example: deepseek-ai/DeepSeek-R1 + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.endpoints.list_hardware()
+ /// for hardware in response.data:
+ /// print(hardware.id) + ///
+ global::System.Threading.Tasks.Task> ListHardwareAsResponseAsync( + string? model = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IHardwareClient.g.cs b/src/libs/Together/Generated/Together.IHardwareClient.g.cs index 18c2976a..af759c7f 100644 --- a/src/libs/Together/Generated/Together.IHardwareClient.g.cs +++ b/src/libs/Together/Generated/Together.IHardwareClient.g.cs @@ -32,6 +32,11 @@ public partial interface IHardwareClient : global::System.IDisposable /// ensuring is populated. ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Together.AutoSDKClientOptions Options { get; } + /// /// diff --git a/src/libs/Together/Generated/Together.IImagesClient.CreateImagesGenerations.g.cs b/src/libs/Together/Generated/Together.IImagesClient.CreateImagesGenerations.g.cs index 4fdfde42..46d3047a 100644 --- a/src/libs/Together/Generated/Together.IImagesClient.CreateImagesGenerations.g.cs +++ b/src/libs/Together/Generated/Together.IImagesClient.CreateImagesGenerations.g.cs @@ -9,6 +9,7 @@ public partial interface IImagesClient /// Use an image model to generate an image for a given prompt. /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -28,6 +29,34 @@ public partial interface IImagesClient global::System.Threading.Tasks.Task CreateImagesGenerationsAsync( global::Together.CreateImagesGenerationsRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create image
+ /// Use an image model to generate an image for a given prompt. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.images.generate(
+ /// model="black-forest-labs/FLUX.1-schnell",
+ /// steps=4,
+ /// prompt="A cartoon of an astronaut riding a horse on the moon",
+ /// )
+ /// print(response.data[0].url) + ///
+ global::System.Threading.Tasks.Task> CreateImagesGenerationsAsResponseAsync( + + global::Together.CreateImagesGenerationsRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create image
@@ -86,6 +115,7 @@ public partial interface IImagesClient /// /// If true, disables the safety checker for image generation. /// + /// 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 CreateImagesGenerationsAsync( @@ -104,6 +134,7 @@ public partial interface IImagesClient global::System.Collections.Generic.IList? imageLoras = default, global::System.Collections.Generic.IList? referenceImages = default, bool? disableSafetyChecker = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IImagesClient.g.cs b/src/libs/Together/Generated/Together.IImagesClient.g.cs index 8133f1f9..1369fc5a 100644 --- a/src/libs/Together/Generated/Together.IImagesClient.g.cs +++ b/src/libs/Together/Generated/Together.IImagesClient.g.cs @@ -32,6 +32,11 @@ public partial interface IImagesClient : global::System.IDisposable /// ensuring is populated. ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Together.AutoSDKClientOptions Options { get; } + /// /// diff --git a/src/libs/Together/Generated/Together.IJobsClient.GetJob.g.cs b/src/libs/Together/Generated/Together.IJobsClient.GetJob.g.cs index 01e1aaee..a7f6c518 100644 --- a/src/libs/Together/Generated/Together.IJobsClient.GetJob.g.cs +++ b/src/libs/Together/Generated/Together.IJobsClient.GetJob.g.cs @@ -12,10 +12,27 @@ public partial interface IJobsClient /// The ID of the job to retrieve
/// Example: job-a15dad11-8d8e-4007-97c5-a211304de284 /// + /// 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 GetJobAsync( string jobId, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get job status
+ /// Get the status of a specific job + ///
+ /// + /// The ID of the job to retrieve
+ /// Example: job-a15dad11-8d8e-4007-97c5-a211304de284 + /// + /// 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> GetJobAsResponseAsync( + string jobId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IJobsClient.ListJobs.g.cs b/src/libs/Together/Generated/Together.IJobsClient.ListJobs.g.cs index 85d44d4d..2701fd16 100644 --- a/src/libs/Together/Generated/Together.IJobsClient.ListJobs.g.cs +++ b/src/libs/Together/Generated/Together.IJobsClient.ListJobs.g.cs @@ -8,9 +8,21 @@ public partial interface IJobsClient /// List all jobs
/// List all jobs and their statuses ///
+ /// 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 ListJobsAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// List all jobs
+ /// List all jobs and their statuses + ///
+ /// 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> ListJobsAsResponseAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IJobsClient.g.cs b/src/libs/Together/Generated/Together.IJobsClient.g.cs index c0093701..68f6636d 100644 --- a/src/libs/Together/Generated/Together.IJobsClient.g.cs +++ b/src/libs/Together/Generated/Together.IJobsClient.g.cs @@ -32,6 +32,11 @@ public partial interface IJobsClient : global::System.IDisposable /// ensuring is populated. ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Together.AutoSDKClientOptions Options { get; } + /// /// diff --git a/src/libs/Together/Generated/Together.IModelsClient.Models.g.cs b/src/libs/Together/Generated/Together.IModelsClient.Models.g.cs index c4bcd4b5..2c2d48d4 100644 --- a/src/libs/Together/Generated/Together.IModelsClient.Models.g.cs +++ b/src/libs/Together/Generated/Together.IModelsClient.Models.g.cs @@ -11,6 +11,7 @@ public partial interface IModelsClient /// /// Filter models to only return dedicated models /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -26,6 +27,32 @@ public partial interface IModelsClient /// global::System.Threading.Tasks.Task> ModelsAsync( bool? dedicated = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// List all models
+ /// Lists all of Together's open-source models + ///
+ /// + /// Filter models to only return dedicated models + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// models = client.models.list()
+ /// for model in models:
+ /// print(model.id) + ///
+ global::System.Threading.Tasks.Task>> ModelsAsResponseAsync( + bool? dedicated = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IModelsClient.UploadModel.g.cs b/src/libs/Together/Generated/Together.IModelsClient.UploadModel.g.cs index 50575240..20c64182 100644 --- a/src/libs/Together/Generated/Together.IModelsClient.UploadModel.g.cs +++ b/src/libs/Together/Generated/Together.IModelsClient.UploadModel.g.cs @@ -9,6 +9,7 @@ public partial interface IModelsClient /// Upload a custom model or adapter from Hugging Face or S3 ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -27,6 +28,33 @@ public partial interface IModelsClient global::System.Threading.Tasks.Task UploadModelAsync( global::Together.ModelUploadRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Upload a custom model or adapter
+ /// Upload a custom model or adapter from Hugging Face or S3 + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.models.upload(
+ /// model_name="My-Fine-Tuned-Model",
+ /// model_source="https://ml-models.s3.us-west-2.amazonaws.com/models/my-fine-tuned-model.tar.gz",
+ /// )
+ /// print(response.data.job_id) + ///
+ global::System.Threading.Tasks.Task> UploadModelAsResponseAsync( + + global::Together.ModelUploadRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Upload a custom model or adapter
@@ -61,6 +89,7 @@ public partial interface IModelsClient /// The lora pool to use for an adapter if setting it to run against, say, a dedicated pool. Only used for model_type `adapter`.
/// Example: my_username/Qwen2.5-72B-Instruct-lora /// + /// 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 UploadModelAsync( @@ -71,6 +100,7 @@ public partial interface IModelsClient string? description = default, string? baseModel = default, string? loraModel = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IModelsClient.g.cs b/src/libs/Together/Generated/Together.IModelsClient.g.cs index 4b7a9063..b268e4a7 100644 --- a/src/libs/Together/Generated/Together.IModelsClient.g.cs +++ b/src/libs/Together/Generated/Together.IModelsClient.g.cs @@ -32,6 +32,11 @@ public partial interface IModelsClient : global::System.IDisposable /// ensuring is populated. ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Together.AutoSDKClientOptions Options { get; } + /// /// diff --git a/src/libs/Together/Generated/Together.IQueueClient.CancelQueueJob.g.cs b/src/libs/Together/Generated/Together.IQueueClient.CancelQueueJob.g.cs index 4514d591..1726b987 100644 --- a/src/libs/Together/Generated/Together.IQueueClient.CancelQueueJob.g.cs +++ b/src/libs/Together/Generated/Together.IQueueClient.CancelQueueJob.g.cs @@ -12,11 +12,29 @@ public partial interface IQueueClient /// unchanged. /// /// + /// 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 CancelQueueJobAsync( global::Together.QueueCancelRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Cancel a queued job
+ /// Cancel a pending job. Only jobs in pending status can be canceled.
+ /// Running jobs cannot be stopped. Returns the job status after the
+ /// attempt. If the job is not pending, returns 409 with the current status
+ /// unchanged. + ///
+ /// + /// 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> CancelQueueJobAsResponseAsync( + + global::Together.QueueCancelRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Cancel a queued job
@@ -31,11 +49,13 @@ public partial interface IQueueClient /// /// The request ID returned from the submit endpoint /// + /// 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 CancelQueueJobAsync( string model, string requestId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IQueueClient.GetQueueJobStatus.g.cs b/src/libs/Together/Generated/Together.IQueueClient.GetQueueJobStatus.g.cs index 6717fe8b..ddbc5e50 100644 --- a/src/libs/Together/Generated/Together.IQueueClient.GetQueueJobStatus.g.cs +++ b/src/libs/Together/Generated/Together.IQueueClient.GetQueueJobStatus.g.cs @@ -14,11 +14,31 @@ public partial interface IQueueClient /// /// Model name the job was submitted to /// + /// 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 GetQueueJobStatusAsync( string requestId, string model, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get job status
+ /// Poll the current status of a previously submitted job. Provide the request_id and model as query parameters. + ///
+ /// + /// Request ID returned from the submit endpoint + /// + /// + /// Model name the job was submitted to + /// + /// 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> GetQueueJobStatusAsResponseAsync( + string requestId, + string model, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IQueueClient.GetQueueMetrics.g.cs b/src/libs/Together/Generated/Together.IQueueClient.GetQueueMetrics.g.cs index c73fd46e..4a19c1fa 100644 --- a/src/libs/Together/Generated/Together.IQueueClient.GetQueueMetrics.g.cs +++ b/src/libs/Together/Generated/Together.IQueueClient.GetQueueMetrics.g.cs @@ -11,10 +11,26 @@ public partial interface IQueueClient /// /// Model name to get metrics for /// + /// 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 GetQueueMetricsAsync( string model, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get queue metrics
+ /// Get the current queue statistics for a model, including pending and running job counts. + ///
+ /// + /// Model name to get metrics for + /// + /// 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> GetQueueMetricsAsResponseAsync( + string model, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IQueueClient.SubmitQueueJob.g.cs b/src/libs/Together/Generated/Together.IQueueClient.SubmitQueueJob.g.cs index 82edcd58..8a1a04d3 100644 --- a/src/libs/Together/Generated/Together.IQueueClient.SubmitQueueJob.g.cs +++ b/src/libs/Together/Generated/Together.IQueueClient.SubmitQueueJob.g.cs @@ -12,11 +12,29 @@ public partial interface IQueueClient /// or cancel the job. ///
/// + /// 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 SubmitQueueJobAsync( global::Together.QueueJobRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Submit a queued job
+ /// Submit a new job to the queue for asynchronous processing. Jobs are
+ /// processed in strict priority order (higher priority first, FIFO within
+ /// the same priority). Returns a request ID that can be used to poll status
+ /// or cancel the job. + ///
+ /// + /// 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> SubmitQueueJobAsResponseAsync( + + global::Together.QueueJobRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Submit a queued job
@@ -42,6 +60,7 @@ public partial interface IQueueClient /// order (FIFO).
/// Default Value: 0 /// + /// 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 SubmitQueueJobAsync( @@ -49,6 +68,7 @@ public partial interface IQueueClient object payload, object? info = default, int? priority = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IQueueClient.g.cs b/src/libs/Together/Generated/Together.IQueueClient.g.cs index 02163ab1..60f222a7 100644 --- a/src/libs/Together/Generated/Together.IQueueClient.g.cs +++ b/src/libs/Together/Generated/Together.IQueueClient.g.cs @@ -32,6 +32,11 @@ public partial interface IQueueClient : global::System.IDisposable /// ensuring is populated. ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Together.AutoSDKClientOptions Options { get; } + /// /// diff --git a/src/libs/Together/Generated/Together.IRegionServiceClient.RegionServiceList.g.cs b/src/libs/Together/Generated/Together.IRegionServiceClient.RegionServiceList.g.cs index ff962a54..738c7097 100644 --- a/src/libs/Together/Generated/Together.IRegionServiceClient.RegionServiceList.g.cs +++ b/src/libs/Together/Generated/Together.IRegionServiceClient.RegionServiceList.g.cs @@ -7,6 +7,7 @@ public partial interface IRegionServiceClient /// /// List regions and corresponding supported driver versions /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -16,6 +17,22 @@ public partial interface IRegionServiceClient /// print(regions) /// global::System.Threading.Tasks.Task RegionServiceListAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// List regions and corresponding supported driver versions + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// regions = client.beta.clusters.list_regions()
+ /// print(regions) + ///
+ global::System.Threading.Tasks.Task> RegionServiceListAsResponseAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IRegionServiceClient.g.cs b/src/libs/Together/Generated/Together.IRegionServiceClient.g.cs index d77ce287..4f8351ae 100644 --- a/src/libs/Together/Generated/Together.IRegionServiceClient.g.cs +++ b/src/libs/Together/Generated/Together.IRegionServiceClient.g.cs @@ -32,6 +32,11 @@ public partial interface IRegionServiceClient : global::System.IDisposable /// ensuring is populated. ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Together.AutoSDKClientOptions Options { get; } + /// /// diff --git a/src/libs/Together/Generated/Together.IRerankClient.Rerank.g.cs b/src/libs/Together/Generated/Together.IRerankClient.Rerank.g.cs index 5784e820..afe392a4 100644 --- a/src/libs/Together/Generated/Together.IRerankClient.Rerank.g.cs +++ b/src/libs/Together/Generated/Together.IRerankClient.Rerank.g.cs @@ -9,6 +9,7 @@ public partial interface IRerankClient /// Rerank a list of documents by relevance to a query. Returns a relevance score and ordering index for each document. /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -49,6 +50,55 @@ public partial interface IRerankClient global::System.Threading.Tasks.Task RerankAsync( global::Together.RerankRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create a rerank request
+ /// Rerank a list of documents by relevance to a query. Returns a relevance score and ordering index for each document. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// documents = [
+ /// {
+ /// "title": "Llama",
+ /// "text": "The llama is a domesticated South American camelid, widely used as a meat and pack animal by Andean cultures since the pre-Columbian era."
+ /// },
+ /// {
+ /// "title": "Panda",
+ /// "text": "The giant panda (Ailuropoda melanoleuca), also known as the panda bear or simply panda, is a bear species endemic to China."
+ /// },
+ /// {
+ /// "title": "Guanaco",
+ /// "text": "The guanaco is a camelid native to South America, closely related to the llama. Guanacos are one of two wild South American camelids; the other species is the vicuña, which lives at higher elevations."
+ /// },
+ /// {
+ /// "title": "Wild Bactrian camel",
+ /// "text": "The wild Bactrian camel (Camelus ferus) is an endangered species of camel endemic to Northwest China and southwestern Mongolia."
+ /// }
+ /// ]
+ /// response = client.rerank.create(
+ /// model="Salesforce/Llama-Rank-v1",
+ /// query="What animals can I find near Peru?",
+ /// documents=documents,
+ /// )
+ /// for result in response.results:
+ /// print(f"Rank: {result.index + 1}")
+ /// print(f"Title: {documents[result.index]['title']}")
+ /// print(f"Text: {documents[result.index]['text']}") + ///
+ global::System.Threading.Tasks.Task> RerankAsResponseAsync( + + global::Together.RerankRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create a rerank request
@@ -78,6 +128,7 @@ public partial interface IRerankClient /// List of keys in the JSON Object document to rank by. Defaults to use all supplied keys for ranking.
/// Example: [title, text] /// + /// 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 RerankAsync( @@ -87,6 +138,7 @@ public partial interface IRerankClient int? topN = default, bool? returnDocuments = default, global::System.Collections.Generic.IList? rankFields = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IRerankClient.g.cs b/src/libs/Together/Generated/Together.IRerankClient.g.cs index 647950a4..6ac3ded4 100644 --- a/src/libs/Together/Generated/Together.IRerankClient.g.cs +++ b/src/libs/Together/Generated/Together.IRerankClient.g.cs @@ -32,6 +32,11 @@ public partial interface IRerankClient : global::System.IDisposable /// ensuring is populated. ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Together.AutoSDKClientOptions Options { get; } + /// /// diff --git a/src/libs/Together/Generated/Together.IRlClient.CreateInferenceCheckpoint.g.cs b/src/libs/Together/Generated/Together.IRlClient.CreateInferenceCheckpoint.g.cs index e5670853..0ae00e81 100644 --- a/src/libs/Together/Generated/Together.IRlClient.CreateInferenceCheckpoint.g.cs +++ b/src/libs/Together/Generated/Together.IRlClient.CreateInferenceCheckpoint.g.cs @@ -11,10 +11,26 @@ public partial interface IRlClient /// /// Training session ID /// + /// 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 CreateInferenceCheckpointAsync( string sessionId, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create inference checkpoint
+ /// Submits an operation that will asynchronously save the current LoRA adapter as an inference checkpoint and upload it to object storage. + ///
+ /// + /// Training session ID + /// + /// 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> CreateInferenceCheckpointAsResponseAsync( + string sessionId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IRlClient.CreateTrainingCheckpoint.g.cs b/src/libs/Together/Generated/Together.IRlClient.CreateTrainingCheckpoint.g.cs index fab16f18..6abf9fe4 100644 --- a/src/libs/Together/Generated/Together.IRlClient.CreateTrainingCheckpoint.g.cs +++ b/src/libs/Together/Generated/Together.IRlClient.CreateTrainingCheckpoint.g.cs @@ -11,10 +11,26 @@ public partial interface IRlClient /// /// Training session ID /// + /// 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 CreateTrainingCheckpointAsync( string sessionId, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Save training checkpoint
+ /// Submits an operation that will asynchronously save the full training state (adapter + optimizer + step). + ///
+ /// + /// Training session ID + /// + /// 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> CreateTrainingCheckpointAsResponseAsync( + string sessionId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IRlClient.DownloadCheckpoint.g.cs b/src/libs/Together/Generated/Together.IRlClient.DownloadCheckpoint.g.cs index 12598bed..441315e3 100644 --- a/src/libs/Together/Generated/Together.IRlClient.DownloadCheckpoint.g.cs +++ b/src/libs/Together/Generated/Together.IRlClient.DownloadCheckpoint.g.cs @@ -15,11 +15,32 @@ public partial interface IRlClient /// Checkpoint variant to download: merged (full model) or adapter (LoRA weights only)
/// Default Value: CHECKPOINT_VARIANT_UNSPECIFIED /// + /// 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 DownloadCheckpointAsync( string id, global::Together.RlCheckpointVariant variant = global::Together.RlCheckpointVariant.CheckpointVariantUnspecified, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Download checkpoint
+ /// Returns presigned URLs for downloading a checkpoint's model files. Only inference checkpoints support downloading. + ///
+ /// + /// ID of the checkpoint + /// + /// + /// Checkpoint variant to download: merged (full model) or adapter (LoRA weights only)
+ /// Default Value: CHECKPOINT_VARIANT_UNSPECIFIED + /// + /// 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> DownloadCheckpointAsResponseAsync( + string id, + global::Together.RlCheckpointVariant variant = global::Together.RlCheckpointVariant.CheckpointVariantUnspecified, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IRlClient.ForwardBackward.g.cs b/src/libs/Together/Generated/Together.IRlClient.ForwardBackward.g.cs index 876007a8..5126e2b5 100644 --- a/src/libs/Together/Generated/Together.IRlClient.ForwardBackward.g.cs +++ b/src/libs/Together/Generated/Together.IRlClient.ForwardBackward.g.cs @@ -12,12 +12,31 @@ public partial interface IRlClient /// Training session ID /// /// + /// 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 ForwardBackwardAsync( string sessionId, global::Together.RlForwardBackwardBody request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Forward-backward pass
+ /// Submits a forward-backward pass operation that will asynchronously compute gradients via backpropagation. + ///
+ /// + /// Training session ID + /// + /// + /// 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> ForwardBackwardAsResponseAsync( + string sessionId, + + global::Together.RlForwardBackwardBody request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Forward-backward pass
@@ -32,12 +51,14 @@ public partial interface IRlClient /// /// Loss function configuration /// + /// 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 ForwardBackwardAsync( string sessionId, global::System.Collections.Generic.IList samples, global::Together.RlLossConfig loss, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IRlClient.GetForwardBackwardOperation.g.cs b/src/libs/Together/Generated/Together.IRlClient.GetForwardBackwardOperation.g.cs index 6e5ab23a..5729088e 100644 --- a/src/libs/Together/Generated/Together.IRlClient.GetForwardBackwardOperation.g.cs +++ b/src/libs/Together/Generated/Together.IRlClient.GetForwardBackwardOperation.g.cs @@ -14,11 +14,31 @@ public partial interface IRlClient /// /// Operation ID /// + /// 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 GetForwardBackwardOperationAsync( string sessionId, string operationId, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get forward-backward operation
+ /// Retrieves the current status and result of a forward-backward operation. + ///
+ /// + /// Training session ID + /// + /// + /// Operation ID + /// + /// 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> GetForwardBackwardOperationAsResponseAsync( + string sessionId, + string operationId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IRlClient.GetInferenceCheckpointOperation.g.cs b/src/libs/Together/Generated/Together.IRlClient.GetInferenceCheckpointOperation.g.cs index 05adb666..7e5f8d39 100644 --- a/src/libs/Together/Generated/Together.IRlClient.GetInferenceCheckpointOperation.g.cs +++ b/src/libs/Together/Generated/Together.IRlClient.GetInferenceCheckpointOperation.g.cs @@ -14,11 +14,31 @@ public partial interface IRlClient /// /// Operation ID /// + /// 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 GetInferenceCheckpointOperationAsync( string sessionId, string operationId, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get inference checkpoint operation
+ /// Retrieves the current status and result of an inference checkpoint operation. + ///
+ /// + /// Training session ID + /// + /// + /// Operation ID + /// + /// 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> GetInferenceCheckpointOperationAsResponseAsync( + string sessionId, + string operationId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IRlClient.GetOptimStepOperation.g.cs b/src/libs/Together/Generated/Together.IRlClient.GetOptimStepOperation.g.cs index 08c64bc2..5355286c 100644 --- a/src/libs/Together/Generated/Together.IRlClient.GetOptimStepOperation.g.cs +++ b/src/libs/Together/Generated/Together.IRlClient.GetOptimStepOperation.g.cs @@ -14,11 +14,31 @@ public partial interface IRlClient /// /// Operation ID /// + /// 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 GetOptimStepOperationAsync( string sessionId, string operationId, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get optim-step operation
+ /// Retrieves the current status and result of an optim-step operation. + ///
+ /// + /// Training session ID + /// + /// + /// Operation ID + /// + /// 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> GetOptimStepOperationAsResponseAsync( + string sessionId, + string operationId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IRlClient.GetSample.g.cs b/src/libs/Together/Generated/Together.IRlClient.GetSample.g.cs index 9ac06d36..c6df5d55 100644 --- a/src/libs/Together/Generated/Together.IRlClient.GetSample.g.cs +++ b/src/libs/Together/Generated/Together.IRlClient.GetSample.g.cs @@ -14,11 +14,31 @@ public partial interface IRlClient /// /// Operation ID /// + /// 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 GetSampleAsync( string sessionId, string operationId, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get sample operation
+ /// Retrieves the current status and result of a sample operation. + ///
+ /// + /// Training session ID + /// + /// + /// Operation ID + /// + /// 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> GetSampleAsResponseAsync( + string sessionId, + string operationId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IRlClient.GetTrainingCheckpointOperation.g.cs b/src/libs/Together/Generated/Together.IRlClient.GetTrainingCheckpointOperation.g.cs index e93a1404..3c707f65 100644 --- a/src/libs/Together/Generated/Together.IRlClient.GetTrainingCheckpointOperation.g.cs +++ b/src/libs/Together/Generated/Together.IRlClient.GetTrainingCheckpointOperation.g.cs @@ -14,11 +14,31 @@ public partial interface IRlClient /// /// Operation ID /// + /// 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 GetTrainingCheckpointOperationAsync( string sessionId, string operationId, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get save training checkpoint operation
+ /// Retrieves the current status and result of a save training checkpoint operation. + ///
+ /// + /// Training session ID + /// + /// + /// Operation ID + /// + /// 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> GetTrainingCheckpointOperationAsResponseAsync( + string sessionId, + string operationId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IRlClient.GetTrainingSession.g.cs b/src/libs/Together/Generated/Together.IRlClient.GetTrainingSession.g.cs index f897c17c..6724c357 100644 --- a/src/libs/Together/Generated/Together.IRlClient.GetTrainingSession.g.cs +++ b/src/libs/Together/Generated/Together.IRlClient.GetTrainingSession.g.cs @@ -11,10 +11,26 @@ public partial interface IRlClient /// /// ID of the training session /// + /// 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 GetTrainingSessionAsync( string sessionId, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get training session
+ /// Gets a training session by its ID and returns its details. + ///
+ /// + /// ID of the training session + /// + /// 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> GetTrainingSessionAsResponseAsync( + string sessionId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IRlClient.ListTrainingSessions.g.cs b/src/libs/Together/Generated/Together.IRlClient.ListTrainingSessions.g.cs index 4f382a03..963ec65b 100644 --- a/src/libs/Together/Generated/Together.IRlClient.ListTrainingSessions.g.cs +++ b/src/libs/Together/Generated/Together.IRlClient.ListTrainingSessions.g.cs @@ -19,12 +19,38 @@ public partial interface IRlClient /// /// Cursor for pagination (ID of the last session from the previous page) /// + /// 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 ListTrainingSessionsAsync( global::Together.RlTrainingSessionStatus? status = default, int? limit = default, string? after = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// List training sessions
+ /// Lists all training sessions. + ///
+ /// + /// Status of the training sessions to list
+ /// Default Value: TRAINING_SESSION_STATUS_UNSPECIFIED + /// + /// + /// Maximum number of sessions to return (1-100)
+ /// Default Value: 20 + /// + /// + /// Cursor for pagination (ID of the last session from the previous page) + /// + /// 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> ListTrainingSessionsAsResponseAsync( + global::Together.RlTrainingSessionStatus? status = default, + int? limit = default, + string? after = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IRlClient.OptimStep.g.cs b/src/libs/Together/Generated/Together.IRlClient.OptimStep.g.cs index 4d1733c5..5374c104 100644 --- a/src/libs/Together/Generated/Together.IRlClient.OptimStep.g.cs +++ b/src/libs/Together/Generated/Together.IRlClient.OptimStep.g.cs @@ -12,12 +12,31 @@ public partial interface IRlClient /// Training session ID /// /// + /// 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 OptimStepAsync( string sessionId, global::Together.RlOptimStepBody request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Optimizer step
+ /// Submits an optimizer step operation that will asynchronously apply accumulated gradients to update model parameters. + ///
+ /// + /// Training session ID + /// + /// + /// 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> OptimStepAsResponseAsync( + string sessionId, + + global::Together.RlOptimStepBody request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Optimizer step
@@ -34,12 +53,14 @@ public partial interface IRlClient /// /// AdamW optimizer parameters /// + /// 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 OptimStepAsync( string sessionId, float? learningRate = default, global::Together.RlAdamWOptimizerParams? adamwParams = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IRlClient.Sample.g.cs b/src/libs/Together/Generated/Together.IRlClient.Sample.g.cs index 97d9cf2c..e965a289 100644 --- a/src/libs/Together/Generated/Together.IRlClient.Sample.g.cs +++ b/src/libs/Together/Generated/Together.IRlClient.Sample.g.cs @@ -12,12 +12,31 @@ public partial interface IRlClient /// Training session ID /// /// + /// 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 SampleAsync( string sessionId, global::Together.RlSampleBody request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Sample
+ /// Submits a sample operation that will asynchronously generate text completions with logprobs. + ///
+ /// + /// Training session ID + /// + /// + /// 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> SampleAsResponseAsync( + string sessionId, + + global::Together.RlSampleBody request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Sample
@@ -37,6 +56,7 @@ public partial interface IRlClient /// Default Value: 1
/// Example: 1 /// + /// 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 SampleAsync( @@ -44,6 +64,7 @@ public partial interface IRlClient global::System.Collections.Generic.IList prompts, global::Together.RlSamplingParams? samplingParams = default, long? numSamples = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IRlClient.StartTrainingSession.g.cs b/src/libs/Together/Generated/Together.IRlClient.StartTrainingSession.g.cs index b5def9ae..fde50833 100644 --- a/src/libs/Together/Generated/Together.IRlClient.StartTrainingSession.g.cs +++ b/src/libs/Together/Generated/Together.IRlClient.StartTrainingSession.g.cs @@ -9,11 +9,26 @@ public partial interface IRlClient /// Creates a training session and returns its details. ///
/// + /// 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 StartTrainingSessionAsync( global::Together.RlStartTrainingSessionRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create training session
+ /// Creates a training session and returns its details. + ///
+ /// + /// 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> StartTrainingSessionAsResponseAsync( + + global::Together.RlStartTrainingSessionRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create training session
@@ -27,15 +42,22 @@ public partial interface IRlClient /// Checkpoint ID to resume from
/// Example: 123e4567-e89b-12d3-a456-426614174000 /// + /// + /// Type of the training session. Defaults to TRAINER_AND_GENERATOR when unspecified. TRAINER_ONLY provisions only the trainer and rejects sample requests.
+ /// Default Value: SESSION_TYPE_TRAINER_AND_GENERATOR + /// /// /// LoRA adapter configuration /// + /// 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 StartTrainingSessionAsync( string baseModel, string? resumeFromCheckpointId = default, + global::Together.RlSessionType? type = default, global::Together.RlLoraConfig? loraConfig = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IRlClient.StopTrainingSession.g.cs b/src/libs/Together/Generated/Together.IRlClient.StopTrainingSession.g.cs index 7161f6d1..4f5f7786 100644 --- a/src/libs/Together/Generated/Together.IRlClient.StopTrainingSession.g.cs +++ b/src/libs/Together/Generated/Together.IRlClient.StopTrainingSession.g.cs @@ -11,10 +11,26 @@ public partial interface IRlClient /// /// ID of the training session /// + /// 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 StopTrainingSessionAsync( string sessionId, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Stop training session
+ /// Stops a training session. + ///
+ /// + /// ID of the training session + /// + /// 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> StopTrainingSessionAsResponseAsync( + string sessionId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IRlClient.g.cs b/src/libs/Together/Generated/Together.IRlClient.g.cs index 51fc1e16..0682f79b 100644 --- a/src/libs/Together/Generated/Together.IRlClient.g.cs +++ b/src/libs/Together/Generated/Together.IRlClient.g.cs @@ -32,6 +32,11 @@ public partial interface IRlClient : global::System.IDisposable /// ensuring is populated. ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Together.AutoSDKClientOptions Options { get; } + /// /// diff --git a/src/libs/Together/Generated/Together.ISecretsClient.CreateDeploymentsSecrets.g.cs b/src/libs/Together/Generated/Together.ISecretsClient.CreateDeploymentsSecrets.g.cs index 65b47a1b..9e6b9b38 100644 --- a/src/libs/Together/Generated/Together.ISecretsClient.CreateDeploymentsSecrets.g.cs +++ b/src/libs/Together/Generated/Together.ISecretsClient.CreateDeploymentsSecrets.g.cs @@ -9,6 +9,7 @@ public partial interface ISecretsClient /// Create a new secret to store sensitive configuration values /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -19,6 +20,25 @@ public partial interface ISecretsClient global::System.Threading.Tasks.Task CreateDeploymentsSecretsAsync( global::Together.CreateSecretRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create a new secret
+ /// Create a new secret to store sensitive configuration values + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// client.beta.jig.secrets.create(name="my-secret", value="my-value") + ///
+ global::System.Threading.Tasks.Task> CreateDeploymentsSecretsAsResponseAsync( + + global::Together.CreateSecretRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create a new secret
@@ -34,8 +54,9 @@ public partial interface ISecretsClient /// ProjectID is ignored - the project is automatically determined from your authentication /// /// - /// Value is the sensitive data to store securely (e.g., API keys, passwords, tokens). This value will be encrypted at rest + /// Value is the sensitive data to store securely (e.g., API keys, passwords, tokens). Encrypted at rest. /// + /// 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 CreateDeploymentsSecretsAsync( @@ -43,6 +64,7 @@ public partial interface ISecretsClient string value, string? description = default, string? projectId = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.ISecretsClient.DeleteDeploymentsSecretsById.g.cs b/src/libs/Together/Generated/Together.ISecretsClient.DeleteDeploymentsSecretsById.g.cs index 46561559..e47dfb2e 100644 --- a/src/libs/Together/Generated/Together.ISecretsClient.DeleteDeploymentsSecretsById.g.cs +++ b/src/libs/Together/Generated/Together.ISecretsClient.DeleteDeploymentsSecretsById.g.cs @@ -11,6 +11,7 @@ public partial interface ISecretsClient /// /// Secret ID or name /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -20,6 +21,26 @@ public partial interface ISecretsClient /// global::System.Threading.Tasks.Task DeleteDeploymentsSecretsByIdAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Delete a secret
+ /// Delete an existing secret + ///
+ /// + /// Secret ID or name + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// client.beta.jig.secrets.delete("my-secret") + ///
+ global::System.Threading.Tasks.Task> DeleteDeploymentsSecretsByIdAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.ISecretsClient.EditDeploymentsSecretsById.g.cs b/src/libs/Together/Generated/Together.ISecretsClient.EditDeploymentsSecretsById.g.cs index 5ca4f4c6..36575239 100644 --- a/src/libs/Together/Generated/Together.ISecretsClient.EditDeploymentsSecretsById.g.cs +++ b/src/libs/Together/Generated/Together.ISecretsClient.EditDeploymentsSecretsById.g.cs @@ -12,6 +12,7 @@ public partial interface ISecretsClient /// Secret ID or name /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -23,6 +24,29 @@ public partial interface ISecretsClient string id, global::Together.UpdateSecretRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Update a secret
+ /// Update an existing secret's value or metadata + ///
+ /// + /// Secret ID or name + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// client.beta.jig.secrets.update("my-secret", value="my-new-value") + ///
+ global::System.Threading.Tasks.Task> EditDeploymentsSecretsByIdAsResponseAsync( + string id, + + global::Together.UpdateSecretRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update a secret
@@ -41,8 +65,9 @@ public partial interface ISecretsClient /// ProjectID is ignored - the project is automatically determined from your authentication /// /// - /// Value is the new sensitive data to store securely. Updating this will replace the existing secret value + /// Value is the new sensitive data to store securely. Updating this replaces the existing secret value. /// + /// 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 EditDeploymentsSecretsByIdAsync( @@ -51,6 +76,7 @@ public partial interface ISecretsClient string? name = default, string? projectId = default, string? value = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.ISecretsClient.GetDeploymentsSecrets.g.cs b/src/libs/Together/Generated/Together.ISecretsClient.GetDeploymentsSecrets.g.cs index 51eb76d4..d2524e98 100644 --- a/src/libs/Together/Generated/Together.ISecretsClient.GetDeploymentsSecrets.g.cs +++ b/src/libs/Together/Generated/Together.ISecretsClient.GetDeploymentsSecrets.g.cs @@ -8,6 +8,7 @@ public partial interface ISecretsClient /// Get the list of project secrets
/// Retrieve all secrets in your project ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -17,6 +18,23 @@ public partial interface ISecretsClient /// print(secrets) /// global::System.Threading.Tasks.Task GetDeploymentsSecretsAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get the list of project secrets
+ /// Retrieve all secrets in your project + ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// secrets = client.beta.jig.secrets.list()
+ /// print(secrets) + ///
+ global::System.Threading.Tasks.Task> GetDeploymentsSecretsAsResponseAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.ISecretsClient.GetDeploymentsSecretsById.g.cs b/src/libs/Together/Generated/Together.ISecretsClient.GetDeploymentsSecretsById.g.cs index 4e37267e..3a08295a 100644 --- a/src/libs/Together/Generated/Together.ISecretsClient.GetDeploymentsSecretsById.g.cs +++ b/src/libs/Together/Generated/Together.ISecretsClient.GetDeploymentsSecretsById.g.cs @@ -11,6 +11,7 @@ public partial interface ISecretsClient /// /// Secret ID or name /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -21,6 +22,27 @@ public partial interface ISecretsClient /// global::System.Threading.Tasks.Task GetDeploymentsSecretsByIdAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get a secret by ID or name
+ /// Retrieve details of a specific secret by its ID or name + ///
+ /// + /// Secret ID or name + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// secret = client.beta.jig.secrets.retrieve("my-secret")
+ /// print(secret) + ///
+ global::System.Threading.Tasks.Task> GetDeploymentsSecretsByIdAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.ISecretsClient.g.cs b/src/libs/Together/Generated/Together.ISecretsClient.g.cs index 0d2f61f5..acef640d 100644 --- a/src/libs/Together/Generated/Together.ISecretsClient.g.cs +++ b/src/libs/Together/Generated/Together.ISecretsClient.g.cs @@ -32,6 +32,11 @@ public partial interface ISecretsClient : global::System.IDisposable /// ensuring is populated. ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Together.AutoSDKClientOptions Options { get; } + /// /// diff --git a/src/libs/Together/Generated/Together.ISharedVolumeServiceClient.SharedVolumeServiceCreate.g.cs b/src/libs/Together/Generated/Together.ISharedVolumeServiceClient.SharedVolumeServiceCreate.g.cs index 986548b6..5c5b6399 100644 --- a/src/libs/Together/Generated/Together.ISharedVolumeServiceClient.SharedVolumeServiceCreate.g.cs +++ b/src/libs/Together/Generated/Together.ISharedVolumeServiceClient.SharedVolumeServiceCreate.g.cs @@ -5,12 +5,13 @@ namespace Together public partial interface ISharedVolumeServiceClient { /// - /// Create a shared volume.
+ /// Create a shared volume
/// Instant Clusters supports long-lived, resizable in-DC shared storage with user data persistence.
/// You can dynamically create and attach volumes to your cluster at cluster creation time, and resize as your data grows.
/// All shared storage is backed by multi-NIC bare metal paths, ensuring high-throughput and low-latency performance for shared storage. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -25,9 +26,34 @@ public partial interface ISharedVolumeServiceClient global::System.Threading.Tasks.Task SharedVolumeServiceCreateAsync( global::Together.GPUClustersSharedVolumeCreateRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// - /// Create a shared volume.
+ /// Create a shared volume
+ /// Instant Clusters supports long-lived, resizable in-DC shared storage with user data persistence.
+ /// You can dynamically create and attach volumes to your cluster at cluster creation time, and resize as your data grows.
+ /// All shared storage is backed by multi-NIC bare metal paths, ensuring high-throughput and low-latency performance for shared storage. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// volume = client.beta.clusters.storage.create(
+ /// volume_name="my-shared-volume",
+ /// size_tib=2,
+ /// region="us-west-2"
+ /// ) + ///
+ global::System.Threading.Tasks.Task> SharedVolumeServiceCreateAsResponseAsync( + + global::Together.GPUClustersSharedVolumeCreateRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create a shared volume
/// Instant Clusters supports long-lived, resizable in-DC shared storage with user data persistence.
/// You can dynamically create and attach volumes to your cluster at cluster creation time, and resize as your data grows.
/// All shared storage is backed by multi-NIC bare metal paths, ensuring high-throughput and low-latency performance for shared storage. @@ -41,12 +67,14 @@ public partial interface ISharedVolumeServiceClient /// /// Region name. Usable regions can be found from `client.clusters.list_regions()` /// + /// 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 SharedVolumeServiceCreateAsync( string volumeName, long sizeTib, string region, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.ISharedVolumeServiceClient.SharedVolumeServiceDelete.g.cs b/src/libs/Together/Generated/Together.ISharedVolumeServiceClient.SharedVolumeServiceDelete.g.cs index 68366592..8d4e8c66 100644 --- a/src/libs/Together/Generated/Together.ISharedVolumeServiceClient.SharedVolumeServiceDelete.g.cs +++ b/src/libs/Together/Generated/Together.ISharedVolumeServiceClient.SharedVolumeServiceDelete.g.cs @@ -5,12 +5,13 @@ namespace Together public partial interface ISharedVolumeServiceClient { /// - /// Delete shared volume by volume id.
+ /// Delete a shared volume by ID
/// Delete a shared volume. Note that if this volume is attached to a cluster, deleting will fail. ///
/// /// The ID of the volume to delete /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -21,6 +22,27 @@ public partial interface ISharedVolumeServiceClient /// global::System.Threading.Tasks.Task SharedVolumeServiceDeleteAsync( string volumeId, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Delete a shared volume by ID
+ /// Delete a shared volume. Note that if this volume is attached to a cluster, deleting will fail. + ///
+ /// + /// The ID of the volume to delete + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// volume = client.beta.clusters.storage.delete("volume_id")
+ /// print(volume) + ///
+ global::System.Threading.Tasks.Task> SharedVolumeServiceDeleteAsResponseAsync( + string volumeId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.ISharedVolumeServiceClient.SharedVolumeServiceGet.g.cs b/src/libs/Together/Generated/Together.ISharedVolumeServiceClient.SharedVolumeServiceGet.g.cs index 02eb84a2..56226dcc 100644 --- a/src/libs/Together/Generated/Together.ISharedVolumeServiceClient.SharedVolumeServiceGet.g.cs +++ b/src/libs/Together/Generated/Together.ISharedVolumeServiceClient.SharedVolumeServiceGet.g.cs @@ -5,12 +5,13 @@ namespace Together public partial interface ISharedVolumeServiceClient { /// - /// Get shared volume by volume Id.
+ /// Get a shared volume by ID
/// Retrieve information about a specific shared volume. ///
/// /// The ID of the volume to retrieve /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -21,6 +22,27 @@ public partial interface ISharedVolumeServiceClient /// global::System.Threading.Tasks.Task SharedVolumeServiceGetAsync( string volumeId, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get a shared volume by ID
+ /// Retrieve information about a specific shared volume. + ///
+ /// + /// The ID of the volume to retrieve + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// volume = client.beta.clusters.storage.retrieve("volume_id")
+ /// print(volume) + ///
+ global::System.Threading.Tasks.Task> SharedVolumeServiceGetAsResponseAsync( + string volumeId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.ISharedVolumeServiceClient.SharedVolumeServiceList.g.cs b/src/libs/Together/Generated/Together.ISharedVolumeServiceClient.SharedVolumeServiceList.g.cs index 65bbc981..3cebfb9e 100644 --- a/src/libs/Together/Generated/Together.ISharedVolumeServiceClient.SharedVolumeServiceList.g.cs +++ b/src/libs/Together/Generated/Together.ISharedVolumeServiceClient.SharedVolumeServiceList.g.cs @@ -5,9 +5,10 @@ namespace Together public partial interface ISharedVolumeServiceClient { /// - /// List all shared volumes.
+ /// List all shared volumes
/// List all shared volumes. ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -17,6 +18,23 @@ public partial interface ISharedVolumeServiceClient /// print(volumes) /// global::System.Threading.Tasks.Task SharedVolumeServiceListAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// List all shared volumes
+ /// List all shared volumes. + ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// volumes = client.beta.clusters.storage.list()
+ /// print(volumes) + ///
+ global::System.Threading.Tasks.Task> SharedVolumeServiceListAsResponseAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.ISharedVolumeServiceClient.SharedVolumeServiceUpdate.g.cs b/src/libs/Together/Generated/Together.ISharedVolumeServiceClient.SharedVolumeServiceUpdate.g.cs index ce72d12e..6405ba94 100644 --- a/src/libs/Together/Generated/Together.ISharedVolumeServiceClient.SharedVolumeServiceUpdate.g.cs +++ b/src/libs/Together/Generated/Together.ISharedVolumeServiceClient.SharedVolumeServiceUpdate.g.cs @@ -5,10 +5,11 @@ namespace Together public partial interface ISharedVolumeServiceClient { /// - /// Update a shared volume.
+ /// Update a shared volume
/// Update the configuration of an existing shared volume. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -23,9 +24,32 @@ public partial interface ISharedVolumeServiceClient global::System.Threading.Tasks.Task SharedVolumeServiceUpdateAsync( global::Together.GPUClustersSharedVolumeUpdateRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// - /// Update a shared volume.
+ /// Update a shared volume
+ /// Update the configuration of an existing shared volume. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// volume = client.beta.clusters.storage.update(
+ /// volume_id="12345-67890-12345-67890",
+ /// size_tib=3
+ /// )
+ /// print(volume) + ///
+ global::System.Threading.Tasks.Task> SharedVolumeServiceUpdateAsResponseAsync( + + global::Together.GPUClustersSharedVolumeUpdateRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Update a shared volume
/// Update the configuration of an existing shared volume. ///
/// @@ -34,11 +58,13 @@ public partial interface ISharedVolumeServiceClient /// /// Size of the volume in whole tebibytes (TiB). /// + /// 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 SharedVolumeServiceUpdateAsync( string? volumeId = default, long? sizeTib = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.ISharedVolumeServiceClient.g.cs b/src/libs/Together/Generated/Together.ISharedVolumeServiceClient.g.cs index 15188d26..09bbc675 100644 --- a/src/libs/Together/Generated/Together.ISharedVolumeServiceClient.g.cs +++ b/src/libs/Together/Generated/Together.ISharedVolumeServiceClient.g.cs @@ -32,6 +32,11 @@ public partial interface ISharedVolumeServiceClient : global::System.IDisposable /// ensuring is populated. ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Together.AutoSDKClientOptions Options { get; } + /// /// diff --git a/src/libs/Together/Generated/Together.ITogetherClient.g.cs b/src/libs/Together/Generated/Together.ITogetherClient.g.cs index 19632bb3..4d29ee80 100644 --- a/src/libs/Together/Generated/Together.ITogetherClient.g.cs +++ b/src/libs/Together/Generated/Together.ITogetherClient.g.cs @@ -4,7 +4,7 @@ namespace Together { /// - /// The Together REST API. Please see https://docs.together.ai for more details.
+ /// The Together REST API. See https://docs.together.ai for more details.
/// If no httpClient is provided, a new one will be created.
/// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. ///
@@ -20,6 +20,27 @@ public partial interface ITogetherClient : global::System.IDisposable ///
public System.Uri? BaseUri { get; } + + /// + /// The server options available for this client. + /// + public global::System.Collections.Generic.IReadOnlyList AvailableServers { get; } + + /// + /// The currently selected server for this client, if any. + /// + public global::Together.AutoSDKServer? SelectedServer { get; set; } + + /// + /// Selects one of the generated server options by id. + /// + public bool TrySelectServer(string serverId); + + /// + /// Clears the currently selected server. + /// + public void ClearSelectedServer(); + /// /// The authorizations to use for the requests. /// @@ -33,6 +54,11 @@ public partial interface ITogetherClient : global::System.IDisposable /// ensuring is populated. ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Together.AutoSDKClientOptions Options { get; } + /// /// diff --git a/src/libs/Together/Generated/Together.IVideoClient.CreateVideo.g.cs b/src/libs/Together/Generated/Together.IVideoClient.CreateVideo.g.cs index a029070f..ae673e2f 100644 --- a/src/libs/Together/Generated/Together.IVideoClient.CreateVideo.g.cs +++ b/src/libs/Together/Generated/Together.IVideoClient.CreateVideo.g.cs @@ -11,6 +11,7 @@ public partial interface IVideoClient /// Create a video /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -29,6 +30,33 @@ public partial interface IVideoClient global::System.Threading.Tasks.Task CreateVideoAsync( global::Together.CreateVideoBody request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create video
+ /// Create a video + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.videos.create(
+ /// model="together/video-model",
+ /// prompt="A cartoon of an astronaut riding a horse on the moon"
+ /// )
+ /// print(response.id) + ///
+ global::System.Threading.Tasks.Task> CreateVideoAsResponseAsync( + + global::Together.CreateVideoBody request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create video
@@ -78,6 +106,7 @@ public partial interface IVideoClient /// /// Media inputs for video generation. The accepted fields depend on the model type (e.g. i2v, r2v, t2v, videoedit). /// + /// 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 CreateVideoAsync( @@ -97,6 +126,7 @@ public partial interface IVideoClient string? negativePrompt = default, bool? generateAudio = default, global::Together.VideoMedia? media = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IVideoClient.RetrieveVideo.g.cs b/src/libs/Together/Generated/Together.IVideoClient.RetrieveVideo.g.cs index 11f419b6..88da9742 100644 --- a/src/libs/Together/Generated/Together.IVideoClient.RetrieveVideo.g.cs +++ b/src/libs/Together/Generated/Together.IVideoClient.RetrieveVideo.g.cs @@ -11,6 +11,7 @@ public partial interface IVideoClient /// /// Identifier of video from create response. /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -25,6 +26,31 @@ public partial interface IVideoClient /// global::System.Threading.Tasks.Task RetrieveVideoAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Fetch video metadata
+ /// Fetch video metadata + ///
+ /// + /// Identifier of video from create response. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.videos.retrieve(video_id)
+ /// print(response.id) + ///
+ global::System.Threading.Tasks.Task> RetrieveVideoAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IVideoClient.g.cs b/src/libs/Together/Generated/Together.IVideoClient.g.cs index f38e1a54..e8a51a20 100644 --- a/src/libs/Together/Generated/Together.IVideoClient.g.cs +++ b/src/libs/Together/Generated/Together.IVideoClient.g.cs @@ -32,6 +32,11 @@ public partial interface IVideoClient : global::System.IDisposable /// ensuring is populated. ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Together.AutoSDKClientOptions Options { get; } + /// /// diff --git a/src/libs/Together/Generated/Together.IVoicesClient.FetchVoices.g.cs b/src/libs/Together/Generated/Together.IVoicesClient.FetchVoices.g.cs index ec752615..71559737 100644 --- a/src/libs/Together/Generated/Together.IVoicesClient.FetchVoices.g.cs +++ b/src/libs/Together/Generated/Together.IVoicesClient.FetchVoices.g.cs @@ -8,6 +8,7 @@ public partial interface IVoicesClient /// Fetch available voices for each model
/// Fetch available voices for each model ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -21,6 +22,27 @@ public partial interface IVoicesClient /// print(response.data) /// global::System.Threading.Tasks.Task FetchVoicesAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Fetch available voices for each model
+ /// Fetch available voices for each model + ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.audio.voices.list()
+ /// print(response.data) + ///
+ global::System.Threading.Tasks.Task> FetchVoicesAsResponseAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IVoicesClient.g.cs b/src/libs/Together/Generated/Together.IVoicesClient.g.cs index 7c96abe9..a18bd3fd 100644 --- a/src/libs/Together/Generated/Together.IVoicesClient.g.cs +++ b/src/libs/Together/Generated/Together.IVoicesClient.g.cs @@ -32,6 +32,11 @@ public partial interface IVoicesClient : global::System.IDisposable /// ensuring is populated. ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Together.AutoSDKClientOptions Options { get; } + /// /// diff --git a/src/libs/Together/Generated/Together.IVolumesClient.DeleteDeploymentsStorageVolumesById.g.cs b/src/libs/Together/Generated/Together.IVolumesClient.DeleteDeploymentsStorageVolumesById.g.cs index b2faf5ea..ae8ed19f 100644 --- a/src/libs/Together/Generated/Together.IVolumesClient.DeleteDeploymentsStorageVolumesById.g.cs +++ b/src/libs/Together/Generated/Together.IVolumesClient.DeleteDeploymentsStorageVolumesById.g.cs @@ -11,10 +11,26 @@ public partial interface IVolumesClient /// /// Volume ID or name /// + /// 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 DeleteDeploymentsStorageVolumesByIdAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Delete a volume
+ /// Delete an existing volume + ///
+ /// + /// Volume ID or name + /// + /// 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> DeleteDeploymentsStorageVolumesByIdAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IVolumesClient.EditDeploymentsStorageVolumesById.g.cs b/src/libs/Together/Generated/Together.IVolumesClient.EditDeploymentsStorageVolumesById.g.cs index b4cb0f12..3851fb34 100644 --- a/src/libs/Together/Generated/Together.IVolumesClient.EditDeploymentsStorageVolumesById.g.cs +++ b/src/libs/Together/Generated/Together.IVolumesClient.EditDeploymentsStorageVolumesById.g.cs @@ -12,12 +12,31 @@ public partial interface IVolumesClient /// Volume ID or name. /// /// + /// 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 EditDeploymentsStorageVolumesByIdAsync( string id, global::Together.UpdateVolumeRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Update a volume
+ /// Update an existing volume's configuration or contents + ///
+ /// + /// Volume ID or name. + /// + /// + /// 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> EditDeploymentsStorageVolumesByIdAsResponseAsync( + string id, + + global::Together.UpdateVolumeRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update a volume
@@ -27,7 +46,7 @@ public partial interface IVolumesClient /// Volume ID or name. /// /// - /// Content specifies the new content that will be preloaded to this volume + /// Content specifies the new content to preload to this volume. /// /// /// Name is the new unique identifier for the volume within the project @@ -35,6 +54,7 @@ public partial interface IVolumesClient /// /// Type is the new volume type (currently only "readOnly" is supported) /// + /// 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 EditDeploymentsStorageVolumesByIdAsync( @@ -42,6 +62,7 @@ public partial interface IVolumesClient global::Together.VolumeContentRequest? content = default, string? name = default, global::Together.VolumeType? type = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IVolumesClient.GetDeploymentsStorageVolumesById.g.cs b/src/libs/Together/Generated/Together.IVolumesClient.GetDeploymentsStorageVolumesById.g.cs index 34534e65..1f151e43 100644 --- a/src/libs/Together/Generated/Together.IVolumesClient.GetDeploymentsStorageVolumesById.g.cs +++ b/src/libs/Together/Generated/Together.IVolumesClient.GetDeploymentsStorageVolumesById.g.cs @@ -11,10 +11,26 @@ public partial interface IVolumesClient /// /// Volume ID or name /// + /// 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 GetDeploymentsStorageVolumesByIdAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get a volume by ID or name
+ /// Retrieve details of a specific volume by its ID or name + ///
+ /// + /// Volume ID or name + /// + /// 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> GetDeploymentsStorageVolumesByIdAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.IVolumesClient.g.cs b/src/libs/Together/Generated/Together.IVolumesClient.g.cs index 76431ab7..eb7ac767 100644 --- a/src/libs/Together/Generated/Together.IVolumesClient.g.cs +++ b/src/libs/Together/Generated/Together.IVolumesClient.g.cs @@ -32,6 +32,11 @@ public partial interface IVolumesClient : global::System.IDisposable /// ensuring is populated. ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Together.AutoSDKClientOptions Options { get; } + /// /// diff --git a/src/libs/Together/Generated/Together.ImagesClient.CreateImagesGenerations.g.cs b/src/libs/Together/Generated/Together.ImagesClient.CreateImagesGenerations.g.cs index dd3af0e5..21acf7e5 100644 --- a/src/libs/Together/Generated/Together.ImagesClient.CreateImagesGenerations.g.cs +++ b/src/libs/Together/Generated/Together.ImagesClient.CreateImagesGenerations.g.cs @@ -14,6 +14,7 @@ public partial class ImagesClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,6 +46,7 @@ partial void ProcessCreateImagesGenerationsResponseContent( /// Use an image model to generate an image for a given prompt. /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -64,6 +66,44 @@ partial void ProcessCreateImagesGenerationsResponseContent( public async global::System.Threading.Tasks.Task CreateImagesGenerationsAsync( global::Together.CreateImagesGenerationsRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreateImagesGenerationsAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Create image
+ /// Use an image model to generate an image for a given prompt. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.images.generate(
+ /// model="black-forest-labs/FLUX.1-schnell",
+ /// steps=4,
+ /// prompt="A cartoon of an astronaut riding a horse on the moon",
+ /// )
+ /// print(response.data[0].url) + ///
+ public async global::System.Threading.Tasks.Task> CreateImagesGenerationsAsResponseAsync( + + global::Together.CreateImagesGenerationsRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -80,22 +120,44 @@ partial void ProcessCreateImagesGenerationsResponseContent( securityRequirements: s_CreateImagesGenerationsSecurityRequirements, operationName: "CreateImagesGenerationsAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/images/generations", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/images/generations", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -105,118 +167,303 @@ partial void ProcessCreateImagesGenerationsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateImagesGenerationsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateImagesGenerationsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateImagesGenerationsResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createImagesGenerations", + methodName: "CreateImagesGenerationsAsync", + pathTemplate: "\"/images/generations\"", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createImagesGenerations", + methodName: "CreateImagesGenerationsAsync", + pathTemplate: "\"/images/generations\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessCreateImagesGenerationsResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createImagesGenerations", + methodName: "CreateImagesGenerationsAsync", + pathTemplate: "\"/images/generations\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::Together.ImageResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Together.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), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return - await global::Together.ImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateImagesGenerationsResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createImagesGenerations", + methodName: "CreateImagesGenerationsAsync", + pathTemplate: "\"/images/generations\"", + 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); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createImagesGenerations", + methodName: "CreateImagesGenerationsAsync", + pathTemplate: "\"/images/generations\"", + 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); + ProcessCreateImagesGenerationsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.ImageResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.ImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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 image
@@ -275,6 +522,7 @@ partial void ProcessCreateImagesGenerationsResponseContent( /// /// If true, disables the safety checker for image generation. /// + /// 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 CreateImagesGenerationsAsync( @@ -293,6 +541,7 @@ partial void ProcessCreateImagesGenerationsResponseContent( global::System.Collections.Generic.IList? imageLoras = default, global::System.Collections.Generic.IList? referenceImages = default, bool? disableSafetyChecker = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.CreateImagesGenerationsRequest @@ -316,6 +565,7 @@ partial void ProcessCreateImagesGenerationsResponseContent( return await CreateImagesGenerationsAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Together/Generated/Together.ImagesClient.g.cs b/src/libs/Together/Generated/Together.ImagesClient.g.cs index 8f9f4316..0c0d9c3f 100644 --- a/src/libs/Together/Generated/Together.ImagesClient.g.cs +++ b/src/libs/Together/Generated/Together.ImagesClient.g.cs @@ -12,7 +12,7 @@ public sealed partial class ImagesClient : global::Together.IImagesClient, globa /// /// /// - public const string DefaultBaseUrl = "https://api.together.xyz/v1"; + public const string DefaultBaseUrl = "https://api.together.ai/v1"; private bool _disposeHttpClient = true; @@ -30,6 +30,12 @@ public sealed partial class ImagesClient : global::Together.IImagesClient, globa #if DEBUG = true; #endif + + /// + public global::Together.AutoSDKClientOptions Options { get; } + + + internal global::Together.AutoSDKServerConfiguration AutoSDKServerConfiguration { get; set; } = new global::Together.AutoSDKServerConfiguration(); /// /// /// @@ -49,13 +55,62 @@ public ImagesClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the ImagesClient with explicit options but no base URL override. + /// Skips passing baseUri so the default base URL from the OpenAPI spec applies. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public ImagesClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, + bool disposeHttpClient = true) : this( + httpClient, + baseUri: null, + authorizations, + options, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the ImagesClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public ImagesClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Together.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; + AutoSDKServerConfiguration.ExplicitBaseUri = baseUri ?? httpClient?.BaseAddress; + Initialized(HttpClient); } diff --git a/src/libs/Together/Generated/Together.JobsClient.GetJob.g.cs b/src/libs/Together/Generated/Together.JobsClient.GetJob.g.cs index d0877565..c3278595 100644 --- a/src/libs/Together/Generated/Together.JobsClient.GetJob.g.cs +++ b/src/libs/Together/Generated/Together.JobsClient.GetJob.g.cs @@ -14,6 +14,7 @@ public partial class JobsClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,10 +49,36 @@ partial void ProcessGetJobResponseContent( /// The ID of the job to retrieve
/// Example: job-a15dad11-8d8e-4007-97c5-a211304de284 /// + /// 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 GetJobAsync( string jobId, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetJobAsResponseAsync( + jobId: jobId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get job status
+ /// Get the status of a specific job + ///
+ /// + /// The ID of the job to retrieve
+ /// Example: job-a15dad11-8d8e-4007-97c5-a211304de284 + /// + /// 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> GetJobAsResponseAsync( + string jobId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -66,22 +93,44 @@ partial void ProcessGetJobResponseContent( securityRequirements: s_GetJobSecurityRequirements, operationName: "GetJobAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/jobs/{jobId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/jobs/{jobId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -91,112 +140,297 @@ partial void ProcessGetJobResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetJobRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - jobId: jobId); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetJobRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + jobId: jobId!); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetJobResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetJob", + methodName: "GetJobAsync", + pathTemplate: "$\"/jobs/{jobId}\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetJob", + methodName: "GetJobAsync", + pathTemplate: "$\"/jobs/{jobId}\"", + httpMethod: "GET", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessGetJobResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetJob", + methodName: "GetJobAsync", + pathTemplate: "$\"/jobs/{jobId}\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::Together.JobInfoSuccessResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Together.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), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return - await global::Together.JobInfoSuccessResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetJobResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetJob", + methodName: "GetJobAsync", + pathTemplate: "$\"/jobs/{jobId}\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetJob", + methodName: "GetJobAsync", + pathTemplate: "$\"/jobs/{jobId}\"", + httpMethod: "GET", + 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); + ProcessGetJobResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.JobInfoSuccessResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.JobInfoSuccessResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.JobsClient.ListJobs.g.cs b/src/libs/Together/Generated/Together.JobsClient.ListJobs.g.cs index 81bc4065..1603505e 100644 --- a/src/libs/Together/Generated/Together.JobsClient.ListJobs.g.cs +++ b/src/libs/Together/Generated/Together.JobsClient.ListJobs.g.cs @@ -14,6 +14,7 @@ public partial class JobsClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -42,9 +43,29 @@ partial void ProcessListJobsResponseContent( /// List all jobs
/// List all jobs and their statuses ///
+ /// 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 ListJobsAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await ListJobsAsResponseAsync( + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// List all jobs
+ /// List all jobs and their statuses + ///
+ /// 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> ListJobsAsResponseAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +79,44 @@ partial void ProcessListJobsResponseContent( securityRequirements: s_ListJobsSecurityRequirements, operationName: "ListJobsAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/jobs", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/jobs", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -83,111 +126,296 @@ partial void ProcessListJobsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListJobsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListJobsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListJobsResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListJobs", + methodName: "ListJobsAsync", + pathTemplate: "\"/jobs\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListJobs", + methodName: "ListJobsAsync", + pathTemplate: "\"/jobs\"", + httpMethod: "GET", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessListJobsResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListJobs", + methodName: "ListJobsAsync", + pathTemplate: "\"/jobs\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::Together.JobsInfoSuccessResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Together.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), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return - await global::Together.JobsInfoSuccessResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListJobsResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListJobs", + methodName: "ListJobsAsync", + pathTemplate: "\"/jobs\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListJobs", + methodName: "ListJobsAsync", + pathTemplate: "\"/jobs\"", + httpMethod: "GET", + 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); + ProcessListJobsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.JobsInfoSuccessResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.JobsInfoSuccessResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.JobsClient.g.cs b/src/libs/Together/Generated/Together.JobsClient.g.cs index b7d5b65c..acf4b8ff 100644 --- a/src/libs/Together/Generated/Together.JobsClient.g.cs +++ b/src/libs/Together/Generated/Together.JobsClient.g.cs @@ -12,7 +12,7 @@ public sealed partial class JobsClient : global::Together.IJobsClient, global::S /// /// /// - public const string DefaultBaseUrl = "https://api.together.xyz/v1"; + public const string DefaultBaseUrl = "https://api.together.ai/v1"; private bool _disposeHttpClient = true; @@ -30,6 +30,12 @@ public sealed partial class JobsClient : global::Together.IJobsClient, global::S #if DEBUG = true; #endif + + /// + public global::Together.AutoSDKClientOptions Options { get; } + + + internal global::Together.AutoSDKServerConfiguration AutoSDKServerConfiguration { get; set; } = new global::Together.AutoSDKServerConfiguration(); /// /// /// @@ -49,13 +55,62 @@ public JobsClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the JobsClient with explicit options but no base URL override. + /// Skips passing baseUri so the default base URL from the OpenAPI spec applies. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public JobsClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, + bool disposeHttpClient = true) : this( + httpClient, + baseUri: null, + authorizations, + options, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the JobsClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public JobsClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Together.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; + AutoSDKServerConfiguration.ExplicitBaseUri = baseUri ?? httpClient?.BaseAddress; + Initialized(HttpClient); } diff --git a/src/libs/Together/Generated/Together.JsonConverters.AllOf2.g.cs b/src/libs/Together/Generated/Together.JsonConverters.AllOf2.g.cs index 282e891f..d0332746 100644 --- a/src/libs/Together/Generated/Together.JsonConverters.AllOf2.g.cs +++ b/src/libs/Together/Generated/Together.JsonConverters.AllOf2.g.cs @@ -3,7 +3,7 @@ namespace Together.JsonConverters { /// - public class AllOfJsonConverter<[global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T1, [global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T2> : global::System.Text.Json.Serialization.JsonConverter> + public class AllOfJsonConverter : global::System.Text.Json.Serialization.JsonConverter> { /// public override global::Together.AllOf Read( @@ -107,7 +107,10 @@ public class AllOfJsonConverter<[global::System.Diagnostics.CodeAnalysis.Dynamic catch (global::System.InvalidOperationException) { } + } + if (value1 == null && value2 == null) + { try { diff --git a/src/libs/Together/Generated/Together.JsonConverters.AnyOf2.g.cs b/src/libs/Together/Generated/Together.JsonConverters.AnyOf2.g.cs index 0c33fc54..51a3f950 100644 --- a/src/libs/Together/Generated/Together.JsonConverters.AnyOf2.g.cs +++ b/src/libs/Together/Generated/Together.JsonConverters.AnyOf2.g.cs @@ -3,7 +3,7 @@ namespace Together.JsonConverters { /// - public class AnyOfJsonConverter<[global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T1, [global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T2> : global::System.Text.Json.Serialization.JsonConverter> + public class AnyOfJsonConverter : global::System.Text.Json.Serialization.JsonConverter> { /// public override global::Together.AnyOf Read( @@ -107,7 +107,10 @@ public class AnyOfJsonConverter<[global::System.Diagnostics.CodeAnalysis.Dynamic catch (global::System.InvalidOperationException) { } + } + if (value1 == null && value2 == null) + { try { diff --git a/src/libs/Together/Generated/Together.JsonConverters.AudioSpeechStreamResponse.g.cs b/src/libs/Together/Generated/Together.JsonConverters.AudioSpeechStreamResponse.g.cs index e2af3bbb..7df71739 100644 --- a/src/libs/Together/Generated/Together.JsonConverters.AudioSpeechStreamResponse.g.cs +++ b/src/libs/Together/Generated/Together.JsonConverters.AudioSpeechStreamResponse.g.cs @@ -23,11 +23,22 @@ public class AudioSpeechStreamResponseJsonConverter : global::System.Text.Json.S foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) { __jsonProps.Add(__jsonProp.Name); + if (__jsonProp.Value.ValueKind == global::System.Text.Json.JsonValueKind.Object) + { + foreach (var __nestedJsonProp in __jsonProp.Value.EnumerateObject()) + { + __jsonProps.Add(__jsonProp.Name + "." + __nestedJsonProp.Name); + } + } + } } var __score0 = 0; if (__jsonProps.Contains("data")) __score0++; + if (__jsonProps.Contains("data.b64")) __score0++; + if (__jsonProps.Contains("data.model")) __score0++; + if (__jsonProps.Contains("data.object")) __score0++; var __score1 = 0; if (__jsonProps.Contains("data")) __score1++; var __bestScore = 0; @@ -75,6 +86,7 @@ public class AudioSpeechStreamResponseJsonConverter : global::System.Text.Json.S { try { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.AudioSpeechStreamEvent), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.AudioSpeechStreamEvent).Name}"); @event = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); @@ -85,9 +97,13 @@ public class AudioSpeechStreamResponseJsonConverter : global::System.Text.Json.S catch (global::System.InvalidOperationException) { } + } + if (@event == null && sentinel == null) + { try { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.StreamSentinel), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.StreamSentinel).Name}"); sentinel = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); diff --git a/src/libs/Together/Generated/Together.JsonConverters.AudioTranscriptionResponse.g.cs b/src/libs/Together/Generated/Together.JsonConverters.AudioTranscriptionResponse.g.cs index 4d742353..e5721e9b 100644 --- a/src/libs/Together/Generated/Together.JsonConverters.AudioTranscriptionResponse.g.cs +++ b/src/libs/Together/Generated/Together.JsonConverters.AudioTranscriptionResponse.g.cs @@ -23,6 +23,7 @@ public class AudioTranscriptionResponseJsonConverter : global::System.Text.Json. foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) { __jsonProps.Add(__jsonProp.Name); + } } @@ -33,7 +34,6 @@ public class AudioTranscriptionResponseJsonConverter : global::System.Text.Json. if (__jsonProps.Contains("language")) __score1++; if (__jsonProps.Contains("segments")) __score1++; if (__jsonProps.Contains("speaker_segments")) __score1++; - if (__jsonProps.Contains("task")) __score1++; if (__jsonProps.Contains("text")) __score1++; if (__jsonProps.Contains("words")) __score1++; var __bestScore = 0; @@ -81,6 +81,7 @@ public class AudioTranscriptionResponseJsonConverter : global::System.Text.Json. { try { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.AudioTranscriptionJsonResponse), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.AudioTranscriptionJsonResponse).Name}"); json = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); @@ -91,9 +92,13 @@ public class AudioTranscriptionResponseJsonConverter : global::System.Text.Json. catch (global::System.InvalidOperationException) { } + } + if (json == null && verboseJson == null) + { try { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.AudioTranscriptionVerboseJsonResponse), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.AudioTranscriptionVerboseJsonResponse).Name}"); verboseJson = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); diff --git a/src/libs/Together/Generated/Together.JsonConverters.AudioTranslationResponse.g.cs b/src/libs/Together/Generated/Together.JsonConverters.AudioTranslationResponse.g.cs index 7f597aea..e7e17f4e 100644 --- a/src/libs/Together/Generated/Together.JsonConverters.AudioTranslationResponse.g.cs +++ b/src/libs/Together/Generated/Together.JsonConverters.AudioTranslationResponse.g.cs @@ -23,6 +23,7 @@ public class AudioTranslationResponseJsonConverter : global::System.Text.Json.Se foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) { __jsonProps.Add(__jsonProp.Name); + } } @@ -32,7 +33,6 @@ public class AudioTranslationResponseJsonConverter : global::System.Text.Json.Se if (__jsonProps.Contains("duration")) __score1++; if (__jsonProps.Contains("language")) __score1++; if (__jsonProps.Contains("segments")) __score1++; - if (__jsonProps.Contains("task")) __score1++; if (__jsonProps.Contains("text")) __score1++; if (__jsonProps.Contains("words")) __score1++; var __bestScore = 0; @@ -80,6 +80,7 @@ public class AudioTranslationResponseJsonConverter : global::System.Text.Json.Se { try { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.AudioTranslationJsonResponse), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.AudioTranslationJsonResponse).Name}"); json = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); @@ -90,9 +91,13 @@ public class AudioTranslationResponseJsonConverter : global::System.Text.Json.Se catch (global::System.InvalidOperationException) { } + } + if (json == null && verboseJson == null) + { try { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.AudioTranslationVerboseJsonResponse), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.AudioTranslationVerboseJsonResponse).Name}"); verboseJson = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); diff --git a/src/libs/Together/Generated/Together.JsonConverters.ChatCompletionMessageParam.g.cs b/src/libs/Together/Generated/Together.JsonConverters.ChatCompletionMessageParam.g.cs index a6b01363..6b219eaf 100644 --- a/src/libs/Together/Generated/Together.JsonConverters.ChatCompletionMessageParam.g.cs +++ b/src/libs/Together/Generated/Together.JsonConverters.ChatCompletionMessageParam.g.cs @@ -23,6 +23,14 @@ public class ChatCompletionMessageParamJsonConverter : global::System.Text.Json. foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) { __jsonProps.Add(__jsonProp.Name); + if (__jsonProp.Value.ValueKind == global::System.Text.Json.JsonValueKind.Object) + { + foreach (var __nestedJsonProp in __jsonProp.Value.EnumerateObject()) + { + __jsonProps.Add(__jsonProp.Name + "." + __nestedJsonProp.Name); + } + } + } } @@ -37,6 +45,8 @@ public class ChatCompletionMessageParamJsonConverter : global::System.Text.Json. var __score2 = 0; if (__jsonProps.Contains("content")) __score2++; if (__jsonProps.Contains("function_call")) __score2++; + if (__jsonProps.Contains("function_call.arguments")) __score2++; + if (__jsonProps.Contains("function_call.name")) __score2++; if (__jsonProps.Contains("name")) __score2++; if (__jsonProps.Contains("role")) __score2++; if (__jsonProps.Contains("tool_calls")) __score2++; @@ -145,6 +155,7 @@ public class ChatCompletionMessageParamJsonConverter : global::System.Text.Json. { try { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.ChatCompletionSystemMessageParam), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.ChatCompletionSystemMessageParam).Name}"); system = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); @@ -155,9 +166,13 @@ public class ChatCompletionMessageParamJsonConverter : global::System.Text.Json. catch (global::System.InvalidOperationException) { } + } + if (system == null && user == null && assistant == null && tool == null && function == null) + { try { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.ChatCompletionUserMessageParam), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.ChatCompletionUserMessageParam).Name}"); user = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); @@ -168,9 +183,13 @@ public class ChatCompletionMessageParamJsonConverter : global::System.Text.Json. catch (global::System.InvalidOperationException) { } + } + if (system == null && user == null && assistant == null && tool == null && function == null) + { try { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.ChatCompletionAssistantMessageParam), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.ChatCompletionAssistantMessageParam).Name}"); assistant = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); @@ -181,9 +200,13 @@ public class ChatCompletionMessageParamJsonConverter : global::System.Text.Json. catch (global::System.InvalidOperationException) { } + } + if (system == null && user == null && assistant == null && tool == null && function == null) + { try { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.ChatCompletionToolMessageParam), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.ChatCompletionToolMessageParam).Name}"); tool = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); @@ -194,9 +217,13 @@ public class ChatCompletionMessageParamJsonConverter : global::System.Text.Json. catch (global::System.InvalidOperationException) { } + } + if (system == null && user == null && assistant == null && tool == null && function == null) + { try { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.ChatCompletionFunctionMessageParam), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.ChatCompletionFunctionMessageParam).Name}"); function = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); diff --git a/src/libs/Together/Generated/Together.JsonConverters.AudioTranscriptionVerboseJsonResponseTask.g.cs b/src/libs/Together/Generated/Together.JsonConverters.ChatCompletionRequestResponseFormatDiscriminatorType.g.cs similarity index 60% rename from src/libs/Together/Generated/Together.JsonConverters.AudioTranscriptionVerboseJsonResponseTask.g.cs rename to src/libs/Together/Generated/Together.JsonConverters.ChatCompletionRequestResponseFormatDiscriminatorType.g.cs index c3648a90..99132af6 100644 --- a/src/libs/Together/Generated/Together.JsonConverters.AudioTranscriptionVerboseJsonResponseTask.g.cs +++ b/src/libs/Together/Generated/Together.JsonConverters.ChatCompletionRequestResponseFormatDiscriminatorType.g.cs @@ -3,10 +3,10 @@ namespace Together.JsonConverters { /// - public sealed class AudioTranscriptionVerboseJsonResponseTaskJsonConverter : global::System.Text.Json.Serialization.JsonConverter + public sealed class ChatCompletionRequestResponseFormatDiscriminatorTypeJsonConverter : global::System.Text.Json.Serialization.JsonConverter { /// - public override global::Together.AudioTranscriptionVerboseJsonResponseTask Read( + public override global::Together.ChatCompletionRequestResponseFormatDiscriminatorType Read( ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) @@ -18,7 +18,7 @@ public sealed class AudioTranscriptionVerboseJsonResponseTaskJsonConverter : glo var stringValue = reader.GetString(); if (stringValue != null) { - return global::Together.AudioTranscriptionVerboseJsonResponseTaskExtensions.ToEnum(stringValue) ?? default; + return global::Together.ChatCompletionRequestResponseFormatDiscriminatorTypeExtensions.ToEnum(stringValue) ?? default; } break; @@ -26,11 +26,11 @@ public sealed class AudioTranscriptionVerboseJsonResponseTaskJsonConverter : glo case global::System.Text.Json.JsonTokenType.Number: { var numValue = reader.GetInt32(); - return (global::Together.AudioTranscriptionVerboseJsonResponseTask)numValue; + return (global::Together.ChatCompletionRequestResponseFormatDiscriminatorType)numValue; } case global::System.Text.Json.JsonTokenType.Null: { - return default(global::Together.AudioTranscriptionVerboseJsonResponseTask); + return default(global::Together.ChatCompletionRequestResponseFormatDiscriminatorType); } default: throw new global::System.ArgumentOutOfRangeException(nameof(reader)); @@ -42,12 +42,12 @@ public sealed class AudioTranscriptionVerboseJsonResponseTaskJsonConverter : glo /// public override void Write( global::System.Text.Json.Utf8JsonWriter writer, - global::Together.AudioTranscriptionVerboseJsonResponseTask value, + global::Together.ChatCompletionRequestResponseFormatDiscriminatorType value, global::System.Text.Json.JsonSerializerOptions options) { writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); - writer.WriteStringValue(global::Together.AudioTranscriptionVerboseJsonResponseTaskExtensions.ToValueString(value)); + writer.WriteStringValue(global::Together.ChatCompletionRequestResponseFormatDiscriminatorTypeExtensions.ToValueString(value)); } } } diff --git a/src/libs/Together/Generated/Together.JsonConverters.AudioTranscriptionVerboseJsonResponseTaskNullable.g.cs b/src/libs/Together/Generated/Together.JsonConverters.ChatCompletionRequestResponseFormatDiscriminatorTypeNullable.g.cs similarity index 62% rename from src/libs/Together/Generated/Together.JsonConverters.AudioTranscriptionVerboseJsonResponseTaskNullable.g.cs rename to src/libs/Together/Generated/Together.JsonConverters.ChatCompletionRequestResponseFormatDiscriminatorTypeNullable.g.cs index 24ef2620..405e3950 100644 --- a/src/libs/Together/Generated/Together.JsonConverters.AudioTranscriptionVerboseJsonResponseTaskNullable.g.cs +++ b/src/libs/Together/Generated/Together.JsonConverters.ChatCompletionRequestResponseFormatDiscriminatorTypeNullable.g.cs @@ -3,10 +3,10 @@ namespace Together.JsonConverters { /// - public sealed class AudioTranscriptionVerboseJsonResponseTaskNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter + public sealed class ChatCompletionRequestResponseFormatDiscriminatorTypeNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter { /// - public override global::Together.AudioTranscriptionVerboseJsonResponseTask? Read( + public override global::Together.ChatCompletionRequestResponseFormatDiscriminatorType? Read( ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) @@ -18,7 +18,7 @@ public sealed class AudioTranscriptionVerboseJsonResponseTaskNullableJsonConvert var stringValue = reader.GetString(); if (stringValue != null) { - return global::Together.AudioTranscriptionVerboseJsonResponseTaskExtensions.ToEnum(stringValue); + return global::Together.ChatCompletionRequestResponseFormatDiscriminatorTypeExtensions.ToEnum(stringValue); } break; @@ -26,11 +26,11 @@ public sealed class AudioTranscriptionVerboseJsonResponseTaskNullableJsonConvert case global::System.Text.Json.JsonTokenType.Number: { var numValue = reader.GetInt32(); - return (global::Together.AudioTranscriptionVerboseJsonResponseTask)numValue; + return (global::Together.ChatCompletionRequestResponseFormatDiscriminatorType)numValue; } case global::System.Text.Json.JsonTokenType.Null: { - return default(global::Together.AudioTranscriptionVerboseJsonResponseTask?); + return default(global::Together.ChatCompletionRequestResponseFormatDiscriminatorType?); } default: throw new global::System.ArgumentOutOfRangeException(nameof(reader)); @@ -42,7 +42,7 @@ public sealed class AudioTranscriptionVerboseJsonResponseTaskNullableJsonConvert /// public override void Write( global::System.Text.Json.Utf8JsonWriter writer, - global::Together.AudioTranscriptionVerboseJsonResponseTask? value, + global::Together.ChatCompletionRequestResponseFormatDiscriminatorType? value, global::System.Text.Json.JsonSerializerOptions options) { writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); @@ -53,7 +53,7 @@ public override void Write( } else { - writer.WriteStringValue(global::Together.AudioTranscriptionVerboseJsonResponseTaskExtensions.ToValueString(value.Value)); + writer.WriteStringValue(global::Together.ChatCompletionRequestResponseFormatDiscriminatorTypeExtensions.ToValueString(value.Value)); } } } diff --git a/src/libs/Together/Generated/Together.JsonConverters.ChatCompletionStream.g.cs b/src/libs/Together/Generated/Together.JsonConverters.ChatCompletionStream.g.cs index 817cee3a..c223d0e9 100644 --- a/src/libs/Together/Generated/Together.JsonConverters.ChatCompletionStream.g.cs +++ b/src/libs/Together/Generated/Together.JsonConverters.ChatCompletionStream.g.cs @@ -23,11 +23,27 @@ public class ChatCompletionStreamJsonConverter : global::System.Text.Json.Serial foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) { __jsonProps.Add(__jsonProp.Name); + if (__jsonProp.Value.ValueKind == global::System.Text.Json.JsonValueKind.Object) + { + foreach (var __nestedJsonProp in __jsonProp.Value.EnumerateObject()) + { + __jsonProps.Add(__jsonProp.Name + "." + __nestedJsonProp.Name); + } + } + } } var __score0 = 0; if (__jsonProps.Contains("data")) __score0++; + if (__jsonProps.Contains("data.choices")) __score0++; + if (__jsonProps.Contains("data.created")) __score0++; + if (__jsonProps.Contains("data.id")) __score0++; + if (__jsonProps.Contains("data.model")) __score0++; + if (__jsonProps.Contains("data.object")) __score0++; + if (__jsonProps.Contains("data.system_fingerprint")) __score0++; + if (__jsonProps.Contains("data.usage")) __score0++; + if (__jsonProps.Contains("data.warnings")) __score0++; var __score1 = 0; if (__jsonProps.Contains("data")) __score1++; var __bestScore = 0; @@ -75,6 +91,7 @@ public class ChatCompletionStreamJsonConverter : global::System.Text.Json.Serial { try { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.ChatCompletionEvent), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.ChatCompletionEvent).Name}"); @event = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); @@ -85,9 +102,13 @@ public class ChatCompletionStreamJsonConverter : global::System.Text.Json.Serial catch (global::System.InvalidOperationException) { } + } + if (@event == null && sentinel == null) + { try { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.StreamSentinel), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.StreamSentinel).Name}"); sentinel = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); diff --git a/src/libs/Together/Generated/Together.JsonConverters.ChatCompletionUserMessageContent.g.cs b/src/libs/Together/Generated/Together.JsonConverters.ChatCompletionUserMessageContent.g.cs index f2e56096..82fb16d5 100644 --- a/src/libs/Together/Generated/Together.JsonConverters.ChatCompletionUserMessageContent.g.cs +++ b/src/libs/Together/Generated/Together.JsonConverters.ChatCompletionUserMessageContent.g.cs @@ -108,7 +108,10 @@ public class ChatCompletionUserMessageContentJsonConverter : global::System.Text catch (global::System.InvalidOperationException) { } + } + if (@string == null && multimodal == null) + { try { diff --git a/src/libs/Together/Generated/Together.JsonConverters.CompletionStream.g.cs b/src/libs/Together/Generated/Together.JsonConverters.CompletionStream.g.cs index 2e0c7ab2..680c2aef 100644 --- a/src/libs/Together/Generated/Together.JsonConverters.CompletionStream.g.cs +++ b/src/libs/Together/Generated/Together.JsonConverters.CompletionStream.g.cs @@ -23,11 +23,27 @@ public class CompletionStreamJsonConverter : global::System.Text.Json.Serializat foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) { __jsonProps.Add(__jsonProp.Name); + if (__jsonProp.Value.ValueKind == global::System.Text.Json.JsonValueKind.Object) + { + foreach (var __nestedJsonProp in __jsonProp.Value.EnumerateObject()) + { + __jsonProps.Add(__jsonProp.Name + "." + __nestedJsonProp.Name); + } + } + } } var __score0 = 0; if (__jsonProps.Contains("data")) __score0++; + if (__jsonProps.Contains("data.choices")) __score0++; + if (__jsonProps.Contains("data.created")) __score0++; + if (__jsonProps.Contains("data.finish_reason")) __score0++; + if (__jsonProps.Contains("data.id")) __score0++; + if (__jsonProps.Contains("data.object")) __score0++; + if (__jsonProps.Contains("data.seed")) __score0++; + if (__jsonProps.Contains("data.token")) __score0++; + if (__jsonProps.Contains("data.usage")) __score0++; var __score1 = 0; if (__jsonProps.Contains("data")) __score1++; var __bestScore = 0; @@ -75,6 +91,7 @@ public class CompletionStreamJsonConverter : global::System.Text.Json.Serializat { try { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.CompletionEvent), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.CompletionEvent).Name}"); @event = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); @@ -85,9 +102,13 @@ public class CompletionStreamJsonConverter : global::System.Text.Json.Serializat catch (global::System.InvalidOperationException) { } + } + if (@event == null && sentinel == null) + { try { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.StreamSentinel), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.StreamSentinel).Name}"); sentinel = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); diff --git a/src/libs/Together/Generated/Together.JsonConverters.AudioSpeechRequestLanguage.g.cs b/src/libs/Together/Generated/Together.JsonConverters.CreateBatchRequestEndpoint.g.cs similarity index 69% rename from src/libs/Together/Generated/Together.JsonConverters.AudioSpeechRequestLanguage.g.cs rename to src/libs/Together/Generated/Together.JsonConverters.CreateBatchRequestEndpoint.g.cs index f2eeeaa4..69a6daf0 100644 --- a/src/libs/Together/Generated/Together.JsonConverters.AudioSpeechRequestLanguage.g.cs +++ b/src/libs/Together/Generated/Together.JsonConverters.CreateBatchRequestEndpoint.g.cs @@ -3,10 +3,10 @@ namespace Together.JsonConverters { /// - public sealed class AudioSpeechRequestLanguageJsonConverter : global::System.Text.Json.Serialization.JsonConverter + public sealed class CreateBatchRequestEndpointJsonConverter : global::System.Text.Json.Serialization.JsonConverter { /// - public override global::Together.AudioSpeechRequestLanguage Read( + public override global::Together.CreateBatchRequestEndpoint Read( ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) @@ -18,7 +18,7 @@ public sealed class AudioSpeechRequestLanguageJsonConverter : global::System.Tex var stringValue = reader.GetString(); if (stringValue != null) { - return global::Together.AudioSpeechRequestLanguageExtensions.ToEnum(stringValue) ?? default; + return global::Together.CreateBatchRequestEndpointExtensions.ToEnum(stringValue) ?? default; } break; @@ -26,11 +26,11 @@ public sealed class AudioSpeechRequestLanguageJsonConverter : global::System.Tex case global::System.Text.Json.JsonTokenType.Number: { var numValue = reader.GetInt32(); - return (global::Together.AudioSpeechRequestLanguage)numValue; + return (global::Together.CreateBatchRequestEndpoint)numValue; } case global::System.Text.Json.JsonTokenType.Null: { - return default(global::Together.AudioSpeechRequestLanguage); + return default(global::Together.CreateBatchRequestEndpoint); } default: throw new global::System.ArgumentOutOfRangeException(nameof(reader)); @@ -42,12 +42,12 @@ public sealed class AudioSpeechRequestLanguageJsonConverter : global::System.Tex /// public override void Write( global::System.Text.Json.Utf8JsonWriter writer, - global::Together.AudioSpeechRequestLanguage value, + global::Together.CreateBatchRequestEndpoint value, global::System.Text.Json.JsonSerializerOptions options) { writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); - writer.WriteStringValue(global::Together.AudioSpeechRequestLanguageExtensions.ToValueString(value)); + writer.WriteStringValue(global::Together.CreateBatchRequestEndpointExtensions.ToValueString(value)); } } } diff --git a/src/libs/Together/Generated/Together.JsonConverters.AudioSpeechRequestLanguageNullable.g.cs b/src/libs/Together/Generated/Together.JsonConverters.CreateBatchRequestEndpointNullable.g.cs similarity index 71% rename from src/libs/Together/Generated/Together.JsonConverters.AudioSpeechRequestLanguageNullable.g.cs rename to src/libs/Together/Generated/Together.JsonConverters.CreateBatchRequestEndpointNullable.g.cs index 6bfb6496..b1c76de9 100644 --- a/src/libs/Together/Generated/Together.JsonConverters.AudioSpeechRequestLanguageNullable.g.cs +++ b/src/libs/Together/Generated/Together.JsonConverters.CreateBatchRequestEndpointNullable.g.cs @@ -3,10 +3,10 @@ namespace Together.JsonConverters { /// - public sealed class AudioSpeechRequestLanguageNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter + public sealed class CreateBatchRequestEndpointNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter { /// - public override global::Together.AudioSpeechRequestLanguage? Read( + public override global::Together.CreateBatchRequestEndpoint? Read( ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) @@ -18,7 +18,7 @@ public sealed class AudioSpeechRequestLanguageNullableJsonConverter : global::Sy var stringValue = reader.GetString(); if (stringValue != null) { - return global::Together.AudioSpeechRequestLanguageExtensions.ToEnum(stringValue); + return global::Together.CreateBatchRequestEndpointExtensions.ToEnum(stringValue); } break; @@ -26,11 +26,11 @@ public sealed class AudioSpeechRequestLanguageNullableJsonConverter : global::Sy case global::System.Text.Json.JsonTokenType.Number: { var numValue = reader.GetInt32(); - return (global::Together.AudioSpeechRequestLanguage)numValue; + return (global::Together.CreateBatchRequestEndpoint)numValue; } case global::System.Text.Json.JsonTokenType.Null: { - return default(global::Together.AudioSpeechRequestLanguage?); + return default(global::Together.CreateBatchRequestEndpoint?); } default: throw new global::System.ArgumentOutOfRangeException(nameof(reader)); @@ -42,7 +42,7 @@ public sealed class AudioSpeechRequestLanguageNullableJsonConverter : global::Sy /// public override void Write( global::System.Text.Json.Utf8JsonWriter writer, - global::Together.AudioSpeechRequestLanguage? value, + global::Together.CreateBatchRequestEndpoint? value, global::System.Text.Json.JsonSerializerOptions options) { writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); @@ -53,7 +53,7 @@ public override void Write( } else { - writer.WriteStringValue(global::Together.AudioSpeechRequestLanguageExtensions.ToValueString(value.Value)); + writer.WriteStringValue(global::Together.CreateBatchRequestEndpointExtensions.ToValueString(value.Value)); } } } diff --git a/src/libs/Together/Generated/Together.JsonConverters.DataItem3.g.cs b/src/libs/Together/Generated/Together.JsonConverters.DataItem3.g.cs index 2a4d514e..8f564b1f 100644 --- a/src/libs/Together/Generated/Together.JsonConverters.DataItem3.g.cs +++ b/src/libs/Together/Generated/Together.JsonConverters.DataItem3.g.cs @@ -15,96 +15,29 @@ public class DataItem3JsonConverter : global::System.Text.Json.Serialization.Jso options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); - using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); - var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - } - } - var __score0 = 0; - if (__jsonProps.Contains("b64_json")) __score0++; - if (__jsonProps.Contains("index")) __score0++; - if (__jsonProps.Contains("type")) __score0++; - var __score1 = 0; - if (__jsonProps.Contains("index")) __score1++; - if (__jsonProps.Contains("type")) __score1++; - if (__jsonProps.Contains("url")) __score1++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } + var readerCopy = reader; + var discriminatorTypeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.ImageResponseDataItemDiscriminator), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::Together.ImageResponseDataItemDiscriminator)}"); + var discriminator = global::System.Text.Json.JsonSerializer.Deserialize(ref readerCopy, discriminatorTypeInfo); global::Together.ImageResponseDataB64? b64Json = default; - global::Together.ImageResponseDataUrl? url = default; - if (__bestIndex >= 0) + if (discriminator?.Type == global::Together.ImageResponseDataItemDiscriminatorType.B64Json) { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.ImageResponseDataB64), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.ImageResponseDataB64).Name}"); - b64Json = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 1) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.ImageResponseDataUrl), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.ImageResponseDataUrl).Name}"); - url = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.ImageResponseDataB64), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::Together.ImageResponseDataB64)}"); + b64Json = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo); } - - if (b64Json == null && url == null) + global::Together.ImageResponseDataUrl? url = default; + if (discriminator?.Type == global::Together.ImageResponseDataItemDiscriminatorType.Url) { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.ImageResponseDataB64), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.ImageResponseDataB64).Name}"); - b64Json = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.ImageResponseDataUrl), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.ImageResponseDataUrl).Name}"); - url = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.ImageResponseDataUrl), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::Together.ImageResponseDataUrl)}"); + url = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo); } var __value = new global::Together.DataItem3( + discriminator?.Type, b64Json, url diff --git a/src/libs/Together/Generated/Together.JsonConverters.Error.g.cs b/src/libs/Together/Generated/Together.JsonConverters.Error.g.cs index 25cb6524..c388b758 100644 --- a/src/libs/Together/Generated/Together.JsonConverters.Error.g.cs +++ b/src/libs/Together/Generated/Together.JsonConverters.Error.g.cs @@ -108,7 +108,10 @@ public class ErrorJsonConverter : global::System.Text.Json.Serialization.JsonCon catch (global::System.InvalidOperationException) { } + } + if (errorVariant1 == null && errorVariant2 == null) + { try { diff --git a/src/libs/Together/Generated/Together.JsonConverters.EvaluationModelOrString.g.cs b/src/libs/Together/Generated/Together.JsonConverters.EvaluationModelOrString.g.cs index b9a07d2d..c063b5fc 100644 --- a/src/libs/Together/Generated/Together.JsonConverters.EvaluationModelOrString.g.cs +++ b/src/libs/Together/Generated/Together.JsonConverters.EvaluationModelOrString.g.cs @@ -23,6 +23,7 @@ public class EvaluationModelOrStringJsonConverter : global::System.Text.Json.Ser foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) { __jsonProps.Add(__jsonProp.Name); + } } @@ -34,6 +35,7 @@ public class EvaluationModelOrStringJsonConverter : global::System.Text.Json.Ser if (__jsonProps.Contains("max_tokens")) __score1++; if (__jsonProps.Contains("model")) __score1++; if (__jsonProps.Contains("model_source")) __score1++; + if (__jsonProps.Contains("num_workers")) __score1++; if (__jsonProps.Contains("system_template")) __score1++; if (__jsonProps.Contains("temperature")) __score1++; var __bestScore = 0; @@ -81,6 +83,7 @@ public class EvaluationModelOrStringJsonConverter : global::System.Text.Json.Ser { try { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(string), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(string).Name}"); evaluationModelOrStringVariant1 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); @@ -91,9 +94,13 @@ public class EvaluationModelOrStringJsonConverter : global::System.Text.Json.Ser catch (global::System.InvalidOperationException) { } + } + if (evaluationModelOrStringVariant1 == null && request == null) + { try { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.EvaluationModelRequest), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.EvaluationModelRequest).Name}"); request = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); diff --git a/src/libs/Together/Generated/Together.JsonConverters.ExecuteResponse.g.cs b/src/libs/Together/Generated/Together.JsonConverters.ExecuteResponse.g.cs index 2a51576b..c5917d9a 100644 --- a/src/libs/Together/Generated/Together.JsonConverters.ExecuteResponse.g.cs +++ b/src/libs/Together/Generated/Together.JsonConverters.ExecuteResponse.g.cs @@ -23,11 +23,22 @@ public class ExecuteResponseJsonConverter : global::System.Text.Json.Serializati foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) { __jsonProps.Add(__jsonProp.Name); + if (__jsonProp.Value.ValueKind == global::System.Text.Json.JsonValueKind.Object) + { + foreach (var __nestedJsonProp in __jsonProp.Value.EnumerateObject()) + { + __jsonProps.Add(__jsonProp.Name + "." + __nestedJsonProp.Name); + } + } + } } var __score0 = 0; if (__jsonProps.Contains("data")) __score0++; + if (__jsonProps.Contains("data.outputs")) __score0++; + if (__jsonProps.Contains("data.session_id")) __score0++; + if (__jsonProps.Contains("data.status")) __score0++; if (__jsonProps.Contains("errors")) __score0++; var __score1 = 0; if (__jsonProps.Contains("data")) __score1++; @@ -77,6 +88,7 @@ public class ExecuteResponseJsonConverter : global::System.Text.Json.Serializati { try { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.ExecuteResponseSuccessfulExecution), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.ExecuteResponseSuccessfulExecution).Name}"); successfulExecution = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); @@ -87,9 +99,13 @@ public class ExecuteResponseJsonConverter : global::System.Text.Json.Serializati catch (global::System.InvalidOperationException) { } + } + if (successfulExecution == null && failedExecution == null) + { try { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.ExecuteResponseFailedExecution), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.ExecuteResponseFailedExecution).Name}"); failedExecution = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); diff --git a/src/libs/Together/Generated/Together.JsonConverters.ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorType.g.cs b/src/libs/Together/Generated/Together.JsonConverters.ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorType.g.cs new file mode 100644 index 00000000..4dfa6979 --- /dev/null +++ b/src/libs/Together/Generated/Together.JsonConverters.ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorType.g.cs @@ -0,0 +1,53 @@ +#nullable enable + +namespace Together.JsonConverters +{ + /// + public sealed class ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorTypeJsonConverter : global::System.Text.Json.Serialization.JsonConverter + { + /// + public override global::Together.ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorType Read( + ref global::System.Text.Json.Utf8JsonReader reader, + global::System.Type typeToConvert, + global::System.Text.Json.JsonSerializerOptions options) + { + switch (reader.TokenType) + { + case global::System.Text.Json.JsonTokenType.String: + { + var stringValue = reader.GetString(); + if (stringValue != null) + { + return global::Together.ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorTypeExtensions.ToEnum(stringValue) ?? default; + } + + break; + } + case global::System.Text.Json.JsonTokenType.Number: + { + var numValue = reader.GetInt32(); + return (global::Together.ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorType)numValue; + } + case global::System.Text.Json.JsonTokenType.Null: + { + return default(global::Together.ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorType); + } + default: + throw new global::System.ArgumentOutOfRangeException(nameof(reader)); + } + + return default; + } + + /// + public override void Write( + global::System.Text.Json.Utf8JsonWriter writer, + global::Together.ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorType value, + global::System.Text.Json.JsonSerializerOptions options) + { + writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); + + writer.WriteStringValue(global::Together.ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorTypeExtensions.ToValueString(value)); + } + } +} diff --git a/src/libs/Together/Generated/Together.JsonConverters.ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorTypeNullable.g.cs b/src/libs/Together/Generated/Together.JsonConverters.ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorTypeNullable.g.cs new file mode 100644 index 00000000..14ea0a6a --- /dev/null +++ b/src/libs/Together/Generated/Together.JsonConverters.ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorTypeNullable.g.cs @@ -0,0 +1,60 @@ +#nullable enable + +namespace Together.JsonConverters +{ + /// + public sealed class ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorTypeNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter + { + /// + public override global::Together.ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorType? Read( + ref global::System.Text.Json.Utf8JsonReader reader, + global::System.Type typeToConvert, + global::System.Text.Json.JsonSerializerOptions options) + { + switch (reader.TokenType) + { + case global::System.Text.Json.JsonTokenType.String: + { + var stringValue = reader.GetString(); + if (stringValue != null) + { + return global::Together.ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorTypeExtensions.ToEnum(stringValue); + } + + break; + } + case global::System.Text.Json.JsonTokenType.Number: + { + var numValue = reader.GetInt32(); + return (global::Together.ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorType)numValue; + } + case global::System.Text.Json.JsonTokenType.Null: + { + return default(global::Together.ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorType?); + } + default: + throw new global::System.ArgumentOutOfRangeException(nameof(reader)); + } + + return default; + } + + /// + public override void Write( + global::System.Text.Json.Utf8JsonWriter writer, + global::Together.ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorType? value, + global::System.Text.Json.JsonSerializerOptions options) + { + writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); + + if (value == null) + { + writer.WriteNullValue(); + } + else + { + writer.WriteStringValue(global::Together.ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorTypeExtensions.ToValueString(value.Value)); + } + } + } +} diff --git a/src/libs/Together/Generated/Together.JsonConverters.AudioTranslationVerboseJsonResponseTask.g.cs b/src/libs/Together/Generated/Together.JsonConverters.ImageResponseDataItemDiscriminatorType.g.cs similarity index 63% rename from src/libs/Together/Generated/Together.JsonConverters.AudioTranslationVerboseJsonResponseTask.g.cs rename to src/libs/Together/Generated/Together.JsonConverters.ImageResponseDataItemDiscriminatorType.g.cs index 505d23a5..0b6d7cf8 100644 --- a/src/libs/Together/Generated/Together.JsonConverters.AudioTranslationVerboseJsonResponseTask.g.cs +++ b/src/libs/Together/Generated/Together.JsonConverters.ImageResponseDataItemDiscriminatorType.g.cs @@ -3,10 +3,10 @@ namespace Together.JsonConverters { /// - public sealed class AudioTranslationVerboseJsonResponseTaskJsonConverter : global::System.Text.Json.Serialization.JsonConverter + public sealed class ImageResponseDataItemDiscriminatorTypeJsonConverter : global::System.Text.Json.Serialization.JsonConverter { /// - public override global::Together.AudioTranslationVerboseJsonResponseTask Read( + public override global::Together.ImageResponseDataItemDiscriminatorType Read( ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) @@ -18,7 +18,7 @@ public sealed class AudioTranslationVerboseJsonResponseTaskJsonConverter : globa var stringValue = reader.GetString(); if (stringValue != null) { - return global::Together.AudioTranslationVerboseJsonResponseTaskExtensions.ToEnum(stringValue) ?? default; + return global::Together.ImageResponseDataItemDiscriminatorTypeExtensions.ToEnum(stringValue) ?? default; } break; @@ -26,11 +26,11 @@ public sealed class AudioTranslationVerboseJsonResponseTaskJsonConverter : globa case global::System.Text.Json.JsonTokenType.Number: { var numValue = reader.GetInt32(); - return (global::Together.AudioTranslationVerboseJsonResponseTask)numValue; + return (global::Together.ImageResponseDataItemDiscriminatorType)numValue; } case global::System.Text.Json.JsonTokenType.Null: { - return default(global::Together.AudioTranslationVerboseJsonResponseTask); + return default(global::Together.ImageResponseDataItemDiscriminatorType); } default: throw new global::System.ArgumentOutOfRangeException(nameof(reader)); @@ -42,12 +42,12 @@ public sealed class AudioTranslationVerboseJsonResponseTaskJsonConverter : globa /// public override void Write( global::System.Text.Json.Utf8JsonWriter writer, - global::Together.AudioTranslationVerboseJsonResponseTask value, + global::Together.ImageResponseDataItemDiscriminatorType value, global::System.Text.Json.JsonSerializerOptions options) { writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); - writer.WriteStringValue(global::Together.AudioTranslationVerboseJsonResponseTaskExtensions.ToValueString(value)); + writer.WriteStringValue(global::Together.ImageResponseDataItemDiscriminatorTypeExtensions.ToValueString(value)); } } } diff --git a/src/libs/Together/Generated/Together.JsonConverters.AudioTranslationVerboseJsonResponseTaskNullable.g.cs b/src/libs/Together/Generated/Together.JsonConverters.ImageResponseDataItemDiscriminatorTypeNullable.g.cs similarity index 65% rename from src/libs/Together/Generated/Together.JsonConverters.AudioTranslationVerboseJsonResponseTaskNullable.g.cs rename to src/libs/Together/Generated/Together.JsonConverters.ImageResponseDataItemDiscriminatorTypeNullable.g.cs index 105795ef..a1245b15 100644 --- a/src/libs/Together/Generated/Together.JsonConverters.AudioTranslationVerboseJsonResponseTaskNullable.g.cs +++ b/src/libs/Together/Generated/Together.JsonConverters.ImageResponseDataItemDiscriminatorTypeNullable.g.cs @@ -3,10 +3,10 @@ namespace Together.JsonConverters { /// - public sealed class AudioTranslationVerboseJsonResponseTaskNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter + public sealed class ImageResponseDataItemDiscriminatorTypeNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter { /// - public override global::Together.AudioTranslationVerboseJsonResponseTask? Read( + public override global::Together.ImageResponseDataItemDiscriminatorType? Read( ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) @@ -18,7 +18,7 @@ public sealed class AudioTranslationVerboseJsonResponseTaskNullableJsonConverter var stringValue = reader.GetString(); if (stringValue != null) { - return global::Together.AudioTranslationVerboseJsonResponseTaskExtensions.ToEnum(stringValue); + return global::Together.ImageResponseDataItemDiscriminatorTypeExtensions.ToEnum(stringValue); } break; @@ -26,11 +26,11 @@ public sealed class AudioTranslationVerboseJsonResponseTaskNullableJsonConverter case global::System.Text.Json.JsonTokenType.Number: { var numValue = reader.GetInt32(); - return (global::Together.AudioTranslationVerboseJsonResponseTask)numValue; + return (global::Together.ImageResponseDataItemDiscriminatorType)numValue; } case global::System.Text.Json.JsonTokenType.Null: { - return default(global::Together.AudioTranslationVerboseJsonResponseTask?); + return default(global::Together.ImageResponseDataItemDiscriminatorType?); } default: throw new global::System.ArgumentOutOfRangeException(nameof(reader)); @@ -42,7 +42,7 @@ public sealed class AudioTranslationVerboseJsonResponseTaskNullableJsonConverter /// public override void Write( global::System.Text.Json.Utf8JsonWriter writer, - global::Together.AudioTranslationVerboseJsonResponseTask? value, + global::Together.ImageResponseDataItemDiscriminatorType? value, global::System.Text.Json.JsonSerializerOptions options) { writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); @@ -53,7 +53,7 @@ public override void Write( } else { - writer.WriteStringValue(global::Together.AudioTranslationVerboseJsonResponseTaskExtensions.ToValueString(value.Value)); + writer.WriteStringValue(global::Together.ImageResponseDataItemDiscriminatorTypeExtensions.ToValueString(value.Value)); } } } diff --git a/src/libs/Together/Generated/Together.JsonConverters.InterpreterOutput.g.cs b/src/libs/Together/Generated/Together.JsonConverters.InterpreterOutput.g.cs index b048f22e..d544e2b5 100644 --- a/src/libs/Together/Generated/Together.JsonConverters.InterpreterOutput.g.cs +++ b/src/libs/Together/Generated/Together.JsonConverters.InterpreterOutput.g.cs @@ -23,6 +23,14 @@ public class InterpreterOutputJsonConverter : global::System.Text.Json.Serializa foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) { __jsonProps.Add(__jsonProp.Name); + if (__jsonProp.Value.ValueKind == global::System.Text.Json.JsonValueKind.Object) + { + foreach (var __nestedJsonProp in __jsonProp.Value.EnumerateObject()) + { + __jsonProps.Add(__jsonProp.Name + "." + __nestedJsonProp.Name); + } + } + } } @@ -34,6 +42,20 @@ public class InterpreterOutputJsonConverter : global::System.Text.Json.Serializa if (__jsonProps.Contains("type")) __score1++; var __score2 = 0; if (__jsonProps.Contains("data")) __score2++; + if (__jsonProps.Contains("data.application/geo+json")) __score2++; + if (__jsonProps.Contains("data.application/javascript")) __score2++; + if (__jsonProps.Contains("data.application/json")) __score2++; + if (__jsonProps.Contains("data.application/pdf")) __score2++; + if (__jsonProps.Contains("data.application/vnd.vega.v5+json")) __score2++; + if (__jsonProps.Contains("data.application/vnd.vegalite.v4+json")) __score2++; + if (__jsonProps.Contains("data.image/gif")) __score2++; + if (__jsonProps.Contains("data.image/jpeg")) __score2++; + if (__jsonProps.Contains("data.image/png")) __score2++; + if (__jsonProps.Contains("data.image/svg+xml")) __score2++; + if (__jsonProps.Contains("data.text/html")) __score2++; + if (__jsonProps.Contains("data.text/latex")) __score2++; + if (__jsonProps.Contains("data.text/markdown")) __score2++; + if (__jsonProps.Contains("data.text/plain")) __score2++; if (__jsonProps.Contains("type")) __score2++; var __bestScore = 0; var __bestIndex = -1; @@ -97,6 +119,7 @@ public class InterpreterOutputJsonConverter : global::System.Text.Json.Serializa { try { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.InterpreterOutputStreamOutput), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.InterpreterOutputStreamOutput).Name}"); streamOutput = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); @@ -107,9 +130,13 @@ public class InterpreterOutputJsonConverter : global::System.Text.Json.Serializa catch (global::System.InvalidOperationException) { } + } + if (streamOutput == null && error == null && displayorExecuteOutput == null) + { try { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.InterpreterOutputErrorOutput), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.InterpreterOutputErrorOutput).Name}"); error = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); @@ -120,9 +147,13 @@ public class InterpreterOutputJsonConverter : global::System.Text.Json.Serializa catch (global::System.InvalidOperationException) { } + } + if (streamOutput == null && error == null && displayorExecuteOutput == null) + { try { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.InterpreterOutputDisplayorExecuteOutput), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.InterpreterOutputDisplayorExecuteOutput).Name}"); displayorExecuteOutput = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); diff --git a/src/libs/Together/Generated/Together.JsonConverters.GPUClusterCreateRequestDriverVersion.g.cs b/src/libs/Together/Generated/Together.JsonConverters.InterpreterOutputDiscriminatorType.g.cs similarity index 64% rename from src/libs/Together/Generated/Together.JsonConverters.GPUClusterCreateRequestDriverVersion.g.cs rename to src/libs/Together/Generated/Together.JsonConverters.InterpreterOutputDiscriminatorType.g.cs index f4ef0498..919da1c1 100644 --- a/src/libs/Together/Generated/Together.JsonConverters.GPUClusterCreateRequestDriverVersion.g.cs +++ b/src/libs/Together/Generated/Together.JsonConverters.InterpreterOutputDiscriminatorType.g.cs @@ -3,10 +3,10 @@ namespace Together.JsonConverters { /// - public sealed class GPUClusterCreateRequestDriverVersionJsonConverter : global::System.Text.Json.Serialization.JsonConverter + public sealed class InterpreterOutputDiscriminatorTypeJsonConverter : global::System.Text.Json.Serialization.JsonConverter { /// - public override global::Together.GPUClusterCreateRequestDriverVersion Read( + public override global::Together.InterpreterOutputDiscriminatorType Read( ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) @@ -18,7 +18,7 @@ public sealed class GPUClusterCreateRequestDriverVersionJsonConverter : global:: var stringValue = reader.GetString(); if (stringValue != null) { - return global::Together.GPUClusterCreateRequestDriverVersionExtensions.ToEnum(stringValue) ?? default; + return global::Together.InterpreterOutputDiscriminatorTypeExtensions.ToEnum(stringValue) ?? default; } break; @@ -26,11 +26,11 @@ public sealed class GPUClusterCreateRequestDriverVersionJsonConverter : global:: case global::System.Text.Json.JsonTokenType.Number: { var numValue = reader.GetInt32(); - return (global::Together.GPUClusterCreateRequestDriverVersion)numValue; + return (global::Together.InterpreterOutputDiscriminatorType)numValue; } case global::System.Text.Json.JsonTokenType.Null: { - return default(global::Together.GPUClusterCreateRequestDriverVersion); + return default(global::Together.InterpreterOutputDiscriminatorType); } default: throw new global::System.ArgumentOutOfRangeException(nameof(reader)); @@ -42,12 +42,12 @@ public sealed class GPUClusterCreateRequestDriverVersionJsonConverter : global:: /// public override void Write( global::System.Text.Json.Utf8JsonWriter writer, - global::Together.GPUClusterCreateRequestDriverVersion value, + global::Together.InterpreterOutputDiscriminatorType value, global::System.Text.Json.JsonSerializerOptions options) { writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); - writer.WriteStringValue(global::Together.GPUClusterCreateRequestDriverVersionExtensions.ToValueString(value)); + writer.WriteStringValue(global::Together.InterpreterOutputDiscriminatorTypeExtensions.ToValueString(value)); } } } diff --git a/src/libs/Together/Generated/Together.JsonConverters.GPUClusterCreateRequestDriverVersionNullable.g.cs b/src/libs/Together/Generated/Together.JsonConverters.InterpreterOutputDiscriminatorTypeNullable.g.cs similarity index 66% rename from src/libs/Together/Generated/Together.JsonConverters.GPUClusterCreateRequestDriverVersionNullable.g.cs rename to src/libs/Together/Generated/Together.JsonConverters.InterpreterOutputDiscriminatorTypeNullable.g.cs index 9de9e4e3..b38812e4 100644 --- a/src/libs/Together/Generated/Together.JsonConverters.GPUClusterCreateRequestDriverVersionNullable.g.cs +++ b/src/libs/Together/Generated/Together.JsonConverters.InterpreterOutputDiscriminatorTypeNullable.g.cs @@ -3,10 +3,10 @@ namespace Together.JsonConverters { /// - public sealed class GPUClusterCreateRequestDriverVersionNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter + public sealed class InterpreterOutputDiscriminatorTypeNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter { /// - public override global::Together.GPUClusterCreateRequestDriverVersion? Read( + public override global::Together.InterpreterOutputDiscriminatorType? Read( ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) @@ -18,7 +18,7 @@ public sealed class GPUClusterCreateRequestDriverVersionNullableJsonConverter : var stringValue = reader.GetString(); if (stringValue != null) { - return global::Together.GPUClusterCreateRequestDriverVersionExtensions.ToEnum(stringValue); + return global::Together.InterpreterOutputDiscriminatorTypeExtensions.ToEnum(stringValue); } break; @@ -26,11 +26,11 @@ public sealed class GPUClusterCreateRequestDriverVersionNullableJsonConverter : case global::System.Text.Json.JsonTokenType.Number: { var numValue = reader.GetInt32(); - return (global::Together.GPUClusterCreateRequestDriverVersion)numValue; + return (global::Together.InterpreterOutputDiscriminatorType)numValue; } case global::System.Text.Json.JsonTokenType.Null: { - return default(global::Together.GPUClusterCreateRequestDriverVersion?); + return default(global::Together.InterpreterOutputDiscriminatorType?); } default: throw new global::System.ArgumentOutOfRangeException(nameof(reader)); @@ -42,7 +42,7 @@ public sealed class GPUClusterCreateRequestDriverVersionNullableJsonConverter : /// public override void Write( global::System.Text.Json.Utf8JsonWriter writer, - global::Together.GPUClusterCreateRequestDriverVersion? value, + global::Together.InterpreterOutputDiscriminatorType? value, global::System.Text.Json.JsonSerializerOptions options) { writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); @@ -53,7 +53,7 @@ public override void Write( } else { - writer.WriteStringValue(global::Together.GPUClusterCreateRequestDriverVersionExtensions.ToValueString(value.Value)); + writer.WriteStringValue(global::Together.InterpreterOutputDiscriminatorTypeExtensions.ToValueString(value.Value)); } } } diff --git a/src/libs/Together/Generated/Together.JsonConverters.OneOf2.g.cs b/src/libs/Together/Generated/Together.JsonConverters.OneOf2.g.cs index 4baf0013..8e5486a1 100644 --- a/src/libs/Together/Generated/Together.JsonConverters.OneOf2.g.cs +++ b/src/libs/Together/Generated/Together.JsonConverters.OneOf2.g.cs @@ -3,7 +3,7 @@ namespace Together.JsonConverters { /// - public class OneOfJsonConverter<[global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T1, [global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T2> : global::System.Text.Json.Serialization.JsonConverter> + public class OneOfJsonConverter : global::System.Text.Json.Serialization.JsonConverter> { /// public override global::Together.OneOf Read( @@ -107,7 +107,10 @@ public class OneOfJsonConverter<[global::System.Diagnostics.CodeAnalysis.Dynamic catch (global::System.InvalidOperationException) { } + } + if (value1 == null && value2 == null) + { try { diff --git a/src/libs/Together/Generated/Together.JsonConverters.OneOf3.g.cs b/src/libs/Together/Generated/Together.JsonConverters.OneOf3.g.cs index 29ac9340..de5b9b8e 100644 --- a/src/libs/Together/Generated/Together.JsonConverters.OneOf3.g.cs +++ b/src/libs/Together/Generated/Together.JsonConverters.OneOf3.g.cs @@ -3,7 +3,7 @@ namespace Together.JsonConverters { /// - public class OneOfJsonConverter<[global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T1, [global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T2, [global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T3> : global::System.Text.Json.Serialization.JsonConverter> + public class OneOfJsonConverter : global::System.Text.Json.Serialization.JsonConverter> { /// public override global::Together.OneOf Read( @@ -137,7 +137,10 @@ public class OneOfJsonConverter<[global::System.Diagnostics.CodeAnalysis.Dynamic catch (global::System.InvalidOperationException) { } + } + if (value1 == null && value2 == null && value3 == null) + { try { @@ -151,7 +154,10 @@ public class OneOfJsonConverter<[global::System.Diagnostics.CodeAnalysis.Dynamic catch (global::System.InvalidOperationException) { } + } + if (value1 == null && value2 == null && value3 == null) + { try { diff --git a/src/libs/Together/Generated/Together.JsonConverters.OneOf4.g.cs b/src/libs/Together/Generated/Together.JsonConverters.OneOf4.g.cs index f95330fa..38bd3c48 100644 --- a/src/libs/Together/Generated/Together.JsonConverters.OneOf4.g.cs +++ b/src/libs/Together/Generated/Together.JsonConverters.OneOf4.g.cs @@ -3,7 +3,7 @@ namespace Together.JsonConverters { /// - public class OneOfJsonConverter<[global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T1, [global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T2, [global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T3, [global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T4> : global::System.Text.Json.Serialization.JsonConverter> + public class OneOfJsonConverter : global::System.Text.Json.Serialization.JsonConverter> { /// public override global::Together.OneOf Read( @@ -167,7 +167,10 @@ public class OneOfJsonConverter<[global::System.Diagnostics.CodeAnalysis.Dynamic catch (global::System.InvalidOperationException) { } + } + if (value1 == null && value2 == null && value3 == null && value4 == null) + { try { @@ -181,7 +184,10 @@ public class OneOfJsonConverter<[global::System.Diagnostics.CodeAnalysis.Dynamic catch (global::System.InvalidOperationException) { } + } + if (value1 == null && value2 == null && value3 == null && value4 == null) + { try { @@ -195,7 +201,10 @@ public class OneOfJsonConverter<[global::System.Diagnostics.CodeAnalysis.Dynamic catch (global::System.InvalidOperationException) { } + } + if (value1 == null && value2 == null && value3 == null && value4 == null) + { try { diff --git a/src/libs/Together/Generated/Together.JsonConverters.OneOf5.g.cs b/src/libs/Together/Generated/Together.JsonConverters.OneOf5.g.cs index ac97f620..758834b2 100644 --- a/src/libs/Together/Generated/Together.JsonConverters.OneOf5.g.cs +++ b/src/libs/Together/Generated/Together.JsonConverters.OneOf5.g.cs @@ -3,7 +3,7 @@ namespace Together.JsonConverters { /// - public class OneOfJsonConverter<[global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T1, [global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T2, [global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T3, [global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T4, [global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T5> : global::System.Text.Json.Serialization.JsonConverter> + public class OneOfJsonConverter : global::System.Text.Json.Serialization.JsonConverter> { /// public override global::Together.OneOf Read( @@ -197,7 +197,10 @@ public class OneOfJsonConverter<[global::System.Diagnostics.CodeAnalysis.Dynamic catch (global::System.InvalidOperationException) { } + } + if (value1 == null && value2 == null && value3 == null && value4 == null && value5 == null) + { try { @@ -211,7 +214,10 @@ public class OneOfJsonConverter<[global::System.Diagnostics.CodeAnalysis.Dynamic catch (global::System.InvalidOperationException) { } + } + if (value1 == null && value2 == null && value3 == null && value4 == null && value5 == null) + { try { @@ -225,7 +231,10 @@ public class OneOfJsonConverter<[global::System.Diagnostics.CodeAnalysis.Dynamic catch (global::System.InvalidOperationException) { } + } + if (value1 == null && value2 == null && value3 == null && value4 == null && value5 == null) + { try { @@ -239,7 +248,10 @@ public class OneOfJsonConverter<[global::System.Diagnostics.CodeAnalysis.Dynamic catch (global::System.InvalidOperationException) { } + } + if (value1 == null && value2 == null && value3 == null && value4 == null && value5 == null) + { try { diff --git a/src/libs/Together/Generated/Together.JsonConverters.OutputsItem.g.cs b/src/libs/Together/Generated/Together.JsonConverters.OutputsItem.g.cs index 2fc16d7b..85453377 100644 --- a/src/libs/Together/Generated/Together.JsonConverters.OutputsItem.g.cs +++ b/src/libs/Together/Generated/Together.JsonConverters.OutputsItem.g.cs @@ -23,6 +23,14 @@ public class OutputsItemJsonConverter : global::System.Text.Json.Serialization.J foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) { __jsonProps.Add(__jsonProp.Name); + if (__jsonProp.Value.ValueKind == global::System.Text.Json.JsonValueKind.Object) + { + foreach (var __nestedJsonProp in __jsonProp.Value.EnumerateObject()) + { + __jsonProps.Add(__jsonProp.Name + "." + __nestedJsonProp.Name); + } + } + } } @@ -34,6 +42,20 @@ public class OutputsItemJsonConverter : global::System.Text.Json.Serialization.J if (__jsonProps.Contains("type")) __score1++; var __score2 = 0; if (__jsonProps.Contains("data")) __score2++; + if (__jsonProps.Contains("data.application/geo+json")) __score2++; + if (__jsonProps.Contains("data.application/javascript")) __score2++; + if (__jsonProps.Contains("data.application/json")) __score2++; + if (__jsonProps.Contains("data.application/pdf")) __score2++; + if (__jsonProps.Contains("data.application/vnd.vega.v5+json")) __score2++; + if (__jsonProps.Contains("data.application/vnd.vegalite.v4+json")) __score2++; + if (__jsonProps.Contains("data.image/gif")) __score2++; + if (__jsonProps.Contains("data.image/jpeg")) __score2++; + if (__jsonProps.Contains("data.image/png")) __score2++; + if (__jsonProps.Contains("data.image/svg+xml")) __score2++; + if (__jsonProps.Contains("data.text/html")) __score2++; + if (__jsonProps.Contains("data.text/latex")) __score2++; + if (__jsonProps.Contains("data.text/markdown")) __score2++; + if (__jsonProps.Contains("data.text/plain")) __score2++; if (__jsonProps.Contains("type")) __score2++; var __bestScore = 0; var __bestIndex = -1; @@ -97,6 +119,7 @@ public class OutputsItemJsonConverter : global::System.Text.Json.Serialization.J { try { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.ExecuteResponseSuccessfulExecutionDataOutputStreamOutput), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.ExecuteResponseSuccessfulExecutionDataOutputStreamOutput).Name}"); streamOutput = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); @@ -107,9 +130,13 @@ public class OutputsItemJsonConverter : global::System.Text.Json.Serialization.J catch (global::System.InvalidOperationException) { } + } + if (streamOutput == null && error == null && displayorExecuteOutput == null) + { try { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.ExecuteResponseSuccessfulExecutionDataOutputErrorOutput), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.ExecuteResponseSuccessfulExecutionDataOutputErrorOutput).Name}"); error = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); @@ -120,9 +147,13 @@ public class OutputsItemJsonConverter : global::System.Text.Json.Serialization.J catch (global::System.InvalidOperationException) { } + } + if (streamOutput == null && error == null && displayorExecuteOutput == null) + { try { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutput), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutput).Name}"); displayorExecuteOutput = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); diff --git a/src/libs/Together/Generated/Together.JsonConverters.ResponseFormat.g.cs b/src/libs/Together/Generated/Together.JsonConverters.ResponseFormat.g.cs index e1beaa3c..3467c6d7 100644 --- a/src/libs/Together/Generated/Together.JsonConverters.ResponseFormat.g.cs +++ b/src/libs/Together/Generated/Together.JsonConverters.ResponseFormat.g.cs @@ -15,125 +15,36 @@ public class ResponseFormatJsonConverter : global::System.Text.Json.Serializatio options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); - using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); - var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - } - } - var __score0 = 0; - if (__jsonProps.Contains("type")) __score0++; - var __score1 = 0; - if (__jsonProps.Contains("json_schema")) __score1++; - if (__jsonProps.Contains("type")) __score1++; - var __score2 = 0; - if (__jsonProps.Contains("type")) __score2++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - if (__score2 > __bestScore) { __bestScore = __score2; __bestIndex = 2; } + var readerCopy = reader; + var discriminatorTypeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.ChatCompletionRequestResponseFormatDiscriminator), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::Together.ChatCompletionRequestResponseFormatDiscriminator)}"); + var discriminator = global::System.Text.Json.JsonSerializer.Deserialize(ref readerCopy, discriminatorTypeInfo); global::Together.ResponseFormatText? text = default; + if (discriminator?.Type == global::Together.ChatCompletionRequestResponseFormatDiscriminatorType.Text) + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.ResponseFormatText), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::Together.ResponseFormatText)}"); + text = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo); + } global::Together.ResponseFormatJsonSchema? jsonSchema = default; - global::Together.ResponseFormatJsonObject? jsonObject = default; - if (__bestIndex >= 0) + if (discriminator?.Type == global::Together.ChatCompletionRequestResponseFormatDiscriminatorType.JsonSchema) { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.ResponseFormatText), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.ResponseFormatText).Name}"); - text = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 1) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.ResponseFormatJsonSchema), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.ResponseFormatJsonSchema).Name}"); - jsonSchema = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 2) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.ResponseFormatJsonObject), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.ResponseFormatJsonObject).Name}"); - jsonObject = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.ResponseFormatJsonSchema), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::Together.ResponseFormatJsonSchema)}"); + jsonSchema = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo); } - - if (text == null && jsonSchema == null && jsonObject == null) + global::Together.ResponseFormatJsonObject? jsonObject = default; + if (discriminator?.Type == global::Together.ChatCompletionRequestResponseFormatDiscriminatorType.JsonObject) { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.ResponseFormatText), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.ResponseFormatText).Name}"); - text = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.ResponseFormatJsonSchema), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.ResponseFormatJsonSchema).Name}"); - jsonSchema = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.ResponseFormatJsonObject), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.ResponseFormatJsonObject).Name}"); - jsonObject = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.ResponseFormatJsonObject), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::Together.ResponseFormatJsonObject)}"); + jsonObject = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo); } var __value = new global::Together.ResponseFormat( + discriminator?.Type, text, jsonSchema, diff --git a/src/libs/Together/Generated/Together.JsonConverters.GPUClusterInfoDriverVersion.g.cs b/src/libs/Together/Generated/Together.JsonConverters.RlSessionType.g.cs similarity index 66% rename from src/libs/Together/Generated/Together.JsonConverters.GPUClusterInfoDriverVersion.g.cs rename to src/libs/Together/Generated/Together.JsonConverters.RlSessionType.g.cs index ae95c026..38e7e3ed 100644 --- a/src/libs/Together/Generated/Together.JsonConverters.GPUClusterInfoDriverVersion.g.cs +++ b/src/libs/Together/Generated/Together.JsonConverters.RlSessionType.g.cs @@ -3,10 +3,10 @@ namespace Together.JsonConverters { /// - public sealed class GPUClusterInfoDriverVersionJsonConverter : global::System.Text.Json.Serialization.JsonConverter + public sealed class RlSessionTypeJsonConverter : global::System.Text.Json.Serialization.JsonConverter { /// - public override global::Together.GPUClusterInfoDriverVersion Read( + public override global::Together.RlSessionType Read( ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) @@ -18,7 +18,7 @@ public sealed class GPUClusterInfoDriverVersionJsonConverter : global::System.Te var stringValue = reader.GetString(); if (stringValue != null) { - return global::Together.GPUClusterInfoDriverVersionExtensions.ToEnum(stringValue) ?? default; + return global::Together.RlSessionTypeExtensions.ToEnum(stringValue) ?? default; } break; @@ -26,11 +26,11 @@ public sealed class GPUClusterInfoDriverVersionJsonConverter : global::System.Te case global::System.Text.Json.JsonTokenType.Number: { var numValue = reader.GetInt32(); - return (global::Together.GPUClusterInfoDriverVersion)numValue; + return (global::Together.RlSessionType)numValue; } case global::System.Text.Json.JsonTokenType.Null: { - return default(global::Together.GPUClusterInfoDriverVersion); + return default(global::Together.RlSessionType); } default: throw new global::System.ArgumentOutOfRangeException(nameof(reader)); @@ -42,12 +42,12 @@ public sealed class GPUClusterInfoDriverVersionJsonConverter : global::System.Te /// public override void Write( global::System.Text.Json.Utf8JsonWriter writer, - global::Together.GPUClusterInfoDriverVersion value, + global::Together.RlSessionType value, global::System.Text.Json.JsonSerializerOptions options) { writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); - writer.WriteStringValue(global::Together.GPUClusterInfoDriverVersionExtensions.ToValueString(value)); + writer.WriteStringValue(global::Together.RlSessionTypeExtensions.ToValueString(value)); } } } diff --git a/src/libs/Together/Generated/Together.JsonConverters.GPUClusterInfoDriverVersionNullable.g.cs b/src/libs/Together/Generated/Together.JsonConverters.RlSessionTypeNullable.g.cs similarity index 68% rename from src/libs/Together/Generated/Together.JsonConverters.GPUClusterInfoDriverVersionNullable.g.cs rename to src/libs/Together/Generated/Together.JsonConverters.RlSessionTypeNullable.g.cs index 41afdfc3..9b0cb954 100644 --- a/src/libs/Together/Generated/Together.JsonConverters.GPUClusterInfoDriverVersionNullable.g.cs +++ b/src/libs/Together/Generated/Together.JsonConverters.RlSessionTypeNullable.g.cs @@ -3,10 +3,10 @@ namespace Together.JsonConverters { /// - public sealed class GPUClusterInfoDriverVersionNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter + public sealed class RlSessionTypeNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter { /// - public override global::Together.GPUClusterInfoDriverVersion? Read( + public override global::Together.RlSessionType? Read( ref global::System.Text.Json.Utf8JsonReader reader, global::System.Type typeToConvert, global::System.Text.Json.JsonSerializerOptions options) @@ -18,7 +18,7 @@ public sealed class GPUClusterInfoDriverVersionNullableJsonConverter : global::S var stringValue = reader.GetString(); if (stringValue != null) { - return global::Together.GPUClusterInfoDriverVersionExtensions.ToEnum(stringValue); + return global::Together.RlSessionTypeExtensions.ToEnum(stringValue); } break; @@ -26,11 +26,11 @@ public sealed class GPUClusterInfoDriverVersionNullableJsonConverter : global::S case global::System.Text.Json.JsonTokenType.Number: { var numValue = reader.GetInt32(); - return (global::Together.GPUClusterInfoDriverVersion)numValue; + return (global::Together.RlSessionType)numValue; } case global::System.Text.Json.JsonTokenType.Null: { - return default(global::Together.GPUClusterInfoDriverVersion?); + return default(global::Together.RlSessionType?); } default: throw new global::System.ArgumentOutOfRangeException(nameof(reader)); @@ -42,7 +42,7 @@ public sealed class GPUClusterInfoDriverVersionNullableJsonConverter : global::S /// public override void Write( global::System.Text.Json.Utf8JsonWriter writer, - global::Together.GPUClusterInfoDriverVersion? value, + global::Together.RlSessionType? value, global::System.Text.Json.JsonSerializerOptions options) { writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); @@ -53,7 +53,7 @@ public override void Write( } else { - writer.WriteStringValue(global::Together.GPUClusterInfoDriverVersionExtensions.ToValueString(value.Value)); + writer.WriteStringValue(global::Together.RlSessionTypeExtensions.ToValueString(value.Value)); } } } diff --git a/src/libs/Together/Generated/Together.JsonConverters.SessionListResponse.g.cs b/src/libs/Together/Generated/Together.JsonConverters.SessionListResponse.g.cs index 4898bc4e..ce0bf935 100644 --- a/src/libs/Together/Generated/Together.JsonConverters.SessionListResponse.g.cs +++ b/src/libs/Together/Generated/Together.JsonConverters.SessionListResponse.g.cs @@ -23,6 +23,14 @@ public class SessionListResponseJsonConverter : global::System.Text.Json.Seriali foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) { __jsonProps.Add(__jsonProp.Name); + if (__jsonProp.Value.ValueKind == global::System.Text.Json.JsonValueKind.Object) + { + foreach (var __nestedJsonProp in __jsonProp.Value.EnumerateObject()) + { + __jsonProps.Add(__jsonProp.Name + "." + __nestedJsonProp.Name); + } + } + } } @@ -30,6 +38,7 @@ public class SessionListResponseJsonConverter : global::System.Text.Json.Seriali if (__jsonProps.Contains("errors")) __score0++; var __score1 = 0; if (__jsonProps.Contains("data")) __score1++; + if (__jsonProps.Contains("data.sessions")) __score1++; var __bestScore = 0; var __bestIndex = -1; if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } @@ -75,6 +84,7 @@ public class SessionListResponseJsonConverter : global::System.Text.Json.Seriali { try { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.SessionListResponseResponse), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.SessionListResponseResponse).Name}"); response = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); @@ -85,9 +95,13 @@ public class SessionListResponseJsonConverter : global::System.Text.Json.Seriali catch (global::System.InvalidOperationException) { } + } + if (response == null && sessionListResponseVariant2 == null) + { try { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Together.SessionListResponseVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Together.SessionListResponseVariant2).Name}"); sessionListResponseVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); diff --git a/src/libs/Together/Generated/Together.JsonSerializerContext.g.cs b/src/libs/Together/Generated/Together.JsonSerializerContext.g.cs index 44837667..77355a8a 100644 --- a/src/libs/Together/Generated/Together.JsonSerializerContext.g.cs +++ b/src/libs/Together/Generated/Together.JsonSerializerContext.g.cs @@ -33,6 +33,10 @@ namespace Together typeof(global::Together.JsonConverters.RlTrainingOperationStatusNullableJsonConverter), + typeof(global::Together.JsonConverters.RlSessionTypeJsonConverter), + + typeof(global::Together.JsonConverters.RlSessionTypeNullableJsonConverter), + typeof(global::Together.JsonConverters.RlTrainingSessionStatusJsonConverter), typeof(global::Together.JsonConverters.RlTrainingSessionStatusNullableJsonConverter), @@ -49,10 +53,6 @@ namespace Together typeof(global::Together.JsonConverters.GPUClusterCreateRequestGpuTypeNullableJsonConverter), - typeof(global::Together.JsonConverters.GPUClusterCreateRequestDriverVersionJsonConverter), - - typeof(global::Together.JsonConverters.GPUClusterCreateRequestDriverVersionNullableJsonConverter), - typeof(global::Together.JsonConverters.GPUClusterCreateRequestBillingTypeJsonConverter), typeof(global::Together.JsonConverters.GPUClusterCreateRequestBillingTypeNullableJsonConverter), @@ -65,10 +65,6 @@ namespace Together typeof(global::Together.JsonConverters.GPUClusterInfoGpuTypeNullableJsonConverter), - typeof(global::Together.JsonConverters.GPUClusterInfoDriverVersionJsonConverter), - - typeof(global::Together.JsonConverters.GPUClusterInfoDriverVersionNullableJsonConverter), - typeof(global::Together.JsonConverters.GPUClusterInfoStatusJsonConverter), typeof(global::Together.JsonConverters.GPUClusterInfoStatusNullableJsonConverter), @@ -121,6 +117,10 @@ namespace Together typeof(global::Together.JsonConverters.ChatCompletionRequestFunctionCallEnumNullableJsonConverter), + typeof(global::Together.JsonConverters.ChatCompletionRequestResponseFormatDiscriminatorTypeJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionRequestResponseFormatDiscriminatorTypeNullableJsonConverter), + typeof(global::Together.JsonConverters.ChatCompletionRequestReasoningEffortJsonConverter), typeof(global::Together.JsonConverters.ChatCompletionRequestReasoningEffortNullableJsonConverter), @@ -193,10 +193,6 @@ namespace Together typeof(global::Together.JsonConverters.AudioSpeechRequestResponseFormatNullableJsonConverter), - typeof(global::Together.JsonConverters.AudioSpeechRequestLanguageJsonConverter), - - typeof(global::Together.JsonConverters.AudioSpeechRequestLanguageNullableJsonConverter), - typeof(global::Together.JsonConverters.AudioSpeechRequestResponseEncodingJsonConverter), typeof(global::Together.JsonConverters.AudioSpeechRequestResponseEncodingNullableJsonConverter), @@ -217,10 +213,6 @@ namespace Together typeof(global::Together.JsonConverters.AudioTranscriptionRequestTimestampGranularitieNullableJsonConverter), - typeof(global::Together.JsonConverters.AudioTranscriptionVerboseJsonResponseTaskJsonConverter), - - typeof(global::Together.JsonConverters.AudioTranscriptionVerboseJsonResponseTaskNullableJsonConverter), - typeof(global::Together.JsonConverters.AudioTranslationRequestModelJsonConverter), typeof(global::Together.JsonConverters.AudioTranslationRequestModelNullableJsonConverter), @@ -237,10 +229,6 @@ namespace Together typeof(global::Together.JsonConverters.AudioTranslationRequestTimestampGranularitieNullableJsonConverter), - typeof(global::Together.JsonConverters.AudioTranslationVerboseJsonResponseTaskJsonConverter), - - typeof(global::Together.JsonConverters.AudioTranslationVerboseJsonResponseTaskNullableJsonConverter), - typeof(global::Together.JsonConverters.StreamSentinelDataJsonConverter), typeof(global::Together.JsonConverters.StreamSentinelDataNullableJsonConverter), @@ -261,6 +249,10 @@ namespace Together typeof(global::Together.JsonConverters.ModelUploadRequestModelTypeNullableJsonConverter), + typeof(global::Together.JsonConverters.ImageResponseDataItemDiscriminatorTypeJsonConverter), + + typeof(global::Together.JsonConverters.ImageResponseDataItemDiscriminatorTypeNullableJsonConverter), + typeof(global::Together.JsonConverters.ImageResponseDataB64TypeJsonConverter), typeof(global::Together.JsonConverters.ImageResponseDataB64TypeNullableJsonConverter), @@ -381,6 +373,10 @@ namespace Together typeof(global::Together.JsonConverters.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutputTypeNullableJsonConverter), + typeof(global::Together.JsonConverters.ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorTypeJsonConverter), + + typeof(global::Together.JsonConverters.ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorTypeNullableJsonConverter), + typeof(global::Together.JsonConverters.ExecuteResponseSuccessfulExecutionDataStatusJsonConverter), typeof(global::Together.JsonConverters.ExecuteResponseSuccessfulExecutionDataStatusNullableJsonConverter), @@ -397,10 +393,18 @@ namespace Together typeof(global::Together.JsonConverters.InterpreterOutputDisplayorExecuteOutputTypeNullableJsonConverter), + typeof(global::Together.JsonConverters.InterpreterOutputDiscriminatorTypeJsonConverter), + + typeof(global::Together.JsonConverters.InterpreterOutputDiscriminatorTypeNullableJsonConverter), + typeof(global::Together.JsonConverters.StreamOutputTypeJsonConverter), typeof(global::Together.JsonConverters.StreamOutputTypeNullableJsonConverter), + typeof(global::Together.JsonConverters.CreateBatchRequestEndpointJsonConverter), + + typeof(global::Together.JsonConverters.CreateBatchRequestEndpointNullableJsonConverter), + typeof(global::Together.JsonConverters.BatchJobStatusJsonConverter), typeof(global::Together.JsonConverters.BatchJobStatusNullableJsonConverter), @@ -573,6 +577,20 @@ namespace Together typeof(global::Together.JsonConverters.OneOfJsonConverter), + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + typeof(global::Together.JsonConverters.AnyOfJsonConverter), typeof(global::Together.JsonConverters.OneOfJsonConverter, global::System.Collections.Generic.IList>), @@ -665,6 +683,10 @@ namespace Together typeof(global::Together.JsonConverters.UnixTimestampJsonConverter), })] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList>), TypeInfoPropertyName = "ChatCompletionUserMessageContentMultimodalItemInputAudio_9a6c1a339fc4e5a1")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.OneOf), TypeInfoPropertyName = "ChatCompletionUserMessageContentMultimodalItemInputAudio_e050a39467d446fd")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.OneOf?), TypeInfoPropertyName = "ChatCompletionUserMessageContentMultimodalItemInputAudio_f38c2c0c365e74fc")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>), TypeInfoPropertyName = "ChatCompletionUserMessageContentMultimodalItemInputAudio_6724b54fa98b04fd")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.JsonSerializerContextTypes))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.RlOptimStepBody))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(float))] @@ -683,11 +705,11 @@ namespace Together [global::System.Text.Json.Serialization.JsonSerializable(typeof(int))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(string))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.OneOf), TypeInfoPropertyName = "OneOfStringInt322")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.RlEncodedText))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.RlListMeta))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(bool))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList>))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.OneOf), TypeInfoPropertyName = "OneOfStringInt322")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.RlDType), TypeInfoPropertyName = "RlDType2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.RlLossType), TypeInfoPropertyName = "RlLossType2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.RlCrossEntropyLossParams))] @@ -717,6 +739,7 @@ namespace Together [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.Dictionary))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.RlTrainingOperationErrorCode), TypeInfoPropertyName = "RlTrainingOperationErrorCode2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.RlStartTrainingSessionRequest))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.RlSessionType), TypeInfoPropertyName = "RlSessionType2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.RlLoraConfig))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.RlTrainingSessionStatus), TypeInfoPropertyName = "RlTrainingSessionStatus2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.RlTrainingSession))] @@ -734,6 +757,7 @@ namespace Together [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.RlTrainingCheckpointOperation))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.RlCheckpointVariant), TypeInfoPropertyName = "RlCheckpointVariant2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.RlCheckpointFile))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.OneOf), TypeInfoPropertyName = "OneOfStringInt642")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.RlCheckpointDownloadResponse))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.ErrorResponse))] @@ -741,14 +765,12 @@ namespace Together [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.GPUClusterCreateRequest))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.GPUClusterCreateRequestClusterType), TypeInfoPropertyName = "GPUClusterCreateRequestClusterType2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.GPUClusterCreateRequestGpuType), TypeInfoPropertyName = "GPUClusterCreateRequestGpuType2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.GPUClusterCreateRequestDriverVersion), TypeInfoPropertyName = "GPUClusterCreateRequestDriverVersion2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.GPUClustersSharedVolumeCreateRequest))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.GPUClusterCreateRequestBillingType), TypeInfoPropertyName = "GPUClusterCreateRequestBillingType2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.GPUClusterGPUWorkerNode))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.GPUClusterInfo))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.GPUClusterInfoClusterType), TypeInfoPropertyName = "GPUClusterInfoClusterType2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.GPUClusterInfoGpuType), TypeInfoPropertyName = "GPUClusterInfoGpuType2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.GPUClusterInfoDriverVersion), TypeInfoPropertyName = "GPUClusterInfoDriverVersion2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.GPUClusterVolume))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.GPUClusterInfoStatus), TypeInfoPropertyName = "GPUClusterInfoStatus2")] @@ -840,6 +862,7 @@ namespace Together [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.ResponseFormatJsonSchema))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.ResponseFormatJsonObject))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.ChatCompletionRequestResponseFormatDiscriminator))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.ChatCompletionRequestResponseFormatDiscriminatorType), TypeInfoPropertyName = "ChatCompletionRequestResponseFormatDiscriminatorType2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.ToolsPart))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.OneOf), TypeInfoPropertyName = "OneOfStringToolChoice22")] @@ -858,8 +881,6 @@ namespace Together [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.ChatCompletionSystemMessageParamRole), TypeInfoPropertyName = "ChatCompletionSystemMessageParamRole2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.ChatCompletionUserMessageContent), TypeInfoPropertyName = "ChatCompletionUserMessageContent2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.ChatCompletionUserMessageParamRole), TypeInfoPropertyName = "ChatCompletionUserMessageParamRole2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList>), TypeInfoPropertyName = "ChatCompletionUserMessageContentMultimodalItemInputAudio_9a6c1a339fc4e5a1")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.OneOf), TypeInfoPropertyName = "ChatCompletionUserMessageContentMultimodalItemInputAudio_e050a39467d446fd")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.ChatCompletionUserMessageContentMultimodalItemVariant1))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.ChatCompletionUserMessageContentMultimodalItemVariant1Type), TypeInfoPropertyName = "ChatCompletionUserMessageContentMultimodalItemVariant1Type2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.ChatCompletionUserMessageContentMultimodalItemVariant2))] @@ -893,8 +914,8 @@ namespace Together [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.AnyOf), TypeInfoPropertyName = "AnyOfAudioSpeechRequestModelString2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.AudioSpeechRequestModel), TypeInfoPropertyName = "AudioSpeechRequestModel2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.AudioSpeechRequestResponseFormat), TypeInfoPropertyName = "AudioSpeechRequestResponseFormat2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.AudioSpeechRequestLanguage), TypeInfoPropertyName = "AudioSpeechRequestLanguage2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.AudioSpeechRequestResponseEncoding), TypeInfoPropertyName = "AudioSpeechRequestResponseEncoding2")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.AudioSpeechRequestExtraParams))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.AudioTranscriptionRequest))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.OneOf), TypeInfoPropertyName = "OneOfByteArrayString2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(byte[]))] @@ -907,7 +928,6 @@ namespace Together [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.AudioTranscriptionResponse), TypeInfoPropertyName = "AudioTranscriptionResponse2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.AudioTranscriptionJsonResponse))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.AudioTranscriptionVerboseJsonResponse))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.AudioTranscriptionVerboseJsonResponseTask), TypeInfoPropertyName = "AudioTranscriptionVerboseJsonResponseTask2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.AudioTranscriptionSegment))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] @@ -924,7 +944,6 @@ namespace Together [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.AudioTranslationResponse), TypeInfoPropertyName = "AudioTranslationResponse2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.AudioTranslationJsonResponse))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.AudioTranslationVerboseJsonResponse))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.AudioTranslationVerboseJsonResponseTask), TypeInfoPropertyName = "AudioTranslationVerboseJsonResponseTask2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.AudioSpeechStreamResponse), TypeInfoPropertyName = "AudioSpeechStreamResponse2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.AudioSpeechStreamEvent))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.AudioSpeechStreamChunk))] @@ -955,6 +974,7 @@ namespace Together [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.ImageResponseDataB64))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.ImageResponseDataUrl))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.ImageResponseDataItemDiscriminator))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.ImageResponseDataItemDiscriminatorType), TypeInfoPropertyName = "ImageResponseDataItemDiscriminatorType2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.ImageResponseDataB64Type), TypeInfoPropertyName = "ImageResponseDataB64Type2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.ImageResponseDataUrlType), TypeInfoPropertyName = "ImageResponseDataUrlType2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.JobInfoSuccessResponse))] @@ -1052,6 +1072,7 @@ namespace Together [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutputData))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutputType), TypeInfoPropertyName = "ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutputType2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.ExecuteResponseSuccessfulExecutionDataOutputDiscriminator))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorType), TypeInfoPropertyName = "ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorType2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.ExecuteResponseSuccessfulExecutionDataStatus), TypeInfoPropertyName = "ExecuteResponseSuccessfulExecutionDataStatus2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.ExecuteResponseFailedExecution))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList>))] @@ -1065,6 +1086,7 @@ namespace Together [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.InterpreterOutputDisplayorExecuteOutputData))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.InterpreterOutputDisplayorExecuteOutputType), TypeInfoPropertyName = "InterpreterOutputDisplayorExecuteOutputType2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.InterpreterOutputDiscriminator))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.InterpreterOutputDiscriminatorType), TypeInfoPropertyName = "InterpreterOutputDiscriminatorType2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.Response))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.SessionListResponse), TypeInfoPropertyName = "SessionListResponse2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.SessionListResponseResponse))] @@ -1075,6 +1097,7 @@ namespace Together [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.StreamOutput))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.StreamOutputType), TypeInfoPropertyName = "StreamOutputType2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.CreateBatchRequest))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.CreateBatchRequestEndpoint), TypeInfoPropertyName = "CreateBatchRequestEndpoint2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.BatchErrorResponse))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.BatchJobWithWarning))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.BatchJob))] @@ -1160,129 +1183,1194 @@ namespace Together [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.VolumeContent))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.Dictionary))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.VersionHistoryItem))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.VolumeContentRequestType), TypeInfoPropertyName = "VolumeContentRequestType2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.FileInfo))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.VolumeContentType), TypeInfoPropertyName = "VolumeContentType2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.QueueError))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.QueueMetricsResponse))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.QueueCancelRequest))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.QueueCancelResponse))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.QueueCancelResponseStatus), TypeInfoPropertyName = "QueueCancelResponseStatus2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.QueueJobRequest))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.QueueJobResponse))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.QueueJobStatusResponse))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.QueueJobStatusResponseStatus), TypeInfoPropertyName = "QueueJobStatusResponseStatus2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.CreateImagesGenerationsRequest))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.AnyOf), TypeInfoPropertyName = "AnyOfCreateImagesGenerationsRequestModelString2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.CreateImagesGenerationsRequestModel), TypeInfoPropertyName = "CreateImagesGenerationsRequestModel2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.CreateImagesGenerationsRequestResponseFormat), TypeInfoPropertyName = "CreateImagesGenerationsRequestResponseFormat2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.CreateImagesGenerationsRequestOutputFormat), TypeInfoPropertyName = "CreateImagesGenerationsRequestOutputFormat2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.CreateImagesGenerationsRequestImageLora))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.CreateFilesUploadRequest))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.CreateFineTunesRequest))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.OneOf), TypeInfoPropertyName = "OneOfInt32CreateFineTunesRequestBatchSize2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.CreateFineTunesRequestBatchSize), TypeInfoPropertyName = "CreateFineTunesRequestBatchSize2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.OneOf), TypeInfoPropertyName = "OneOfBooleanCreateFineTunesRequestTrainOnInputs2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.CreateFineTunesRequestTrainOnInputs), TypeInfoPropertyName = "CreateFineTunesRequestTrainOnInputs2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.AnyOf), TypeInfoPropertyName = "AnyOfFullTrainingTypeLoRATrainingType2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.CreateFineTunesEstimatePriceRequest))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.UpdateEndpointRequest))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.UpdateEndpointRequestState), TypeInfoPropertyName = "UpdateEndpointRequestState2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.GetFinetuneDownloadCheckpoint), TypeInfoPropertyName = "GetFinetuneDownloadCheckpoint2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.RealtimeTtsModel), TypeInfoPropertyName = "RealtimeTtsModel2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.ListEndpointsType), TypeInfoPropertyName = "ListEndpointsType2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.ListEndpointsUsageType), TypeInfoPropertyName = "ListEndpointsUsageType2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.RealtimeTranscriptionInputAudioFormat), TypeInfoPropertyName = "RealtimeTranscriptionInputAudioFormat2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.Dictionary))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.CreateFineTunesEstimatePriceResponse))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.GetFineTunesModelsSupportedResponse))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.GetFineTunesModelsLimitsResponse))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.GPUClusterServiceDeleteResponse))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.ListEndpointsResponse))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.ListHardwareResponse))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.GetModelListResponse))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.GetEvaluationJobStatusAndResultsResponse))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.GetEvaluationJobStatusAndResultsResponseStatus), TypeInfoPropertyName = "GetEvaluationJobStatusAndResultsResponseStatus2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.OneOf), TypeInfoPropertyName = "OneOfEvaluationClassifyResultsEvaluationScoreResultsEvaluationCompareResults2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.OneOf, global::System.Collections.Generic.List>))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>), TypeInfoPropertyName = "ChatCompletionUserMessageContentMultimodalItemInputAudio_6724b54fa98b04fd")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.OneOf>))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.OneOf>))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.OneOf>))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - public sealed partial class SourceGenerationContext : global::System.Text.Json.Serialization.JsonSerializerContext + internal sealed partial class SourceGenerationContextChunk0 : global::System.Text.Json.Serialization.JsonSerializerContext { } + + /// + /// + /// + [global::System.Text.Json.Serialization.JsonSourceGenerationOptions( + DefaultIgnoreCondition = global::System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull, + Converters = new global::System.Type[] + { + typeof(global::Together.JsonConverters.RlDTypeJsonConverter), + + typeof(global::Together.JsonConverters.RlDTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.RlLossTypeJsonConverter), + + typeof(global::Together.JsonConverters.RlLossTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.RlGRPOLossAggregationTypeJsonConverter), + + typeof(global::Together.JsonConverters.RlGRPOLossAggregationTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.RlTrainingOperationErrorCodeJsonConverter), + + typeof(global::Together.JsonConverters.RlTrainingOperationErrorCodeNullableJsonConverter), + + typeof(global::Together.JsonConverters.RlTrainingOperationStatusJsonConverter), + + typeof(global::Together.JsonConverters.RlTrainingOperationStatusNullableJsonConverter), + + typeof(global::Together.JsonConverters.RlSessionTypeJsonConverter), + + typeof(global::Together.JsonConverters.RlSessionTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.RlTrainingSessionStatusJsonConverter), + + typeof(global::Together.JsonConverters.RlTrainingSessionStatusNullableJsonConverter), + + typeof(global::Together.JsonConverters.RlCheckpointVariantJsonConverter), + + typeof(global::Together.JsonConverters.RlCheckpointVariantNullableJsonConverter), + + typeof(global::Together.JsonConverters.GPUClusterCreateRequestClusterTypeJsonConverter), + + typeof(global::Together.JsonConverters.GPUClusterCreateRequestClusterTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.GPUClusterCreateRequestGpuTypeJsonConverter), + + typeof(global::Together.JsonConverters.GPUClusterCreateRequestGpuTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.GPUClusterCreateRequestBillingTypeJsonConverter), + + typeof(global::Together.JsonConverters.GPUClusterCreateRequestBillingTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.GPUClusterInfoClusterTypeJsonConverter), + + typeof(global::Together.JsonConverters.GPUClusterInfoClusterTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.GPUClusterInfoGpuTypeJsonConverter), + + typeof(global::Together.JsonConverters.GPUClusterInfoGpuTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.GPUClusterInfoStatusJsonConverter), + + typeof(global::Together.JsonConverters.GPUClusterInfoStatusNullableJsonConverter), + + typeof(global::Together.JsonConverters.GPUClusterUpdateRequestClusterTypeJsonConverter), + + typeof(global::Together.JsonConverters.GPUClusterUpdateRequestClusterTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.InstanceTypesResponseTypeJsonConverter), + + typeof(global::Together.JsonConverters.InstanceTypesResponseTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.GPUClustersSharedVolumeStatusJsonConverter), + + typeof(global::Together.JsonConverters.GPUClustersSharedVolumeStatusNullableJsonConverter), + + typeof(global::Together.JsonConverters.RerankRequestModelJsonConverter), + + typeof(global::Together.JsonConverters.RerankRequestModelNullableJsonConverter), + + typeof(global::Together.JsonConverters.FinishReasonJsonConverter), + + typeof(global::Together.JsonConverters.FinishReasonNullableJsonConverter), + + typeof(global::Together.JsonConverters.CompletionRequestModelJsonConverter), + + typeof(global::Together.JsonConverters.CompletionRequestModelNullableJsonConverter), + + typeof(global::Together.JsonConverters.CompletionRequestSafetyModelJsonConverter), + + typeof(global::Together.JsonConverters.CompletionRequestSafetyModelNullableJsonConverter), + + typeof(global::Together.JsonConverters.CompletionChoiceDeltaRoleJsonConverter), + + typeof(global::Together.JsonConverters.CompletionChoiceDeltaRoleNullableJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionMessageRoleJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionMessageRoleNullableJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionToolTypeJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionToolTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionRequestContextLengthExceededBehaviorJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionRequestContextLengthExceededBehaviorNullableJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionRequestFunctionCallEnumJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionRequestFunctionCallEnumNullableJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionRequestResponseFormatDiscriminatorTypeJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionRequestResponseFormatDiscriminatorTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionRequestReasoningEffortJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionRequestReasoningEffortNullableJsonConverter), + + typeof(global::Together.JsonConverters.ResponseFormatTextTypeJsonConverter), + + typeof(global::Together.JsonConverters.ResponseFormatTextTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.ResponseFormatJsonObjectTypeJsonConverter), + + typeof(global::Together.JsonConverters.ResponseFormatJsonObjectTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.ResponseFormatJsonSchemaTypeJsonConverter), + + typeof(global::Together.JsonConverters.ResponseFormatJsonSchemaTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionSystemMessageParamRoleJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionSystemMessageParamRoleNullableJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionUserMessageParamRoleJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionUserMessageParamRoleNullableJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionUserMessageContentMultimodalItemVariant1TypeJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionUserMessageContentMultimodalItemVariant1TypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionUserMessageContentMultimodalItemVariant2TypeJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionUserMessageContentMultimodalItemVariant2TypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionUserMessageContentMultimodalItemVideoTypeJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionUserMessageContentMultimodalItemVideoTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionUserMessageContentMultimodalItemAudioTypeJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionUserMessageContentMultimodalItemAudioTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionUserMessageContentMultimodalItemInputAudioTypeJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionUserMessageContentMultimodalItemInputAudioTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionUserMessageContentMultimodalItemInputAudioInputAudioFormatJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionUserMessageContentMultimodalItemInputAudioInputAudioFormatNullableJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionAssistantMessageParamRoleJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionAssistantMessageParamRoleNullableJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionFunctionMessageParamRoleJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionFunctionMessageParamRoleNullableJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionToolMessageParamRoleJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionToolMessageParamRoleNullableJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionChunkChoiceDeltaRoleJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionChunkChoiceDeltaRoleNullableJsonConverter), + + typeof(global::Together.JsonConverters.AudioSpeechRequestModelJsonConverter), + + typeof(global::Together.JsonConverters.AudioSpeechRequestModelNullableJsonConverter), + + typeof(global::Together.JsonConverters.AudioSpeechRequestResponseFormatJsonConverter), + + typeof(global::Together.JsonConverters.AudioSpeechRequestResponseFormatNullableJsonConverter), + + typeof(global::Together.JsonConverters.AudioSpeechRequestResponseEncodingJsonConverter), + + typeof(global::Together.JsonConverters.AudioSpeechRequestResponseEncodingNullableJsonConverter), + + typeof(global::Together.JsonConverters.AudioTranscriptionRequestModelJsonConverter), + + typeof(global::Together.JsonConverters.AudioTranscriptionRequestModelNullableJsonConverter), + + typeof(global::Together.JsonConverters.AudioTranscriptionRequestResponseFormatJsonConverter), + + typeof(global::Together.JsonConverters.AudioTranscriptionRequestResponseFormatNullableJsonConverter), + + typeof(global::Together.JsonConverters.AudioTranscriptionRequestTimestampGranularitiesJsonConverter), + + typeof(global::Together.JsonConverters.AudioTranscriptionRequestTimestampGranularitiesNullableJsonConverter), + + typeof(global::Together.JsonConverters.AudioTranscriptionRequestTimestampGranularitieJsonConverter), + + typeof(global::Together.JsonConverters.AudioTranscriptionRequestTimestampGranularitieNullableJsonConverter), + + typeof(global::Together.JsonConverters.AudioTranslationRequestModelJsonConverter), + + typeof(global::Together.JsonConverters.AudioTranslationRequestModelNullableJsonConverter), + + typeof(global::Together.JsonConverters.AudioTranslationRequestResponseFormatJsonConverter), + + typeof(global::Together.JsonConverters.AudioTranslationRequestResponseFormatNullableJsonConverter), + + typeof(global::Together.JsonConverters.AudioTranslationRequestTimestampGranularitiesJsonConverter), + + typeof(global::Together.JsonConverters.AudioTranslationRequestTimestampGranularitiesNullableJsonConverter), + + typeof(global::Together.JsonConverters.AudioTranslationRequestTimestampGranularitieJsonConverter), + + typeof(global::Together.JsonConverters.AudioTranslationRequestTimestampGranularitieNullableJsonConverter), + + typeof(global::Together.JsonConverters.StreamSentinelDataJsonConverter), + + typeof(global::Together.JsonConverters.StreamSentinelDataNullableJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionChoiceDeltaRoleJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionChoiceDeltaRoleNullableJsonConverter), + + typeof(global::Together.JsonConverters.EmbeddingsRequestModelJsonConverter), + + typeof(global::Together.JsonConverters.EmbeddingsRequestModelNullableJsonConverter), + + typeof(global::Together.JsonConverters.ModelInfoTypeJsonConverter), + + typeof(global::Together.JsonConverters.ModelInfoTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.ModelUploadRequestModelTypeJsonConverter), + + typeof(global::Together.JsonConverters.ModelUploadRequestModelTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.ImageResponseDataItemDiscriminatorTypeJsonConverter), + + typeof(global::Together.JsonConverters.ImageResponseDataItemDiscriminatorTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.ImageResponseDataB64TypeJsonConverter), + + typeof(global::Together.JsonConverters.ImageResponseDataB64TypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.ImageResponseDataUrlTypeJsonConverter), + + typeof(global::Together.JsonConverters.ImageResponseDataUrlTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.JobInfoSuccessResponseStatusJsonConverter), + + typeof(global::Together.JsonConverters.JobInfoSuccessResponseStatusNullableJsonConverter), + + typeof(global::Together.JsonConverters.ToolChoiceTypeJsonConverter), + + typeof(global::Together.JsonConverters.ToolChoiceTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.FilePurposeJsonConverter), + + typeof(global::Together.JsonConverters.FilePurposeNullableJsonConverter), + + typeof(global::Together.JsonConverters.FileTypeJsonConverter), + + typeof(global::Together.JsonConverters.FileTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.FinetuneResponseBatchSizeJsonConverter), + + typeof(global::Together.JsonConverters.FinetuneResponseBatchSizeNullableJsonConverter), + + typeof(global::Together.JsonConverters.FinetuneResponseTrainOnInputsJsonConverter), + + typeof(global::Together.JsonConverters.FinetuneResponseTrainOnInputsNullableJsonConverter), + + typeof(global::Together.JsonConverters.FinetuneJobStatusJsonConverter), + + typeof(global::Together.JsonConverters.FinetuneJobStatusNullableJsonConverter), + + typeof(global::Together.JsonConverters.FinetuneEventLevelsJsonConverter), + + typeof(global::Together.JsonConverters.FinetuneEventLevelsNullableJsonConverter), + + typeof(global::Together.JsonConverters.FinetuneEventTypeJsonConverter), + + typeof(global::Together.JsonConverters.FinetuneEventTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.FullTrainingTypeTypeJsonConverter), + + typeof(global::Together.JsonConverters.FullTrainingTypeTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.LoRATrainingTypeTypeJsonConverter), + + typeof(global::Together.JsonConverters.LoRATrainingTypeTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.TrainingMethodSFTMethodJsonConverter), + + typeof(global::Together.JsonConverters.TrainingMethodSFTMethodNullableJsonConverter), + + typeof(global::Together.JsonConverters.TrainingMethodSFTTrainOnInputsJsonConverter), + + typeof(global::Together.JsonConverters.TrainingMethodSFTTrainOnInputsNullableJsonConverter), + + typeof(global::Together.JsonConverters.TrainingMethodDPOMethodJsonConverter), + + typeof(global::Together.JsonConverters.TrainingMethodDPOMethodNullableJsonConverter), + + typeof(global::Together.JsonConverters.LRSchedulerLrSchedulerTypeJsonConverter), + + typeof(global::Together.JsonConverters.LRSchedulerLrSchedulerTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.HardwareAvailabilityStatusJsonConverter), + + typeof(global::Together.JsonConverters.HardwareAvailabilityStatusNullableJsonConverter), + + typeof(global::Together.JsonConverters.CreateEndpointRequestStateJsonConverter), + + typeof(global::Together.JsonConverters.CreateEndpointRequestStateNullableJsonConverter), + + typeof(global::Together.JsonConverters.DedicatedEndpointTypeJsonConverter), + + typeof(global::Together.JsonConverters.DedicatedEndpointTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.DedicatedEndpointStateJsonConverter), + + typeof(global::Together.JsonConverters.DedicatedEndpointStateNullableJsonConverter), + + typeof(global::Together.JsonConverters.ListEndpointTypeJsonConverter), + + typeof(global::Together.JsonConverters.ListEndpointTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.ListEndpointStateJsonConverter), + + typeof(global::Together.JsonConverters.ListEndpointStateNullableJsonConverter), + + typeof(global::Together.JsonConverters.DisplayorExecuteOutputTypeJsonConverter), + + typeof(global::Together.JsonConverters.DisplayorExecuteOutputTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.ErrorOutputTypeJsonConverter), + + typeof(global::Together.JsonConverters.ErrorOutputTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.ExecuteRequestFileEncodingJsonConverter), + + typeof(global::Together.JsonConverters.ExecuteRequestFileEncodingNullableJsonConverter), + + typeof(global::Together.JsonConverters.ExecuteRequestLanguageJsonConverter), + + typeof(global::Together.JsonConverters.ExecuteRequestLanguageNullableJsonConverter), + + typeof(global::Together.JsonConverters.ExecuteResponseSuccessfulExecutionDataOutputStreamOutputTypeJsonConverter), + + typeof(global::Together.JsonConverters.ExecuteResponseSuccessfulExecutionDataOutputStreamOutputTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.ExecuteResponseSuccessfulExecutionDataOutputErrorOutputTypeJsonConverter), + + typeof(global::Together.JsonConverters.ExecuteResponseSuccessfulExecutionDataOutputErrorOutputTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutputTypeJsonConverter), + + typeof(global::Together.JsonConverters.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutputTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorTypeJsonConverter), + + typeof(global::Together.JsonConverters.ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.ExecuteResponseSuccessfulExecutionDataStatusJsonConverter), + + typeof(global::Together.JsonConverters.ExecuteResponseSuccessfulExecutionDataStatusNullableJsonConverter), + + typeof(global::Together.JsonConverters.InterpreterOutputStreamOutputTypeJsonConverter), + + typeof(global::Together.JsonConverters.InterpreterOutputStreamOutputTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.InterpreterOutputErrorOutputTypeJsonConverter), + + typeof(global::Together.JsonConverters.InterpreterOutputErrorOutputTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.InterpreterOutputDisplayorExecuteOutputTypeJsonConverter), + + typeof(global::Together.JsonConverters.InterpreterOutputDisplayorExecuteOutputTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.InterpreterOutputDiscriminatorTypeJsonConverter), + + typeof(global::Together.JsonConverters.InterpreterOutputDiscriminatorTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.StreamOutputTypeJsonConverter), + + typeof(global::Together.JsonConverters.StreamOutputTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.CreateBatchRequestEndpointJsonConverter), + + typeof(global::Together.JsonConverters.CreateBatchRequestEndpointNullableJsonConverter), + + typeof(global::Together.JsonConverters.BatchJobStatusJsonConverter), + + typeof(global::Together.JsonConverters.BatchJobStatusNullableJsonConverter), + + typeof(global::Together.JsonConverters.EvaluationTypedRequestTypeJsonConverter), + + typeof(global::Together.JsonConverters.EvaluationTypedRequestTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.EvaluationJudgeModelConfigModelSourceJsonConverter), + + typeof(global::Together.JsonConverters.EvaluationJudgeModelConfigModelSourceNullableJsonConverter), + + typeof(global::Together.JsonConverters.EvaluationModelRequestModelSourceJsonConverter), + + typeof(global::Together.JsonConverters.EvaluationModelRequestModelSourceNullableJsonConverter), + + typeof(global::Together.JsonConverters.EvaluationResponseStatusJsonConverter), + + typeof(global::Together.JsonConverters.EvaluationResponseStatusNullableJsonConverter), + + typeof(global::Together.JsonConverters.EvaluationJobTypeJsonConverter), + + typeof(global::Together.JsonConverters.EvaluationJobTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.EvaluationJobStatusJsonConverter), + + typeof(global::Together.JsonConverters.EvaluationJobStatusNullableJsonConverter), + + typeof(global::Together.JsonConverters.VideoStatusJsonConverter), + + typeof(global::Together.JsonConverters.VideoStatusNullableJsonConverter), + + typeof(global::Together.JsonConverters.VideoFrameImageInputFrameJsonConverter), + + typeof(global::Together.JsonConverters.VideoFrameImageInputFrameNullableJsonConverter), + + typeof(global::Together.JsonConverters.VideoOutputFormatJsonConverter), + + typeof(global::Together.JsonConverters.VideoOutputFormatNullableJsonConverter), + + typeof(global::Together.JsonConverters.CreateDeploymentRequestGpuTypeJsonConverter), + + typeof(global::Together.JsonConverters.CreateDeploymentRequestGpuTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.DeploymentResponseItemGpuTypeJsonConverter), + + typeof(global::Together.JsonConverters.DeploymentResponseItemGpuTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.DeploymentStatusJsonConverter), + + typeof(global::Together.JsonConverters.DeploymentStatusNullableJsonConverter), + + typeof(global::Together.JsonConverters.HTTPAutoscalingConfigMetricJsonConverter), + + typeof(global::Together.JsonConverters.HTTPAutoscalingConfigMetricNullableJsonConverter), + + typeof(global::Together.JsonConverters.QueueAutoscalingConfigMetricJsonConverter), + + typeof(global::Together.JsonConverters.QueueAutoscalingConfigMetricNullableJsonConverter), + + typeof(global::Together.JsonConverters.CustomMetricAutoscalingConfigMetricJsonConverter), + + typeof(global::Together.JsonConverters.CustomMetricAutoscalingConfigMetricNullableJsonConverter), + + typeof(global::Together.JsonConverters.UpdateDeploymentRequestGpuTypeJsonConverter), + + typeof(global::Together.JsonConverters.UpdateDeploymentRequestGpuTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.VolumeContentRequestTypeJsonConverter), + + typeof(global::Together.JsonConverters.VolumeContentRequestTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.VolumeContentTypeJsonConverter), + + typeof(global::Together.JsonConverters.VolumeContentTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.VolumeTypeJsonConverter), + + typeof(global::Together.JsonConverters.VolumeTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.QueueCancelResponseStatusJsonConverter), + + typeof(global::Together.JsonConverters.QueueCancelResponseStatusNullableJsonConverter), + + typeof(global::Together.JsonConverters.QueueJobStatusResponseStatusJsonConverter), + + typeof(global::Together.JsonConverters.QueueJobStatusResponseStatusNullableJsonConverter), + + typeof(global::Together.JsonConverters.CreateImagesGenerationsRequestModelJsonConverter), + + typeof(global::Together.JsonConverters.CreateImagesGenerationsRequestModelNullableJsonConverter), + + typeof(global::Together.JsonConverters.CreateImagesGenerationsRequestResponseFormatJsonConverter), + + typeof(global::Together.JsonConverters.CreateImagesGenerationsRequestResponseFormatNullableJsonConverter), + + typeof(global::Together.JsonConverters.CreateImagesGenerationsRequestOutputFormatJsonConverter), + + typeof(global::Together.JsonConverters.CreateImagesGenerationsRequestOutputFormatNullableJsonConverter), + + typeof(global::Together.JsonConverters.CreateFineTunesRequestBatchSizeJsonConverter), + + typeof(global::Together.JsonConverters.CreateFineTunesRequestBatchSizeNullableJsonConverter), + + typeof(global::Together.JsonConverters.CreateFineTunesRequestTrainOnInputsJsonConverter), + + typeof(global::Together.JsonConverters.CreateFineTunesRequestTrainOnInputsNullableJsonConverter), + + typeof(global::Together.JsonConverters.UpdateEndpointRequestStateJsonConverter), + + typeof(global::Together.JsonConverters.UpdateEndpointRequestStateNullableJsonConverter), + + typeof(global::Together.JsonConverters.GetFinetuneDownloadCheckpointJsonConverter), + + typeof(global::Together.JsonConverters.GetFinetuneDownloadCheckpointNullableJsonConverter), + + typeof(global::Together.JsonConverters.RealtimeTtsModelJsonConverter), + + typeof(global::Together.JsonConverters.RealtimeTtsModelNullableJsonConverter), + + typeof(global::Together.JsonConverters.ListEndpointsTypeJsonConverter), + + typeof(global::Together.JsonConverters.ListEndpointsTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.ListEndpointsUsageTypeJsonConverter), + + typeof(global::Together.JsonConverters.ListEndpointsUsageTypeNullableJsonConverter), + + typeof(global::Together.JsonConverters.RealtimeTranscriptionInputAudioFormatJsonConverter), + + typeof(global::Together.JsonConverters.RealtimeTranscriptionInputAudioFormatNullableJsonConverter), + + typeof(global::Together.JsonConverters.GetEvaluationJobStatusAndResultsResponseStatusJsonConverter), + + typeof(global::Together.JsonConverters.GetEvaluationJobStatusAndResultsResponseStatusNullableJsonConverter), + + typeof(global::Together.JsonConverters.CompletionStreamJsonConverter), + + typeof(global::Together.JsonConverters.ResponseFormatJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionMessageParamJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionUserMessageContentJsonConverter), + + typeof(global::Together.JsonConverters.ChatCompletionStreamJsonConverter), + + typeof(global::Together.JsonConverters.AudioTranscriptionResponseJsonConverter), + + typeof(global::Together.JsonConverters.AudioTranslationResponseJsonConverter), + + typeof(global::Together.JsonConverters.AudioSpeechStreamResponseJsonConverter), + + typeof(global::Together.JsonConverters.DataItem3JsonConverter), + + typeof(global::Together.JsonConverters.ErrorJsonConverter), + + typeof(global::Together.JsonConverters.ExecuteResponseJsonConverter), + + typeof(global::Together.JsonConverters.OutputsItemJsonConverter), + + typeof(global::Together.JsonConverters.InterpreterOutputJsonConverter), + + typeof(global::Together.JsonConverters.SessionListResponseJsonConverter), + + typeof(global::Together.JsonConverters.EvaluationModelOrStringJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.AnyOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter, global::System.Collections.Generic.IList>), + + typeof(global::Together.JsonConverters.AnyOfJsonConverter), + + typeof(global::Together.JsonConverters.AnyOfJsonConverter), + + typeof(global::Together.JsonConverters.AllOfJsonConverter), + + typeof(global::Together.JsonConverters.AllOfJsonConverter), + + typeof(global::Together.JsonConverters.AllOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.AllOfJsonConverter), + + typeof(global::Together.JsonConverters.AnyOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter>), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter>), + + typeof(global::Together.JsonConverters.AnyOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter>), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.AnyOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.AnyOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.AnyOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.OneOfJsonConverter), + + typeof(global::Together.JsonConverters.UnixTimestampJsonConverter), + })] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList>), TypeInfoPropertyName = "ChatCompletionUserMessageContentMultimodalItemInputAudio_9a6c1a339fc4e5a1")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.OneOf), TypeInfoPropertyName = "ChatCompletionUserMessageContentMultimodalItemInputAudio_e050a39467d446fd")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.OneOf?), TypeInfoPropertyName = "ChatCompletionUserMessageContentMultimodalItemInputAudio_f38c2c0c365e74fc")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>), TypeInfoPropertyName = "ChatCompletionUserMessageContentMultimodalItemInputAudio_6724b54fa98b04fd")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.VolumeContentRequestType), TypeInfoPropertyName = "VolumeContentRequestType2")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.FileInfo))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.VolumeContentType), TypeInfoPropertyName = "VolumeContentType2")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.QueueError))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.QueueMetricsResponse))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.QueueCancelRequest))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.QueueCancelResponse))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.QueueCancelResponseStatus), TypeInfoPropertyName = "QueueCancelResponseStatus2")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.QueueJobRequest))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.QueueJobResponse))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.QueueJobStatusResponse))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.QueueJobStatusResponseStatus), TypeInfoPropertyName = "QueueJobStatusResponseStatus2")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.CreateImagesGenerationsRequest))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.AnyOf), TypeInfoPropertyName = "AnyOfCreateImagesGenerationsRequestModelString2")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.CreateImagesGenerationsRequestModel), TypeInfoPropertyName = "CreateImagesGenerationsRequestModel2")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.CreateImagesGenerationsRequestResponseFormat), TypeInfoPropertyName = "CreateImagesGenerationsRequestResponseFormat2")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.CreateImagesGenerationsRequestOutputFormat), TypeInfoPropertyName = "CreateImagesGenerationsRequestOutputFormat2")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.CreateImagesGenerationsRequestImageLora))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.CreateFilesUploadRequest))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.CreateFineTunesRequest))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.OneOf), TypeInfoPropertyName = "OneOfInt32CreateFineTunesRequestBatchSize2")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.CreateFineTunesRequestBatchSize), TypeInfoPropertyName = "CreateFineTunesRequestBatchSize2")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.OneOf), TypeInfoPropertyName = "OneOfBooleanCreateFineTunesRequestTrainOnInputs2")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.CreateFineTunesRequestTrainOnInputs), TypeInfoPropertyName = "CreateFineTunesRequestTrainOnInputs2")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.AnyOf), TypeInfoPropertyName = "AnyOfFullTrainingTypeLoRATrainingType2")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.CreateFineTunesEstimatePriceRequest))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.UpdateEndpointRequest))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.UpdateEndpointRequestState), TypeInfoPropertyName = "UpdateEndpointRequestState2")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.GetFinetuneDownloadCheckpoint), TypeInfoPropertyName = "GetFinetuneDownloadCheckpoint2")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.RealtimeTtsModel), TypeInfoPropertyName = "RealtimeTtsModel2")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.ListEndpointsType), TypeInfoPropertyName = "ListEndpointsType2")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.ListEndpointsUsageType), TypeInfoPropertyName = "ListEndpointsUsageType2")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.RealtimeTranscriptionInputAudioFormat), TypeInfoPropertyName = "RealtimeTranscriptionInputAudioFormat2")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.Dictionary))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.CreateFineTunesEstimatePriceResponse))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.GetFineTunesMetricsResponse))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList>))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.GetFineTunesModelsSupportedResponse))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.GetFineTunesModelsLimitsResponse))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.GPUClusterServiceDeleteResponse))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.ListEndpointsResponse))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.ListHardwareResponse))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.GetModelListResponse))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.GetEvaluationJobStatusAndResultsResponse))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.GetEvaluationJobStatusAndResultsResponseStatus), TypeInfoPropertyName = "GetEvaluationJobStatusAndResultsResponseStatus2")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.OneOf), TypeInfoPropertyName = "OneOfEvaluationClassifyResultsEvaluationScoreResultsEvaluationCompareResults2")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.OneOf, global::System.Collections.Generic.List>))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.OneOf>))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.OneOf>))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Together.OneOf>))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + internal sealed partial class SourceGenerationContextChunk1 : global::System.Text.Json.Serialization.JsonSerializerContext + { + } + /// + /// + /// + public sealed partial class SourceGenerationContext : global::System.Text.Json.Serialization.JsonSerializerContext + { + private static readonly global::System.Text.Json.Serialization.Metadata.IJsonTypeInfoResolver Resolver = global::System.Text.Json.Serialization.Metadata.JsonTypeInfoResolver.Combine( + SourceGenerationContextChunk0.Default, + + SourceGenerationContextChunk1.Default + ); + + private static readonly global::System.Text.Json.JsonSerializerOptions DefaultOptions = CreateDefaultOptions(); + + /// + /// + /// + public static SourceGenerationContext Default { get; } = new(DefaultOptions); + + private SourceGenerationContext(global::System.Text.Json.JsonSerializerOptions options) + : base(options) + { + } + + /// + protected override global::System.Text.Json.JsonSerializerOptions? GeneratedSerializerOptions => DefaultOptions; + + /// + public override global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? GetTypeInfo(global::System.Type type) + { + return Resolver.GetTypeInfo(type, Options); + } + + private static global::System.Text.Json.JsonSerializerOptions CreateDefaultOptions() + { + var options = new global::System.Text.Json.JsonSerializerOptions + { + DefaultIgnoreCondition = global::System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull, + TypeInfoResolver = Resolver, + }; + options.Converters.Add(new global::Together.JsonConverters.RlDTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.RlDTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.RlLossTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.RlLossTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.RlGRPOLossAggregationTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.RlGRPOLossAggregationTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.RlTrainingOperationErrorCodeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.RlTrainingOperationErrorCodeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.RlTrainingOperationStatusJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.RlTrainingOperationStatusNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.RlSessionTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.RlSessionTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.RlTrainingSessionStatusJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.RlTrainingSessionStatusNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.RlCheckpointVariantJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.RlCheckpointVariantNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.GPUClusterCreateRequestClusterTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.GPUClusterCreateRequestClusterTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.GPUClusterCreateRequestGpuTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.GPUClusterCreateRequestGpuTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.GPUClusterCreateRequestBillingTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.GPUClusterCreateRequestBillingTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.GPUClusterInfoClusterTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.GPUClusterInfoClusterTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.GPUClusterInfoGpuTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.GPUClusterInfoGpuTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.GPUClusterInfoStatusJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.GPUClusterInfoStatusNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.GPUClusterUpdateRequestClusterTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.GPUClusterUpdateRequestClusterTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.InstanceTypesResponseTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.InstanceTypesResponseTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.GPUClustersSharedVolumeStatusJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.GPUClustersSharedVolumeStatusNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.RerankRequestModelJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.RerankRequestModelNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.FinishReasonJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.FinishReasonNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.CompletionRequestModelJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.CompletionRequestModelNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.CompletionRequestSafetyModelJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.CompletionRequestSafetyModelNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.CompletionChoiceDeltaRoleJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.CompletionChoiceDeltaRoleNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionMessageRoleJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionMessageRoleNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionToolTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionToolTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionRequestContextLengthExceededBehaviorJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionRequestContextLengthExceededBehaviorNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionRequestFunctionCallEnumJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionRequestFunctionCallEnumNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionRequestResponseFormatDiscriminatorTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionRequestResponseFormatDiscriminatorTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionRequestReasoningEffortJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionRequestReasoningEffortNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ResponseFormatTextTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ResponseFormatTextTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ResponseFormatJsonObjectTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ResponseFormatJsonObjectTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ResponseFormatJsonSchemaTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ResponseFormatJsonSchemaTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionSystemMessageParamRoleJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionSystemMessageParamRoleNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionUserMessageParamRoleJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionUserMessageParamRoleNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionUserMessageContentMultimodalItemVariant1TypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionUserMessageContentMultimodalItemVariant1TypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionUserMessageContentMultimodalItemVariant2TypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionUserMessageContentMultimodalItemVariant2TypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionUserMessageContentMultimodalItemVideoTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionUserMessageContentMultimodalItemVideoTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionUserMessageContentMultimodalItemAudioTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionUserMessageContentMultimodalItemAudioTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionUserMessageContentMultimodalItemInputAudioTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionUserMessageContentMultimodalItemInputAudioTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionUserMessageContentMultimodalItemInputAudioInputAudioFormatJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionUserMessageContentMultimodalItemInputAudioInputAudioFormatNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionAssistantMessageParamRoleJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionAssistantMessageParamRoleNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionFunctionMessageParamRoleJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionFunctionMessageParamRoleNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionToolMessageParamRoleJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionToolMessageParamRoleNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionChunkChoiceDeltaRoleJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionChunkChoiceDeltaRoleNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AudioSpeechRequestModelJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AudioSpeechRequestModelNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AudioSpeechRequestResponseFormatJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AudioSpeechRequestResponseFormatNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AudioSpeechRequestResponseEncodingJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AudioSpeechRequestResponseEncodingNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AudioTranscriptionRequestModelJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AudioTranscriptionRequestModelNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AudioTranscriptionRequestResponseFormatJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AudioTranscriptionRequestResponseFormatNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AudioTranscriptionRequestTimestampGranularitiesJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AudioTranscriptionRequestTimestampGranularitiesNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AudioTranscriptionRequestTimestampGranularitieJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AudioTranscriptionRequestTimestampGranularitieNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AudioTranslationRequestModelJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AudioTranslationRequestModelNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AudioTranslationRequestResponseFormatJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AudioTranslationRequestResponseFormatNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AudioTranslationRequestTimestampGranularitiesJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AudioTranslationRequestTimestampGranularitiesNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AudioTranslationRequestTimestampGranularitieJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AudioTranslationRequestTimestampGranularitieNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.StreamSentinelDataJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.StreamSentinelDataNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionChoiceDeltaRoleJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionChoiceDeltaRoleNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.EmbeddingsRequestModelJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.EmbeddingsRequestModelNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ModelInfoTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ModelInfoTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ModelUploadRequestModelTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ModelUploadRequestModelTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ImageResponseDataItemDiscriminatorTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ImageResponseDataItemDiscriminatorTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ImageResponseDataB64TypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ImageResponseDataB64TypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ImageResponseDataUrlTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ImageResponseDataUrlTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.JobInfoSuccessResponseStatusJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.JobInfoSuccessResponseStatusNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ToolChoiceTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ToolChoiceTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.FilePurposeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.FilePurposeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.FileTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.FileTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.FinetuneResponseBatchSizeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.FinetuneResponseBatchSizeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.FinetuneResponseTrainOnInputsJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.FinetuneResponseTrainOnInputsNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.FinetuneJobStatusJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.FinetuneJobStatusNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.FinetuneEventLevelsJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.FinetuneEventLevelsNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.FinetuneEventTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.FinetuneEventTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.FullTrainingTypeTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.FullTrainingTypeTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.LoRATrainingTypeTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.LoRATrainingTypeTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.TrainingMethodSFTMethodJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.TrainingMethodSFTMethodNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.TrainingMethodSFTTrainOnInputsJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.TrainingMethodSFTTrainOnInputsNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.TrainingMethodDPOMethodJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.TrainingMethodDPOMethodNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.LRSchedulerLrSchedulerTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.LRSchedulerLrSchedulerTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.HardwareAvailabilityStatusJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.HardwareAvailabilityStatusNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.CreateEndpointRequestStateJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.CreateEndpointRequestStateNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.DedicatedEndpointTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.DedicatedEndpointTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.DedicatedEndpointStateJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.DedicatedEndpointStateNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ListEndpointTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ListEndpointTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ListEndpointStateJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ListEndpointStateNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.DisplayorExecuteOutputTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.DisplayorExecuteOutputTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ErrorOutputTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ErrorOutputTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ExecuteRequestFileEncodingJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ExecuteRequestFileEncodingNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ExecuteRequestLanguageJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ExecuteRequestLanguageNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ExecuteResponseSuccessfulExecutionDataOutputStreamOutputTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ExecuteResponseSuccessfulExecutionDataOutputStreamOutputTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ExecuteResponseSuccessfulExecutionDataOutputErrorOutputTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ExecuteResponseSuccessfulExecutionDataOutputErrorOutputTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutputTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutputTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ExecuteResponseSuccessfulExecutionDataStatusJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ExecuteResponseSuccessfulExecutionDataStatusNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.InterpreterOutputStreamOutputTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.InterpreterOutputStreamOutputTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.InterpreterOutputErrorOutputTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.InterpreterOutputErrorOutputTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.InterpreterOutputDisplayorExecuteOutputTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.InterpreterOutputDisplayorExecuteOutputTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.InterpreterOutputDiscriminatorTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.InterpreterOutputDiscriminatorTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.StreamOutputTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.StreamOutputTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.CreateBatchRequestEndpointJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.CreateBatchRequestEndpointNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.BatchJobStatusJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.BatchJobStatusNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.EvaluationTypedRequestTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.EvaluationTypedRequestTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.EvaluationJudgeModelConfigModelSourceJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.EvaluationJudgeModelConfigModelSourceNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.EvaluationModelRequestModelSourceJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.EvaluationModelRequestModelSourceNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.EvaluationResponseStatusJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.EvaluationResponseStatusNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.EvaluationJobTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.EvaluationJobTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.EvaluationJobStatusJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.EvaluationJobStatusNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.VideoStatusJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.VideoStatusNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.VideoFrameImageInputFrameJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.VideoFrameImageInputFrameNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.VideoOutputFormatJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.VideoOutputFormatNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.CreateDeploymentRequestGpuTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.CreateDeploymentRequestGpuTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.DeploymentResponseItemGpuTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.DeploymentResponseItemGpuTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.DeploymentStatusJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.DeploymentStatusNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.HTTPAutoscalingConfigMetricJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.HTTPAutoscalingConfigMetricNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.QueueAutoscalingConfigMetricJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.QueueAutoscalingConfigMetricNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.CustomMetricAutoscalingConfigMetricJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.CustomMetricAutoscalingConfigMetricNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.UpdateDeploymentRequestGpuTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.UpdateDeploymentRequestGpuTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.VolumeContentRequestTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.VolumeContentRequestTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.VolumeContentTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.VolumeContentTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.VolumeTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.VolumeTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.QueueCancelResponseStatusJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.QueueCancelResponseStatusNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.QueueJobStatusResponseStatusJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.QueueJobStatusResponseStatusNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.CreateImagesGenerationsRequestModelJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.CreateImagesGenerationsRequestModelNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.CreateImagesGenerationsRequestResponseFormatJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.CreateImagesGenerationsRequestResponseFormatNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.CreateImagesGenerationsRequestOutputFormatJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.CreateImagesGenerationsRequestOutputFormatNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.CreateFineTunesRequestBatchSizeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.CreateFineTunesRequestBatchSizeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.CreateFineTunesRequestTrainOnInputsJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.CreateFineTunesRequestTrainOnInputsNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.UpdateEndpointRequestStateJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.UpdateEndpointRequestStateNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.GetFinetuneDownloadCheckpointJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.GetFinetuneDownloadCheckpointNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.RealtimeTtsModelJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.RealtimeTtsModelNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ListEndpointsTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ListEndpointsTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ListEndpointsUsageTypeJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ListEndpointsUsageTypeNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.RealtimeTranscriptionInputAudioFormatJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.RealtimeTranscriptionInputAudioFormatNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.GetEvaluationJobStatusAndResultsResponseStatusJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.GetEvaluationJobStatusAndResultsResponseStatusNullableJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.CompletionStreamJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ResponseFormatJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionMessageParamJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionUserMessageContentJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ChatCompletionStreamJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AudioTranscriptionResponseJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AudioTranslationResponseJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AudioSpeechStreamResponseJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.DataItem3JsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ErrorJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.ExecuteResponseJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OutputsItemJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.InterpreterOutputJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.SessionListResponseJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.EvaluationModelOrStringJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AnyOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter, global::System.Collections.Generic.IList>()); + options.Converters.Add(new global::Together.JsonConverters.AnyOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AnyOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AllOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AllOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AllOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AllOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AnyOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter>()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter>()); + options.Converters.Add(new global::Together.JsonConverters.AnyOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter>()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AnyOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AnyOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.AnyOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.OneOfJsonConverter()); + options.Converters.Add(new global::Together.JsonConverters.UnixTimestampJsonConverter()); + + return options; + } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.JsonSerializerContextTypes.g.cs b/src/libs/Together/Generated/Together.JsonSerializerContextTypes.g.cs index 077b39d6..5b6fc327 100644 --- a/src/libs/Together/Generated/Together.JsonSerializerContextTypes.g.cs +++ b/src/libs/Together/Generated/Together.JsonSerializerContextTypes.g.cs @@ -96,23 +96,23 @@ public sealed partial class JsonSerializerContextTypes /// /// /// - public global::Together.RlEncodedText? Type17 { get; set; } + public global::Together.OneOf? Type17 { get; set; } /// /// /// - public global::Together.RlListMeta? Type18 { get; set; } + public global::Together.RlEncodedText? Type18 { get; set; } /// /// /// - public bool? Type19 { get; set; } + public global::Together.RlListMeta? Type19 { get; set; } /// /// /// - public global::System.Collections.Generic.IList>? Type20 { get; set; } + public bool? Type20 { get; set; } /// /// /// - public global::Together.OneOf? Type21 { get; set; } + public global::System.Collections.Generic.IList>? Type21 { get; set; } /// /// /// @@ -232,131 +232,131 @@ public sealed partial class JsonSerializerContextTypes /// /// /// - public global::Together.RlLoraConfig? Type51 { get; set; } + public global::Together.RlSessionType? Type51 { get; set; } /// /// /// - public global::Together.RlTrainingSessionStatus? Type52 { get; set; } + public global::Together.RlLoraConfig? Type52 { get; set; } /// /// /// - public global::Together.RlTrainingSession? Type53 { get; set; } + public global::Together.RlTrainingSessionStatus? Type53 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type54 { get; set; } + public global::Together.RlTrainingSession? Type54 { get; set; } /// /// /// - public global::Together.RlInferenceCheckpoint? Type55 { get; set; } + public global::System.Collections.Generic.IList? Type55 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type56 { get; set; } + public global::Together.RlInferenceCheckpoint? Type56 { get; set; } /// /// /// - public global::Together.RlTrainingCheckpoint? Type57 { get; set; } + public global::System.Collections.Generic.IList? Type57 { get; set; } /// /// /// - public global::System.DateTime? Type58 { get; set; } + public global::Together.RlTrainingCheckpoint? Type58 { get; set; } /// /// /// - public global::Together.RlTrainingSessionsListResponse? Type59 { get; set; } + public global::System.DateTime? Type59 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type60 { get; set; } + public global::Together.RlTrainingSessionsListResponse? Type60 { get; set; } /// /// /// - public global::Together.RlInferenceCheckpointOperation? Type61 { get; set; } + public global::System.Collections.Generic.IList? Type61 { get; set; } /// /// /// - public global::Together.RlInferenceCheckpointResult? Type62 { get; set; } + public global::Together.RlInferenceCheckpointOperation? Type62 { get; set; } /// /// /// - public global::Together.RlInferenceCheckpointRegistration? Type63 { get; set; } + public global::Together.RlInferenceCheckpointResult? Type63 { get; set; } /// /// /// - public global::Together.RlTrainingCheckpointResult? Type64 { get; set; } + public global::Together.RlInferenceCheckpointRegistration? Type64 { get; set; } /// /// /// - public global::Together.RlTrainingCheckpointOperation? Type65 { get; set; } + public global::Together.RlTrainingCheckpointResult? Type65 { get; set; } /// /// /// - public global::Together.RlCheckpointVariant? Type66 { get; set; } + public global::Together.RlTrainingCheckpointOperation? Type66 { get; set; } /// /// /// - public global::Together.RlCheckpointFile? Type67 { get; set; } + public global::Together.RlCheckpointVariant? Type67 { get; set; } /// /// /// - public global::Together.RlCheckpointDownloadResponse? Type68 { get; set; } + public global::Together.RlCheckpointFile? Type68 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type69 { get; set; } + public global::Together.OneOf? Type69 { get; set; } /// /// /// - public global::Together.ErrorResponse? Type70 { get; set; } + public global::Together.RlCheckpointDownloadResponse? Type70 { get; set; } /// /// /// - public global::Together.GPUClusterControlPlaneNode? Type71 { get; set; } + public global::System.Collections.Generic.IList? Type71 { get; set; } /// /// /// - public global::Together.GPUClusterCreateRequest? Type72 { get; set; } + public global::Together.ErrorResponse? Type72 { get; set; } /// /// /// - public global::Together.GPUClusterCreateRequestClusterType? Type73 { get; set; } + public global::Together.GPUClusterControlPlaneNode? Type73 { get; set; } /// /// /// - public global::Together.GPUClusterCreateRequestGpuType? Type74 { get; set; } + public global::Together.GPUClusterCreateRequest? Type74 { get; set; } /// /// /// - public global::Together.GPUClusterCreateRequestDriverVersion? Type75 { get; set; } + public global::Together.GPUClusterCreateRequestClusterType? Type75 { get; set; } /// /// /// - public global::Together.GPUClustersSharedVolumeCreateRequest? Type76 { get; set; } + public global::Together.GPUClusterCreateRequestGpuType? Type76 { get; set; } /// /// /// - public global::Together.GPUClusterCreateRequestBillingType? Type77 { get; set; } + public global::Together.GPUClustersSharedVolumeCreateRequest? Type77 { get; set; } /// /// /// - public global::Together.GPUClusterGPUWorkerNode? Type78 { get; set; } + public global::Together.GPUClusterCreateRequestBillingType? Type78 { get; set; } /// /// /// - public global::Together.GPUClusterInfo? Type79 { get; set; } + public global::Together.GPUClusterGPUWorkerNode? Type79 { get; set; } /// /// /// - public global::Together.GPUClusterInfoClusterType? Type80 { get; set; } + public global::Together.GPUClusterInfo? Type80 { get; set; } /// /// /// - public global::Together.GPUClusterInfoGpuType? Type81 { get; set; } + public global::Together.GPUClusterInfoClusterType? Type81 { get; set; } /// /// /// - public global::Together.GPUClusterInfoDriverVersion? Type82 { get; set; } + public global::Together.GPUClusterInfoGpuType? Type82 { get; set; } /// /// /// @@ -724,211 +724,211 @@ public sealed partial class JsonSerializerContextTypes /// /// /// - public global::System.Collections.Generic.IList? Type174 { get; set; } + public global::Together.ChatCompletionRequestResponseFormatDiscriminatorType? Type174 { get; set; } /// /// /// - public global::Together.ToolsPart? Type175 { get; set; } + public global::System.Collections.Generic.IList? Type175 { get; set; } /// /// /// - public global::Together.OneOf? Type176 { get; set; } + public global::Together.ToolsPart? Type176 { get; set; } /// /// /// - public global::Together.ChatCompletionRequestReasoningEffort? Type177 { get; set; } + public global::Together.OneOf? Type177 { get; set; } /// /// /// - public global::Together.ChatCompletionRequestReasoning? Type178 { get; set; } + public global::Together.ChatCompletionRequestReasoningEffort? Type178 { get; set; } /// /// /// - public global::Together.ResponseFormatTextType? Type179 { get; set; } + public global::Together.ChatCompletionRequestReasoning? Type179 { get; set; } /// /// /// - public global::Together.ResponseFormatJsonObjectType? Type180 { get; set; } + public global::Together.ResponseFormatTextType? Type180 { get; set; } /// /// /// - public global::Together.ResponseFormatJsonSchemaType? Type181 { get; set; } + public global::Together.ResponseFormatJsonObjectType? Type181 { get; set; } /// /// /// - public global::Together.ResponseFormatJsonSchemaJsonSchema? Type182 { get; set; } + public global::Together.ResponseFormatJsonSchemaType? Type182 { get; set; } /// /// /// - public global::Together.ResponseFormatJsonSchemaSchema? Type183 { get; set; } + public global::Together.ResponseFormatJsonSchemaJsonSchema? Type183 { get; set; } /// /// /// - public global::Together.ChatCompletionSystemMessageParam? Type184 { get; set; } + public global::Together.ResponseFormatJsonSchemaSchema? Type184 { get; set; } /// /// /// - public global::Together.ChatCompletionUserMessageParam? Type185 { get; set; } + public global::Together.ChatCompletionSystemMessageParam? Type185 { get; set; } /// /// /// - public global::Together.ChatCompletionAssistantMessageParam? Type186 { get; set; } + public global::Together.ChatCompletionUserMessageParam? Type186 { get; set; } /// /// /// - public global::Together.ChatCompletionToolMessageParam? Type187 { get; set; } + public global::Together.ChatCompletionAssistantMessageParam? Type187 { get; set; } /// /// /// - public global::Together.ChatCompletionFunctionMessageParam? Type188 { get; set; } + public global::Together.ChatCompletionToolMessageParam? Type188 { get; set; } /// /// /// - public global::Together.ChatCompletionSystemMessageParamRole? Type189 { get; set; } + public global::Together.ChatCompletionFunctionMessageParam? Type189 { get; set; } /// /// /// - public global::Together.ChatCompletionUserMessageContent? Type190 { get; set; } + public global::Together.ChatCompletionSystemMessageParamRole? Type190 { get; set; } /// /// /// - public global::Together.ChatCompletionUserMessageParamRole? Type191 { get; set; } + public global::Together.ChatCompletionUserMessageContent? Type191 { get; set; } /// /// /// - public global::Together.ChatCompletionUserMessageContentMultimodalItemVariant1? Type192 { get; set; } + public global::Together.ChatCompletionUserMessageParamRole? Type192 { get; set; } /// /// /// - public global::Together.ChatCompletionUserMessageContentMultimodalItemVariant1Type? Type193 { get; set; } + public global::Together.ChatCompletionUserMessageContentMultimodalItemVariant1? Type193 { get; set; } /// /// /// - public global::Together.ChatCompletionUserMessageContentMultimodalItemVariant2? Type194 { get; set; } + public global::Together.ChatCompletionUserMessageContentMultimodalItemVariant1Type? Type194 { get; set; } /// /// /// - public global::Together.ChatCompletionUserMessageContentMultimodalItemVariant2Type? Type195 { get; set; } + public global::Together.ChatCompletionUserMessageContentMultimodalItemVariant2? Type195 { get; set; } /// /// /// - public global::Together.ChatCompletionUserMessageContentMultimodalItemVariant2ImageUrl? Type196 { get; set; } + public global::Together.ChatCompletionUserMessageContentMultimodalItemVariant2Type? Type196 { get; set; } /// /// /// - public global::Together.ChatCompletionUserMessageContentMultimodalItemVideo? Type197 { get; set; } + public global::Together.ChatCompletionUserMessageContentMultimodalItemVariant2ImageUrl? Type197 { get; set; } /// /// /// - public global::Together.ChatCompletionUserMessageContentMultimodalItemVideoType? Type198 { get; set; } + public global::Together.ChatCompletionUserMessageContentMultimodalItemVideo? Type198 { get; set; } /// /// /// - public global::Together.ChatCompletionUserMessageContentMultimodalItemVideoVideoUrl? Type199 { get; set; } + public global::Together.ChatCompletionUserMessageContentMultimodalItemVideoType? Type199 { get; set; } /// /// /// - public global::Together.ChatCompletionUserMessageContentMultimodalItemAudio? Type200 { get; set; } + public global::Together.ChatCompletionUserMessageContentMultimodalItemVideoVideoUrl? Type200 { get; set; } /// /// /// - public global::Together.ChatCompletionUserMessageContentMultimodalItemAudioType? Type201 { get; set; } + public global::Together.ChatCompletionUserMessageContentMultimodalItemAudio? Type201 { get; set; } /// /// /// - public global::Together.ChatCompletionUserMessageContentMultimodalItemAudioAudioUrl? Type202 { get; set; } + public global::Together.ChatCompletionUserMessageContentMultimodalItemAudioType? Type202 { get; set; } /// /// /// - public global::Together.ChatCompletionUserMessageContentMultimodalItemInputAudio? Type203 { get; set; } + public global::Together.ChatCompletionUserMessageContentMultimodalItemAudioAudioUrl? Type203 { get; set; } /// /// /// - public global::Together.ChatCompletionUserMessageContentMultimodalItemInputAudioType? Type204 { get; set; } + public global::Together.ChatCompletionUserMessageContentMultimodalItemInputAudio? Type204 { get; set; } /// /// /// - public global::Together.ChatCompletionUserMessageContentMultimodalItemInputAudioInputAudio? Type205 { get; set; } + public global::Together.ChatCompletionUserMessageContentMultimodalItemInputAudioType? Type205 { get; set; } /// /// /// - public global::Together.ChatCompletionUserMessageContentMultimodalItemInputAudioInputAudioFormat? Type206 { get; set; } + public global::Together.ChatCompletionUserMessageContentMultimodalItemInputAudioInputAudio? Type206 { get; set; } /// /// /// - public global::Together.ChatCompletionAssistantMessageParamRole? Type207 { get; set; } + public global::Together.ChatCompletionUserMessageContentMultimodalItemInputAudioInputAudioFormat? Type207 { get; set; } /// /// /// - public global::Together.ChatCompletionAssistantMessageParamFunctionCall? Type208 { get; set; } + public global::Together.ChatCompletionAssistantMessageParamRole? Type208 { get; set; } /// /// /// - public global::Together.ChatCompletionFunctionMessageParamRole? Type209 { get; set; } + public global::Together.ChatCompletionAssistantMessageParamFunctionCall? Type209 { get; set; } /// /// /// - public global::Together.ChatCompletionToolMessageParamRole? Type210 { get; set; } + public global::Together.ChatCompletionFunctionMessageParamRole? Type210 { get; set; } /// /// /// - public global::Together.ChatCompletionResponse? Type211 { get; set; } + public global::Together.ChatCompletionToolMessageParamRole? Type211 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type212 { get; set; } + public global::Together.ChatCompletionResponse? Type212 { get; set; } /// /// /// - public global::Together.ChatCompletionStream? Type213 { get; set; } + public global::System.Collections.Generic.IList? Type213 { get; set; } /// /// /// - public global::Together.ChatCompletionEvent? Type214 { get; set; } + public global::Together.ChatCompletionStream? Type214 { get; set; } /// /// /// - public global::Together.ChatCompletionChunk? Type215 { get; set; } + public global::Together.ChatCompletionEvent? Type215 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type216 { get; set; } + public global::Together.ChatCompletionChunk? Type216 { get; set; } /// /// /// - public global::Together.ChatCompletionChunkChoice? Type217 { get; set; } + public global::System.Collections.Generic.IList? Type217 { get; set; } /// /// /// - public global::Together.ChatCompletionChunkChoiceDelta? Type218 { get; set; } + public global::Together.ChatCompletionChunkChoice? Type218 { get; set; } /// /// /// - public global::Together.ChatCompletionChunkChoiceDeltaRole? Type219 { get; set; } + public global::Together.ChatCompletionChunkChoiceDelta? Type219 { get; set; } /// /// /// - public global::Together.ChatCompletionChunkChoiceDeltaFunctionCall? Type220 { get; set; } + public global::Together.ChatCompletionChunkChoiceDeltaRole? Type220 { get; set; } /// /// /// - public global::Together.AudioSpeechRequest? Type221 { get; set; } + public global::Together.ChatCompletionChunkChoiceDeltaFunctionCall? Type221 { get; set; } /// /// /// - public global::Together.AnyOf? Type222 { get; set; } + public global::Together.AudioSpeechRequest? Type222 { get; set; } /// /// /// - public global::Together.AudioSpeechRequestModel? Type223 { get; set; } + public global::Together.AnyOf? Type223 { get; set; } /// /// /// - public global::Together.AudioSpeechRequestResponseFormat? Type224 { get; set; } + public global::Together.AudioSpeechRequestModel? Type224 { get; set; } /// /// /// - public global::Together.AudioSpeechRequestLanguage? Type225 { get; set; } + public global::Together.AudioSpeechRequestResponseFormat? Type225 { get; set; } /// /// /// @@ -936,55 +936,55 @@ public sealed partial class JsonSerializerContextTypes /// /// /// - public global::Together.AudioTranscriptionRequest? Type227 { get; set; } + public global::Together.AudioSpeechRequestExtraParams? Type227 { get; set; } /// /// /// - public global::Together.OneOf? Type228 { get; set; } + public global::Together.AudioTranscriptionRequest? Type228 { get; set; } /// /// /// - public byte[]? Type229 { get; set; } + public global::Together.OneOf? Type229 { get; set; } /// /// /// - public global::Together.AudioTranscriptionRequestModel? Type230 { get; set; } + public byte[]? Type230 { get; set; } /// /// /// - public global::Together.AudioTranscriptionRequestResponseFormat? Type231 { get; set; } + public global::Together.AudioTranscriptionRequestModel? Type231 { get; set; } /// /// /// - public global::Together.OneOf>? Type232 { get; set; } + public global::Together.AudioTranscriptionRequestResponseFormat? Type232 { get; set; } /// /// /// - public global::Together.AudioTranscriptionRequestTimestampGranularities? Type233 { get; set; } + public global::Together.OneOf>? Type233 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type234 { get; set; } + public global::Together.AudioTranscriptionRequestTimestampGranularities? Type234 { get; set; } /// /// /// - public global::Together.AudioTranscriptionRequestTimestampGranularitie? Type235 { get; set; } + public global::System.Collections.Generic.IList? Type235 { get; set; } /// /// /// - public global::Together.AudioTranscriptionResponse? Type236 { get; set; } + public global::Together.AudioTranscriptionRequestTimestampGranularitie? Type236 { get; set; } /// /// /// - public global::Together.AudioTranscriptionJsonResponse? Type237 { get; set; } + public global::Together.AudioTranscriptionResponse? Type237 { get; set; } /// /// /// - public global::Together.AudioTranscriptionVerboseJsonResponse? Type238 { get; set; } + public global::Together.AudioTranscriptionJsonResponse? Type238 { get; set; } /// /// /// - public global::Together.AudioTranscriptionVerboseJsonResponseTask? Type239 { get; set; } + public global::Together.AudioTranscriptionVerboseJsonResponse? Type239 { get; set; } /// /// /// @@ -1052,127 +1052,127 @@ public sealed partial class JsonSerializerContextTypes /// /// /// - public global::Together.AudioTranslationVerboseJsonResponseTask? Type256 { get; set; } + public global::Together.AudioSpeechStreamResponse? Type256 { get; set; } /// /// /// - public global::Together.AudioSpeechStreamResponse? Type257 { get; set; } + public global::Together.AudioSpeechStreamEvent? Type257 { get; set; } /// /// /// - public global::Together.AudioSpeechStreamEvent? Type258 { get; set; } + public global::Together.AudioSpeechStreamChunk? Type258 { get; set; } /// /// /// - public global::Together.AudioSpeechStreamChunk? Type259 { get; set; } + public global::Together.StreamSentinelData? Type259 { get; set; } /// /// /// - public global::Together.StreamSentinelData? Type260 { get; set; } + public global::Together.ChatCompletionToken? Type260 { get; set; } /// /// /// - public global::Together.ChatCompletionToken? Type261 { get; set; } + public global::Together.ChatCompletionChoice? Type261 { get; set; } /// /// /// - public global::Together.ChatCompletionChoice? Type262 { get; set; } + public global::Together.ChatCompletionChoiceDelta? Type262 { get; set; } /// /// /// - public global::Together.ChatCompletionChoiceDelta? Type263 { get; set; } + public global::Together.ChatCompletionChoiceDeltaRole? Type263 { get; set; } /// /// /// - public global::Together.ChatCompletionChoiceDeltaRole? Type264 { get; set; } + public global::Together.ChatCompletionChoiceDeltaFunctionCall? Type264 { get; set; } /// /// /// - public global::Together.ChatCompletionChoiceDeltaFunctionCall? Type265 { get; set; } + public global::Together.EmbeddingsRequest? Type265 { get; set; } /// /// /// - public global::Together.EmbeddingsRequest? Type266 { get; set; } + public global::Together.AnyOf? Type266 { get; set; } /// /// /// - public global::Together.AnyOf? Type267 { get; set; } + public global::Together.EmbeddingsRequestModel? Type267 { get; set; } /// /// /// - public global::Together.EmbeddingsRequestModel? Type268 { get; set; } + public global::Together.OneOf>? Type268 { get; set; } /// /// /// - public global::Together.OneOf>? Type269 { get; set; } + public global::Together.EmbeddingsResponse? Type269 { get; set; } /// /// /// - public global::Together.EmbeddingsResponse? Type270 { get; set; } + public global::System.Collections.Generic.IList? Type270 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type271 { get; set; } + public global::Together.EmbeddingsResponseDataItem? Type271 { get; set; } /// /// /// - public global::Together.EmbeddingsResponseDataItem? Type272 { get; set; } + public global::System.Collections.Generic.IList? Type272 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type273 { get; set; } + public global::Together.ModelInfo? Type273 { get; set; } /// /// /// - public global::Together.ModelInfo? Type274 { get; set; } + public global::Together.ModelInfoType? Type274 { get; set; } /// /// /// - public global::Together.ModelInfoType? Type275 { get; set; } + public global::Together.Pricing? Type275 { get; set; } /// /// /// - public global::Together.Pricing? Type276 { get; set; } + public global::Together.ModelUploadRequest? Type276 { get; set; } /// /// /// - public global::Together.ModelUploadRequest? Type277 { get; set; } + public global::Together.ModelUploadRequestModelType? Type277 { get; set; } /// /// /// - public global::Together.ModelUploadRequestModelType? Type278 { get; set; } + public global::Together.ModelUploadSuccessResponse? Type278 { get; set; } /// /// /// - public global::Together.ModelUploadSuccessResponse? Type279 { get; set; } + public global::Together.ModelUploadSuccessResponseData? Type279 { get; set; } /// /// /// - public global::Together.ModelUploadSuccessResponseData? Type280 { get; set; } + public global::Together.ImageResponse? Type280 { get; set; } /// /// /// - public global::Together.ImageResponse? Type281 { get; set; } + public global::System.Collections.Generic.IList? Type281 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type282 { get; set; } + public global::Together.DataItem3? Type282 { get; set; } /// /// /// - public global::Together.DataItem3? Type283 { get; set; } + public global::Together.ImageResponseDataB64? Type283 { get; set; } /// /// /// - public global::Together.ImageResponseDataB64? Type284 { get; set; } + public global::Together.ImageResponseDataUrl? Type284 { get; set; } /// /// /// - public global::Together.ImageResponseDataUrl? Type285 { get; set; } + public global::Together.ImageResponseDataItemDiscriminator? Type285 { get; set; } /// /// /// - public global::Together.ImageResponseDataItemDiscriminator? Type286 { get; set; } + public global::Together.ImageResponseDataItemDiscriminatorType? Type286 { get; set; } /// /// /// @@ -1564,635 +1564,655 @@ public sealed partial class JsonSerializerContextTypes /// /// /// - public global::Together.ExecuteResponseSuccessfulExecutionDataStatus? Type384 { get; set; } + public global::Together.ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorType? Type384 { get; set; } /// /// /// - public global::Together.ExecuteResponseFailedExecution? Type385 { get; set; } + public global::Together.ExecuteResponseSuccessfulExecutionDataStatus? Type385 { get; set; } /// /// /// - public global::System.Collections.Generic.IList>? Type386 { get; set; } + public global::Together.ExecuteResponseFailedExecution? Type386 { get; set; } /// /// /// - public global::Together.OneOf? Type387 { get; set; } + public global::System.Collections.Generic.IList>? Type387 { get; set; } /// /// /// - public global::Together.InterpreterOutput? Type388 { get; set; } + public global::Together.OneOf? Type388 { get; set; } /// /// /// - public global::Together.InterpreterOutputStreamOutput? Type389 { get; set; } + public global::Together.InterpreterOutput? Type389 { get; set; } /// /// /// - public global::Together.InterpreterOutputStreamOutputType? Type390 { get; set; } + public global::Together.InterpreterOutputStreamOutput? Type390 { get; set; } /// /// /// - public global::Together.InterpreterOutputErrorOutput? Type391 { get; set; } + public global::Together.InterpreterOutputStreamOutputType? Type391 { get; set; } /// /// /// - public global::Together.InterpreterOutputErrorOutputType? Type392 { get; set; } + public global::Together.InterpreterOutputErrorOutput? Type392 { get; set; } /// /// /// - public global::Together.InterpreterOutputDisplayorExecuteOutput? Type393 { get; set; } + public global::Together.InterpreterOutputErrorOutputType? Type393 { get; set; } /// /// /// - public global::Together.InterpreterOutputDisplayorExecuteOutputData? Type394 { get; set; } + public global::Together.InterpreterOutputDisplayorExecuteOutput? Type394 { get; set; } /// /// /// - public global::Together.InterpreterOutputDisplayorExecuteOutputType? Type395 { get; set; } + public global::Together.InterpreterOutputDisplayorExecuteOutputData? Type395 { get; set; } /// /// /// - public global::Together.InterpreterOutputDiscriminator? Type396 { get; set; } + public global::Together.InterpreterOutputDisplayorExecuteOutputType? Type396 { get; set; } /// /// /// - public global::Together.Response? Type397 { get; set; } + public global::Together.InterpreterOutputDiscriminator? Type397 { get; set; } /// /// /// - public global::Together.SessionListResponse? Type398 { get; set; } + public global::Together.InterpreterOutputDiscriminatorType? Type398 { get; set; } /// /// /// - public global::Together.SessionListResponseResponse? Type399 { get; set; } + public global::Together.Response? Type399 { get; set; } /// /// /// - public global::Together.SessionListResponseVariant2? Type400 { get; set; } + public global::Together.SessionListResponse? Type400 { get; set; } /// /// /// - public global::Together.SessionListResponseVariant2Data? Type401 { get; set; } + public global::Together.SessionListResponseResponse? Type401 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type402 { get; set; } + public global::Together.SessionListResponseVariant2? Type402 { get; set; } /// /// /// - public global::Together.SessionListResponseVariant2DataSession? Type403 { get; set; } + public global::Together.SessionListResponseVariant2Data? Type403 { get; set; } /// /// /// - public global::Together.StreamOutput? Type404 { get; set; } + public global::System.Collections.Generic.IList? Type404 { get; set; } /// /// /// - public global::Together.StreamOutputType? Type405 { get; set; } + public global::Together.SessionListResponseVariant2DataSession? Type405 { get; set; } /// /// /// - public global::Together.CreateBatchRequest? Type406 { get; set; } + public global::Together.StreamOutput? Type406 { get; set; } /// /// /// - public global::Together.BatchErrorResponse? Type407 { get; set; } + public global::Together.StreamOutputType? Type407 { get; set; } /// /// /// - public global::Together.BatchJobWithWarning? Type408 { get; set; } + public global::Together.CreateBatchRequest? Type408 { get; set; } /// /// /// - public global::Together.BatchJob? Type409 { get; set; } + public global::Together.CreateBatchRequestEndpoint? Type409 { get; set; } /// /// /// - public global::Together.BatchJobStatus? Type410 { get; set; } + public global::Together.BatchErrorResponse? Type410 { get; set; } /// /// /// - public global::Together.EvaluationTypedRequest? Type411 { get; set; } + public global::Together.BatchJobWithWarning? Type411 { get; set; } /// /// /// - public global::Together.EvaluationTypedRequestType? Type412 { get; set; } + public global::Together.BatchJob? Type412 { get; set; } /// /// /// - public global::Together.OneOf? Type413 { get; set; } + public global::Together.BatchJobStatus? Type413 { get; set; } /// /// /// - public global::Together.EvaluationClassifyParameters? Type414 { get; set; } + public global::Together.EvaluationTypedRequest? Type414 { get; set; } /// /// /// - public global::Together.EvaluationScoreParameters? Type415 { get; set; } + public global::Together.EvaluationTypedRequestType? Type415 { get; set; } /// /// /// - public global::Together.EvaluationCompareParameters? Type416 { get; set; } + public global::Together.OneOf? Type416 { get; set; } /// /// /// - public global::Together.EvaluationJudgeModelConfig? Type417 { get; set; } + public global::Together.EvaluationClassifyParameters? Type417 { get; set; } /// /// /// - public global::Together.EvaluationModelOrString? Type418 { get; set; } + public global::Together.EvaluationScoreParameters? Type418 { get; set; } /// /// /// - public global::Together.EvaluationJudgeModelConfigModelSource? Type419 { get; set; } + public global::Together.EvaluationCompareParameters? Type419 { get; set; } /// /// /// - public global::Together.EvaluationModelRequest? Type420 { get; set; } + public global::Together.EvaluationJudgeModelConfig? Type420 { get; set; } /// /// /// - public global::Together.EvaluationModelRequestModelSource? Type421 { get; set; } + public global::Together.EvaluationModelOrString? Type421 { get; set; } /// /// /// - public global::Together.EvaluationResponse? Type422 { get; set; } + public global::Together.EvaluationJudgeModelConfigModelSource? Type422 { get; set; } /// /// /// - public global::Together.EvaluationResponseStatus? Type423 { get; set; } + public global::Together.EvaluationModelRequest? Type423 { get; set; } /// /// /// - public global::Together.EvaluationJob? Type424 { get; set; } + public global::Together.EvaluationModelRequestModelSource? Type424 { get; set; } /// /// /// - public global::Together.EvaluationJobType? Type425 { get; set; } + public global::Together.EvaluationResponse? Type425 { get; set; } /// /// /// - public global::Together.EvaluationJobStatus? Type426 { get; set; } + public global::Together.EvaluationResponseStatus? Type426 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type427 { get; set; } + public global::Together.EvaluationJob? Type427 { get; set; } /// /// /// - public global::Together.EvaluationJobStatusUpdate? Type428 { get; set; } + public global::Together.EvaluationJobType? Type428 { get; set; } /// /// /// - public global::Together.OneOf? Type429 { get; set; } + public global::Together.EvaluationJobStatus? Type429 { get; set; } /// /// /// - public global::Together.EvaluationClassifyResults? Type430 { get; set; } + public global::System.Collections.Generic.IList? Type430 { get; set; } /// /// /// - public global::Together.EvaluationScoreResults? Type431 { get; set; } + public global::Together.EvaluationJobStatusUpdate? Type431 { get; set; } /// /// /// - public global::Together.EvaluationCompareResults? Type432 { get; set; } + public global::Together.OneOf? Type432 { get; set; } /// /// /// - public global::Together.EvaluationJobResults? Type433 { get; set; } + public global::Together.EvaluationClassifyResults? Type433 { get; set; } /// /// /// - public global::Together.EvaluationScoreResultsAggregatedScores? Type434 { get; set; } + public global::Together.EvaluationScoreResults? Type434 { get; set; } /// /// /// - public global::Together.CreateVideoBody? Type435 { get; set; } + public global::Together.EvaluationCompareResults? Type435 { get; set; } /// /// /// - public global::Together.VideoOutputFormat? Type436 { get; set; } + public global::Together.EvaluationJobResults? Type436 { get; set; } /// /// /// - public global::Together.VideoMedia? Type437 { get; set; } + public global::Together.EvaluationScoreResultsAggregatedScores? Type437 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type438 { get; set; } + public global::Together.CreateVideoBody? Type438 { get; set; } /// /// /// - public global::Together.VideoFrameImageInput? Type439 { get; set; } + public global::Together.VideoOutputFormat? Type439 { get; set; } /// /// /// - public global::Together.VideoStatus? Type440 { get; set; } + public global::Together.VideoMedia? Type440 { get; set; } /// /// /// - public global::Together.AnyOf? Type441 { get; set; } + public global::System.Collections.Generic.IList? Type441 { get; set; } /// /// /// - public global::Together.VideoFrameImageInputFrame? Type442 { get; set; } + public global::Together.VideoFrameImageInput? Type442 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type443 { get; set; } + public global::Together.VideoStatus? Type443 { get; set; } /// /// /// - public global::Together.VideoRef? Type444 { get; set; } + public global::Together.AnyOf? Type444 { get; set; } /// /// /// - public global::Together.OneOf? Type445 { get; set; } + public global::Together.VideoFrameImageInputFrame? Type445 { get; set; } /// /// /// - public global::System.Collections.Generic.IList>? Type446 { get; set; } + public global::System.Collections.Generic.IList? Type446 { get; set; } /// /// /// - public global::Together.OneOf? Type447 { get; set; } + public global::Together.VideoRef? Type447 { get; set; } /// /// /// - public global::Together.AudioRef? Type448 { get; set; } + public global::Together.OneOf? Type448 { get; set; } /// /// /// - public global::Together.VideoJob? Type449 { get; set; } + public global::System.Collections.Generic.IList>? Type449 { get; set; } /// /// /// - public global::Together.VideoJobError? Type450 { get; set; } + public global::Together.OneOf? Type450 { get; set; } /// /// /// - public global::Together.VideoJobOutputs? Type451 { get; set; } + public global::Together.AudioRef? Type451 { get; set; } /// /// /// - public global::Together.ContainerStatus? Type452 { get; set; } + public global::Together.VideoJob? Type452 { get; set; } /// /// /// - public global::Together.CreateDeploymentRequest? Type453 { get; set; } + public global::Together.VideoJobError? Type453 { get; set; } /// /// /// - public global::Together.OneOf? Type454 { get; set; } + public global::Together.VideoJobOutputs? Type454 { get; set; } /// /// /// - public global::Together.HTTPAutoscalingConfig? Type455 { get; set; } + public global::Together.ContainerStatus? Type455 { get; set; } /// /// /// - public global::Together.QueueAutoscalingConfig? Type456 { get; set; } + public global::Together.CreateDeploymentRequest? Type456 { get; set; } /// /// /// - public global::Together.CustomMetricAutoscalingConfig? Type457 { get; set; } + public global::Together.OneOf? Type457 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type458 { get; set; } + public global::Together.HTTPAutoscalingConfig? Type458 { get; set; } /// /// /// - public global::Together.EnvironmentVariable? Type459 { get; set; } + public global::Together.QueueAutoscalingConfig? Type459 { get; set; } /// /// /// - public global::Together.CreateDeploymentRequestGpuType? Type460 { get; set; } + public global::Together.CustomMetricAutoscalingConfig? Type460 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type461 { get; set; } + public global::System.Collections.Generic.IList? Type461 { get; set; } /// /// /// - public global::Together.VolumeMount? Type462 { get; set; } + public global::Together.EnvironmentVariable? Type462 { get; set; } /// /// /// - public global::Together.CreateSecretRequest? Type463 { get; set; } + public global::Together.CreateDeploymentRequestGpuType? Type463 { get; set; } /// /// /// - public global::Together.CreateVolumeRequest? Type464 { get; set; } + public global::System.Collections.Generic.IList? Type464 { get; set; } /// /// /// - public global::Together.VolumeContentRequest? Type465 { get; set; } + public global::Together.VolumeMount? Type465 { get; set; } /// /// /// - public global::Together.VolumeType? Type466 { get; set; } + public global::Together.CreateSecretRequest? Type466 { get; set; } /// /// /// - public global::Together.DeploymentListResponse? Type467 { get; set; } + public global::Together.CreateVolumeRequest? Type467 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type468 { get; set; } + public global::Together.VolumeContentRequest? Type468 { get; set; } /// /// /// - public global::Together.DeploymentResponseItem? Type469 { get; set; } + public global::Together.VolumeType? Type469 { get; set; } /// /// /// - public global::Together.DeploymentLogs? Type470 { get; set; } + public global::Together.DeploymentListResponse? Type470 { get; set; } /// /// /// - public global::Together.DeploymentResponseItemGpuType? Type471 { get; set; } + public global::System.Collections.Generic.IList? Type471 { get; set; } /// /// /// - public global::System.Collections.Generic.Dictionary? Type472 { get; set; } + public global::Together.DeploymentResponseItem? Type472 { get; set; } /// /// /// - public global::Together.ReplicaEvent? Type473 { get; set; } + public global::Together.DeploymentLogs? Type473 { get; set; } /// /// /// - public global::Together.DeploymentStatus? Type474 { get; set; } + public global::Together.DeploymentResponseItemGpuType? Type474 { get; set; } /// /// /// - public global::Together.HTTPAutoscalingConfigMetric? Type475 { get; set; } + public global::System.Collections.Generic.Dictionary? Type475 { get; set; } /// /// /// - public global::Together.QueueAutoscalingConfigMetric? Type476 { get; set; } + public global::Together.ReplicaEvent? Type476 { get; set; } /// /// /// - public global::Together.CustomMetricAutoscalingConfigMetric? Type477 { get; set; } + public global::Together.DeploymentStatus? Type477 { get; set; } /// /// /// - public global::Together.KubernetesEvent? Type478 { get; set; } + public global::Together.HTTPAutoscalingConfigMetric? Type478 { get; set; } /// /// /// - public global::Together.ListSecretsResponse? Type479 { get; set; } + public global::Together.QueueAutoscalingConfigMetric? Type479 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type480 { get; set; } + public global::Together.CustomMetricAutoscalingConfigMetric? Type480 { get; set; } /// /// /// - public global::Together.SecretResponseItem? Type481 { get; set; } + public global::Together.KubernetesEvent? Type481 { get; set; } /// /// /// - public global::Together.ListVolumesResponse? Type482 { get; set; } + public global::Together.ListSecretsResponse? Type482 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type483 { get; set; } + public global::System.Collections.Generic.IList? Type483 { get; set; } /// /// /// - public global::Together.VolumeResponseItem? Type484 { get; set; } + public global::Together.SecretResponseItem? Type484 { get; set; } /// /// /// - public global::Together.UpdateDeploymentRequest? Type485 { get; set; } + public global::Together.ListVolumesResponse? Type485 { get; set; } /// /// /// - public global::Together.UpdateDeploymentRequestGpuType? Type486 { get; set; } + public global::System.Collections.Generic.IList? Type486 { get; set; } /// /// /// - public global::Together.UpdateSecretRequest? Type487 { get; set; } + public global::Together.VolumeResponseItem? Type487 { get; set; } /// /// /// - public global::Together.UpdateVolumeRequest? Type488 { get; set; } + public global::Together.UpdateDeploymentRequest? Type488 { get; set; } /// /// /// - public global::Together.VolumeContent? Type489 { get; set; } + public global::Together.UpdateDeploymentRequestGpuType? Type489 { get; set; } /// /// /// - public global::System.Collections.Generic.Dictionary? Type490 { get; set; } + public global::Together.UpdateSecretRequest? Type490 { get; set; } /// /// /// - public global::Together.VersionHistoryItem? Type491 { get; set; } + public global::Together.UpdateVolumeRequest? Type491 { get; set; } /// /// /// - public global::Together.VolumeContentRequestType? Type492 { get; set; } + public global::Together.VolumeContent? Type492 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type493 { get; set; } + public global::System.Collections.Generic.Dictionary? Type493 { get; set; } /// /// /// - public global::Together.FileInfo? Type494 { get; set; } + public global::Together.VersionHistoryItem? Type494 { get; set; } /// /// /// - public global::Together.VolumeContentType? Type495 { get; set; } + public global::Together.VolumeContentRequestType? Type495 { get; set; } /// /// /// - public global::Together.QueueError? Type496 { get; set; } + public global::System.Collections.Generic.IList? Type496 { get; set; } /// /// /// - public global::Together.QueueMetricsResponse? Type497 { get; set; } + public global::Together.FileInfo? Type497 { get; set; } /// /// /// - public global::Together.QueueCancelRequest? Type498 { get; set; } + public global::Together.VolumeContentType? Type498 { get; set; } /// /// /// - public global::Together.QueueCancelResponse? Type499 { get; set; } + public global::Together.QueueError? Type499 { get; set; } /// /// /// - public global::Together.QueueCancelResponseStatus? Type500 { get; set; } + public global::Together.QueueMetricsResponse? Type500 { get; set; } /// /// /// - public global::Together.QueueJobRequest? Type501 { get; set; } + public global::Together.QueueCancelRequest? Type501 { get; set; } /// /// /// - public global::Together.QueueJobResponse? Type502 { get; set; } + public global::Together.QueueCancelResponse? Type502 { get; set; } /// /// /// - public global::Together.QueueJobStatusResponse? Type503 { get; set; } + public global::Together.QueueCancelResponseStatus? Type503 { get; set; } /// /// /// - public global::Together.QueueJobStatusResponseStatus? Type504 { get; set; } + public global::Together.QueueJobRequest? Type504 { get; set; } /// /// /// - public global::Together.CreateImagesGenerationsRequest? Type505 { get; set; } + public global::Together.QueueJobResponse? Type505 { get; set; } /// /// /// - public global::Together.AnyOf? Type506 { get; set; } + public global::Together.QueueJobStatusResponse? Type506 { get; set; } /// /// /// - public global::Together.CreateImagesGenerationsRequestModel? Type507 { get; set; } + public global::Together.QueueJobStatusResponseStatus? Type507 { get; set; } /// /// /// - public global::Together.CreateImagesGenerationsRequestResponseFormat? Type508 { get; set; } + public global::Together.CreateImagesGenerationsRequest? Type508 { get; set; } /// /// /// - public global::Together.CreateImagesGenerationsRequestOutputFormat? Type509 { get; set; } + public global::Together.AnyOf? Type509 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type510 { get; set; } + public global::Together.CreateImagesGenerationsRequestModel? Type510 { get; set; } /// /// /// - public global::Together.CreateImagesGenerationsRequestImageLora? Type511 { get; set; } + public global::Together.CreateImagesGenerationsRequestResponseFormat? Type511 { get; set; } /// /// /// - public global::Together.CreateFilesUploadRequest? Type512 { get; set; } + public global::Together.CreateImagesGenerationsRequestOutputFormat? Type512 { get; set; } /// /// /// - public global::Together.CreateFineTunesRequest? Type513 { get; set; } + public global::System.Collections.Generic.IList? Type513 { get; set; } /// /// /// - public global::Together.OneOf? Type514 { get; set; } + public global::Together.CreateImagesGenerationsRequestImageLora? Type514 { get; set; } /// /// /// - public global::Together.CreateFineTunesRequestBatchSize? Type515 { get; set; } + public global::Together.CreateFilesUploadRequest? Type515 { get; set; } /// /// /// - public global::Together.OneOf? Type516 { get; set; } + public global::Together.CreateFineTunesRequest? Type516 { get; set; } /// /// /// - public global::Together.CreateFineTunesRequestTrainOnInputs? Type517 { get; set; } + public global::Together.OneOf? Type517 { get; set; } /// /// /// - public global::Together.AnyOf? Type518 { get; set; } + public global::Together.CreateFineTunesRequestBatchSize? Type518 { get; set; } /// /// /// - public global::Together.CreateFineTunesEstimatePriceRequest? Type519 { get; set; } + public global::Together.OneOf? Type519 { get; set; } /// /// /// - public global::Together.UpdateEndpointRequest? Type520 { get; set; } + public global::Together.CreateFineTunesRequestTrainOnInputs? Type520 { get; set; } /// /// /// - public global::Together.UpdateEndpointRequestState? Type521 { get; set; } + public global::Together.AnyOf? Type521 { get; set; } /// /// /// - public global::Together.GetFinetuneDownloadCheckpoint? Type522 { get; set; } + public global::Together.CreateFineTunesEstimatePriceRequest? Type522 { get; set; } /// /// /// - public global::Together.RealtimeTtsModel? Type523 { get; set; } + public global::Together.UpdateEndpointRequest? Type523 { get; set; } /// /// /// - public global::Together.ListEndpointsType? Type524 { get; set; } + public global::Together.UpdateEndpointRequestState? Type524 { get; set; } /// /// /// - public global::Together.ListEndpointsUsageType? Type525 { get; set; } + public global::Together.GetFinetuneDownloadCheckpoint? Type525 { get; set; } /// /// /// - public global::Together.RealtimeTranscriptionInputAudioFormat? Type526 { get; set; } + public global::Together.RealtimeTtsModel? Type526 { get; set; } /// /// /// - public global::System.Collections.Generic.Dictionary? Type527 { get; set; } + public global::Together.ListEndpointsType? Type527 { get; set; } /// /// /// - public global::Together.CreateFineTunesEstimatePriceResponse? Type528 { get; set; } + public global::Together.ListEndpointsUsageType? Type528 { get; set; } /// /// /// - public global::Together.GetFineTunesModelsSupportedResponse? Type529 { get; set; } + public global::Together.RealtimeTranscriptionInputAudioFormat? Type529 { get; set; } /// /// /// - public global::Together.GetFineTunesModelsLimitsResponse? Type530 { get; set; } + public global::System.Collections.Generic.Dictionary? Type530 { get; set; } /// /// /// - public global::Together.GPUClusterServiceDeleteResponse? Type531 { get; set; } + public global::Together.CreateFineTunesEstimatePriceResponse? Type531 { get; set; } /// /// /// - public global::Together.ListEndpointsResponse? Type532 { get; set; } + public global::Together.GetFineTunesMetricsResponse? Type532 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type533 { get; set; } + public global::System.Collections.Generic.IList>? Type533 { get; set; } /// /// /// - public global::Together.ListHardwareResponse? Type534 { get; set; } + public global::Together.GetFineTunesModelsSupportedResponse? Type534 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type535 { get; set; } + public global::Together.GetFineTunesModelsLimitsResponse? Type535 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type536 { get; set; } + public global::Together.GPUClusterServiceDeleteResponse? Type536 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type537 { get; set; } + public global::Together.ListEndpointsResponse? Type537 { get; set; } /// /// /// - public global::Together.GetModelListResponse? Type538 { get; set; } + public global::System.Collections.Generic.IList? Type538 { get; set; } /// /// /// - public global::Together.GetEvaluationJobStatusAndResultsResponse? Type539 { get; set; } + public global::Together.ListHardwareResponse? Type539 { get; set; } /// /// /// - public global::Together.GetEvaluationJobStatusAndResultsResponseStatus? Type540 { get; set; } + public global::System.Collections.Generic.IList? Type540 { get; set; } /// /// /// - public global::Together.OneOf? Type541 { get; set; } + public global::System.Collections.Generic.IList? Type541 { get; set; } + /// + /// + /// + public global::System.Collections.Generic.IList? Type542 { get; set; } + /// + /// + /// + public global::Together.GetModelListResponse? Type543 { get; set; } + /// + /// + /// + public global::Together.GetEvaluationJobStatusAndResultsResponse? Type544 { get; set; } + /// + /// + /// + public global::Together.GetEvaluationJobStatusAndResultsResponseStatus? Type545 { get; set; } + /// + /// + /// + public global::Together.OneOf? Type546 { get; set; } /// /// @@ -2465,18 +2485,22 @@ public sealed partial class JsonSerializerContextTypes /// /// /// - public global::System.Collections.Generic.List? ListType67 { get; set; } + public global::System.Collections.Generic.List>? ListType67 { get; set; } + /// + /// + /// + public global::System.Collections.Generic.List? ListType68 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType68 { get; set; } + public global::System.Collections.Generic.List? ListType69 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType69 { get; set; } + public global::System.Collections.Generic.List? ListType70 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType70 { get; set; } + public global::System.Collections.Generic.List? ListType71 { get; set; } } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.AudioRef.g.cs b/src/libs/Together/Generated/Together.Models.AudioRef.g.cs index 6b9092c3..f6642edf 100644 --- a/src/libs/Together/Generated/Together.Models.AudioRef.g.cs +++ b/src/libs/Together/Generated/Together.Models.AudioRef.g.cs @@ -42,5 +42,6 @@ public AudioRef( public AudioRef() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.AudioSpeechRequest.g.cs b/src/libs/Together/Generated/Together.Models.AudioSpeechRequest.g.cs index 805825d5..9531e556 100644 --- a/src/libs/Together/Generated/Together.Models.AudioSpeechRequest.g.cs +++ b/src/libs/Together/Generated/Together.Models.AudioSpeechRequest.g.cs @@ -26,7 +26,7 @@ public sealed partial class AudioSpeechRequest public required string Input { get; set; } /// - /// The voice to use for generating the audio. The voices supported are different for each model. For eg - for canopylabs/orpheus-3b-0.1-ft, one of the voices supported is tara, for hexgrad/Kokoro-82M, one of the voices supported is af_alloy and for cartesia/sonic, one of the voices supported is "friendly sidekick". You can view the voices supported for each model using the /v1/voices endpoint sending the model name as the query parameter. [View all supported voices here](https://docs.together.ai/docs/text-to-speech#supported-voices). + /// The voice to use for generating the audio. The voices supported are different for each model. For eg - for canopylabs/orpheus-3b-0.1-ft, one of the voices supported is tara, for hexgrad/Kokoro-82M, one of the voices supported is af_alloy and for cartesia/sonic, one of the voices supported is "friendly sidekick". You can view the voices supported for each model using the /v1/voices endpoint sending the model name as the query parameter. [View all supported voices here](https://docs.together.ai/docs/text-to-speech#supported-voices). `hexgrad/Kokoro-82M` additionally supports voice mixing, where two or more voices are combined into a single blended voice by joining their names with `+` (e.g. `af_bella+af_heart`). Optional per-voice weights can be provided in parentheses (e.g. `af_bella(2)+af_heart(1)`). Other models require a single voice name. /// [global::System.Text.Json.Serialization.JsonPropertyName("voice")] [global::System.Text.Json.Serialization.JsonRequired] @@ -41,15 +41,16 @@ public sealed partial class AudioSpeechRequest public global::Together.AudioSpeechRequestResponseFormat? ResponseFormat { get; set; } /// - /// Language of input text.
- /// Default Value: en + /// Language or locale of input text. Accepts ISO 639-1 language codes (e.g., `en`, `fr`, `es`, `zh`) as well as locale codes for region-specific variants. Locale codes must be lowercase (e.g., `zh-hk` for Cantonese).
+ /// Default Value: en
+ /// Example: en ///
+ /// en [global::System.Text.Json.Serialization.JsonPropertyName("language")] - [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Together.JsonConverters.AudioSpeechRequestLanguageJsonConverter))] - public global::Together.AudioSpeechRequestLanguage? Language { get; set; } + public string? Language { get; set; } /// - /// Audio encoding of response
+ /// Audio encoding of response. Only applicable when response_format is raw or pcm. Cartesia models respect this parameter and support all values. Orpheus, Kokoro, and Minimax models always return pcm_s16le regardless of this setting.
/// Default Value: pcm_f32le ///
[global::System.Text.Json.Serialization.JsonPropertyName("response_encoding")] @@ -57,7 +58,7 @@ public sealed partial class AudioSpeechRequest public global::Together.AudioSpeechRequestResponseEncoding? ResponseEncoding { get; set; } /// - /// Sampling rate to use for the output audio. The default sampling rate for canopylabs/orpheus-3b-0.1-ft and hexgrad/Kokoro-82M is 24000 and for cartesia/sonic is 44100.
+ /// Sampling rate in Hz for the output audio. Cartesia and Minimax models respect this parameter. Orpheus and Kokoro models always output at 24000 Hz regardless of this setting.
/// Default Value: 44100 ///
[global::System.Text.Json.Serialization.JsonPropertyName("sample_rate")] @@ -77,6 +78,12 @@ public sealed partial class AudioSpeechRequest [global::System.Text.Json.Serialization.JsonPropertyName("stream")] public bool? Stream { get; set; } + /// + /// Additional model-specific parameters that fine-tune speech generation behavior. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("extra_params")] + public global::Together.AudioSpeechRequestExtraParams? ExtraParams { get; set; } + /// /// Additional properties that are not explicitly defined in the schema /// @@ -94,22 +101,23 @@ public sealed partial class AudioSpeechRequest /// Input text to generate the audio for /// /// - /// The voice to use for generating the audio. The voices supported are different for each model. For eg - for canopylabs/orpheus-3b-0.1-ft, one of the voices supported is tara, for hexgrad/Kokoro-82M, one of the voices supported is af_alloy and for cartesia/sonic, one of the voices supported is "friendly sidekick". You can view the voices supported for each model using the /v1/voices endpoint sending the model name as the query parameter. [View all supported voices here](https://docs.together.ai/docs/text-to-speech#supported-voices). + /// The voice to use for generating the audio. The voices supported are different for each model. For eg - for canopylabs/orpheus-3b-0.1-ft, one of the voices supported is tara, for hexgrad/Kokoro-82M, one of the voices supported is af_alloy and for cartesia/sonic, one of the voices supported is "friendly sidekick". You can view the voices supported for each model using the /v1/voices endpoint sending the model name as the query parameter. [View all supported voices here](https://docs.together.ai/docs/text-to-speech#supported-voices). `hexgrad/Kokoro-82M` additionally supports voice mixing, where two or more voices are combined into a single blended voice by joining their names with `+` (e.g. `af_bella+af_heart`). Optional per-voice weights can be provided in parentheses (e.g. `af_bella(2)+af_heart(1)`). Other models require a single voice name. /// /// /// The format of audio output. Supported formats are mp3, wav, raw if streaming is false. If streaming is true, the only supported format is raw.
/// Default Value: wav /// /// - /// Language of input text.
- /// Default Value: en + /// Language or locale of input text. Accepts ISO 639-1 language codes (e.g., `en`, `fr`, `es`, `zh`) as well as locale codes for region-specific variants. Locale codes must be lowercase (e.g., `zh-hk` for Cantonese).
+ /// Default Value: en
+ /// Example: en /// /// - /// Audio encoding of response
+ /// Audio encoding of response. Only applicable when response_format is raw or pcm. Cartesia models respect this parameter and support all values. Orpheus, Kokoro, and Minimax models always return pcm_s16le regardless of this setting.
/// Default Value: pcm_f32le /// /// - /// Sampling rate to use for the output audio. The default sampling rate for canopylabs/orpheus-3b-0.1-ft and hexgrad/Kokoro-82M is 24000 and for cartesia/sonic is 44100.
+ /// Sampling rate in Hz for the output audio. Cartesia and Minimax models respect this parameter. Orpheus and Kokoro models always output at 24000 Hz regardless of this setting.
/// Default Value: 44100 /// /// @@ -120,6 +128,9 @@ public sealed partial class AudioSpeechRequest /// If true, output is streamed for several characters at a time instead of waiting for the full response. The stream terminates with `data: [DONE]`. If false, return the encoded audio as octet stream
/// Default Value: false /// + /// + /// Additional model-specific parameters that fine-tune speech generation behavior. + /// #if NET7_0_OR_GREATER [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] #endif @@ -128,11 +139,12 @@ public AudioSpeechRequest( string input, string voice, global::Together.AudioSpeechRequestResponseFormat? responseFormat, - global::Together.AudioSpeechRequestLanguage? language, + string? language, global::Together.AudioSpeechRequestResponseEncoding? responseEncoding, int? sampleRate, int? bitRate, - bool? stream) + bool? stream, + global::Together.AudioSpeechRequestExtraParams? extraParams) { this.Model = model; this.Input = input ?? throw new global::System.ArgumentNullException(nameof(input)); @@ -143,6 +155,7 @@ public AudioSpeechRequest( this.SampleRate = sampleRate; this.BitRate = bitRate; this.Stream = stream; + this.ExtraParams = extraParams; } /// @@ -151,5 +164,6 @@ public AudioSpeechRequest( public AudioSpeechRequest() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.AudioSpeechRequestExtraParams.Json.g.cs b/src/libs/Together/Generated/Together.Models.AudioSpeechRequestExtraParams.Json.g.cs new file mode 100644 index 00000000..12d199a3 --- /dev/null +++ b/src/libs/Together/Generated/Together.Models.AudioSpeechRequestExtraParams.Json.g.cs @@ -0,0 +1,92 @@ +#nullable enable + +namespace Together +{ + public sealed partial class AudioSpeechRequestExtraParams + { + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerContext. + /// + public string ToJson( + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Serialize( + this, + this.GetType(), + jsonSerializerContext); + } + + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public string ToJson( + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + return global::System.Text.Json.JsonSerializer.Serialize( + this, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerContext. + /// + public static global::Together.AudioSpeechRequestExtraParams? FromJson( + string json, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + typeof(global::Together.AudioSpeechRequestExtraParams), + jsonSerializerContext) as global::Together.AudioSpeechRequestExtraParams; + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::Together.AudioSpeechRequestExtraParams? FromJson( + string json, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerContext. + /// + public static async global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return (await global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + typeof(global::Together.AudioSpeechRequestExtraParams), + jsonSerializerContext).ConfigureAwait(false)) as global::Together.AudioSpeechRequestExtraParams; + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + return global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + jsonSerializerOptions); + } + } +} diff --git a/src/libs/Together/Generated/Together.Models.AudioSpeechRequestExtraParams.g.cs b/src/libs/Together/Generated/Together.Models.AudioSpeechRequestExtraParams.g.cs new file mode 100644 index 00000000..3ba6c642 --- /dev/null +++ b/src/libs/Together/Generated/Together.Models.AudioSpeechRequestExtraParams.g.cs @@ -0,0 +1,49 @@ + +#nullable enable + +namespace Together +{ + /// + /// Additional model-specific parameters that fine-tune speech generation behavior. + /// + public sealed partial class AudioSpeechRequestExtraParams + { + /// + /// A list of pronunciation rules for specific characters or symbols. Each entry uses the format `"<source>/<replacement>"` (e.g., `["omg/oh my god"]`) to override how the model pronounces matching tokens.
+ /// Example: [omg/oh my god] + ///
+ /// [omg/oh my god] + [global::System.Text.Json.Serialization.JsonPropertyName("pronunciation_dict")] + public global::System.Collections.Generic.IList? PronunciationDict { get; set; } + + /// + /// Additional properties that are not explicitly defined in the schema + /// + [global::System.Text.Json.Serialization.JsonExtensionData] + public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + + /// + /// Initializes a new instance of the class. + /// + /// + /// A list of pronunciation rules for specific characters or symbols. Each entry uses the format `"<source>/<replacement>"` (e.g., `["omg/oh my god"]`) to override how the model pronounces matching tokens.
+ /// Example: [omg/oh my god] + /// +#if NET7_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] +#endif + public AudioSpeechRequestExtraParams( + global::System.Collections.Generic.IList? pronunciationDict) + { + this.PronunciationDict = pronunciationDict; + } + + /// + /// Initializes a new instance of the class. + /// + public AudioSpeechRequestExtraParams() + { + } + + } +} \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.AudioSpeechRequestLanguage.g.cs b/src/libs/Together/Generated/Together.Models.AudioSpeechRequestLanguage.g.cs deleted file mode 100644 index 2c613a8b..00000000 --- a/src/libs/Together/Generated/Together.Models.AudioSpeechRequestLanguage.g.cs +++ /dev/null @@ -1,130 +0,0 @@ - -#nullable enable - -namespace Together -{ - /// - /// Language of input text.
- /// Default Value: en - ///
- public enum AudioSpeechRequestLanguage - { - /// - /// - /// - De, - /// - /// - /// - En, - /// - /// - /// - Es, - /// - /// - /// - Fr, - /// - /// - /// - Hi, - /// - /// - /// - It, - /// - /// - /// - Ja, - /// - /// - /// - Ko, - /// - /// - /// - Nl, - /// - /// - /// - Pl, - /// - /// - /// - Pt, - /// - /// - /// - Ru, - /// - /// - /// - Sv, - /// - /// - /// - Tr, - /// - /// - /// - Zh, - } - - /// - /// Enum extensions to do fast conversions without the reflection. - /// - public static class AudioSpeechRequestLanguageExtensions - { - /// - /// Converts an enum to a string. - /// - public static string ToValueString(this AudioSpeechRequestLanguage value) - { - return value switch - { - AudioSpeechRequestLanguage.De => "de", - AudioSpeechRequestLanguage.En => "en", - AudioSpeechRequestLanguage.Es => "es", - AudioSpeechRequestLanguage.Fr => "fr", - AudioSpeechRequestLanguage.Hi => "hi", - AudioSpeechRequestLanguage.It => "it", - AudioSpeechRequestLanguage.Ja => "ja", - AudioSpeechRequestLanguage.Ko => "ko", - AudioSpeechRequestLanguage.Nl => "nl", - AudioSpeechRequestLanguage.Pl => "pl", - AudioSpeechRequestLanguage.Pt => "pt", - AudioSpeechRequestLanguage.Ru => "ru", - AudioSpeechRequestLanguage.Sv => "sv", - AudioSpeechRequestLanguage.Tr => "tr", - AudioSpeechRequestLanguage.Zh => "zh", - _ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null), - }; - } - /// - /// Converts an string to a enum. - /// - public static AudioSpeechRequestLanguage? ToEnum(string value) - { - return value switch - { - "de" => AudioSpeechRequestLanguage.De, - "en" => AudioSpeechRequestLanguage.En, - "es" => AudioSpeechRequestLanguage.Es, - "fr" => AudioSpeechRequestLanguage.Fr, - "hi" => AudioSpeechRequestLanguage.Hi, - "it" => AudioSpeechRequestLanguage.It, - "ja" => AudioSpeechRequestLanguage.Ja, - "ko" => AudioSpeechRequestLanguage.Ko, - "nl" => AudioSpeechRequestLanguage.Nl, - "pl" => AudioSpeechRequestLanguage.Pl, - "pt" => AudioSpeechRequestLanguage.Pt, - "ru" => AudioSpeechRequestLanguage.Ru, - "sv" => AudioSpeechRequestLanguage.Sv, - "tr" => AudioSpeechRequestLanguage.Tr, - "zh" => AudioSpeechRequestLanguage.Zh, - _ => null, - }; - } - } -} \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.AudioSpeechRequestResponseEncoding.g.cs b/src/libs/Together/Generated/Together.Models.AudioSpeechRequestResponseEncoding.g.cs index c996dfcd..96ab3789 100644 --- a/src/libs/Together/Generated/Together.Models.AudioSpeechRequestResponseEncoding.g.cs +++ b/src/libs/Together/Generated/Together.Models.AudioSpeechRequestResponseEncoding.g.cs @@ -4,7 +4,7 @@ namespace Together { /// - /// Audio encoding of response
+ /// Audio encoding of response. Only applicable when response_format is raw or pcm. Cartesia models respect this parameter and support all values. Orpheus, Kokoro, and Minimax models always return pcm_s16le regardless of this setting.
/// Default Value: pcm_f32le ///
public enum AudioSpeechRequestResponseEncoding diff --git a/src/libs/Together/Generated/Together.Models.AudioSpeechStreamChunk.g.cs b/src/libs/Together/Generated/Together.Models.AudioSpeechStreamChunk.g.cs index 650b0e4b..f8ab507d 100644 --- a/src/libs/Together/Generated/Together.Models.AudioSpeechStreamChunk.g.cs +++ b/src/libs/Together/Generated/Together.Models.AudioSpeechStreamChunk.g.cs @@ -67,5 +67,6 @@ public AudioSpeechStreamChunk( public AudioSpeechStreamChunk() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.AudioSpeechStreamChunkObject.g.cs b/src/libs/Together/Generated/Together.Models.AudioSpeechStreamChunkObject.g.cs index be2d0103..01194458 100644 --- a/src/libs/Together/Generated/Together.Models.AudioSpeechStreamChunkObject.g.cs +++ b/src/libs/Together/Generated/Together.Models.AudioSpeechStreamChunkObject.g.cs @@ -14,5 +14,6 @@ public sealed partial class AudioSpeechStreamChunkObject ///
[global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.AudioSpeechStreamEvent.g.cs b/src/libs/Together/Generated/Together.Models.AudioSpeechStreamEvent.g.cs index 4c73d9f3..9d99282d 100644 --- a/src/libs/Together/Generated/Together.Models.AudioSpeechStreamEvent.g.cs +++ b/src/libs/Together/Generated/Together.Models.AudioSpeechStreamEvent.g.cs @@ -40,5 +40,6 @@ public AudioSpeechStreamEvent( public AudioSpeechStreamEvent() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.AudioSpeechStreamResponse.g.cs b/src/libs/Together/Generated/Together.Models.AudioSpeechStreamResponse.g.cs index 0a3f1f71..08dca0c6 100644 --- a/src/libs/Together/Generated/Together.Models.AudioSpeechStreamResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.AudioSpeechStreamResponse.g.cs @@ -26,6 +26,26 @@ namespace Together #endif public bool IsEvent => Event != null; + /// + /// + /// + public bool TryPickEvent( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Together.AudioSpeechStreamEvent? value) + { + value = Event; + return IsEvent; + } + + /// + /// + /// + public global::Together.AudioSpeechStreamEvent PickEvent() => IsEvent + ? Event! + : throw new global::System.InvalidOperationException($"Expected union variant 'Event' but the value was {ToString()}."); + /// /// /// @@ -42,6 +62,26 @@ namespace Together [global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(Sentinel))] #endif public bool IsSentinel => Sentinel != null; + + /// + /// + /// + public bool TryPickSentinel( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Together.StreamSentinel? value) + { + value = Sentinel; + return IsSentinel; + } + + /// + /// + /// + public global::Together.StreamSentinel PickSentinel() => IsSentinel + ? Sentinel! + : throw new global::System.InvalidOperationException($"Expected union variant 'Sentinel' but the value was {ToString()}."); /// /// /// @@ -60,6 +100,11 @@ public AudioSpeechStreamResponse(global::Together.AudioSpeechStreamEvent? value) Event = value; } + /// + /// + /// + public static AudioSpeechStreamResponse FromEvent(global::Together.AudioSpeechStreamEvent? value) => new AudioSpeechStreamResponse(value); + /// /// /// @@ -78,6 +123,11 @@ public AudioSpeechStreamResponse(global::Together.StreamSentinel? value) Sentinel = value; } + /// + /// + /// + public static AudioSpeechStreamResponse FromSentinel(global::Together.StreamSentinel? value) => new AudioSpeechStreamResponse(value); + /// /// /// @@ -118,8 +168,8 @@ public bool Validate() /// ///
public TResult? Match( - global::System.Func? @event = null, - global::System.Func? sentinel = null, + global::System.Func? @event = null, + global::System.Func? sentinel = null, bool validate = true) { if (validate) @@ -143,8 +193,32 @@ public bool Validate() /// /// public void Match( - global::System.Action? @event = null, - global::System.Action? sentinel = null, + global::System.Action? @event = null, + + global::System.Action? sentinel = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (IsEvent) + { + @event?.Invoke(Event!); + } + else if (IsSentinel) + { + sentinel?.Invoke(Sentinel!); + } + } + + /// + /// + /// + public void Switch( + global::System.Action? @event = null, + global::System.Action? sentinel = null, bool validate = true) { if (validate) diff --git a/src/libs/Together/Generated/Together.Models.AudioTranscriptionJsonResponse.g.cs b/src/libs/Together/Generated/Together.Models.AudioTranscriptionJsonResponse.g.cs index ece6a2d5..2262e6f9 100644 --- a/src/libs/Together/Generated/Together.Models.AudioTranscriptionJsonResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.AudioTranscriptionJsonResponse.g.cs @@ -45,5 +45,6 @@ public AudioTranscriptionJsonResponse( public AudioTranscriptionJsonResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.AudioTranscriptionRequest.g.cs b/src/libs/Together/Generated/Together.Models.AudioTranscriptionRequest.g.cs index a2a9839f..1f19fbea 100644 --- a/src/libs/Together/Generated/Together.Models.AudioTranscriptionRequest.g.cs +++ b/src/libs/Together/Generated/Together.Models.AudioTranscriptionRequest.g.cs @@ -9,7 +9,7 @@ namespace Together public sealed partial class AudioTranscriptionRequest { /// - /// Audio file upload or public HTTP/HTTPS URL. Supported formats .wav, .mp3, .m4a, .webm, .flac. + /// Audio file upload or public HTTP/HTTPS URL. Supported formats .wav, .mp3, .m4a, .webm, .flac, .ogg, .opus, .aac. /// [global::System.Text.Json.Serialization.JsonPropertyName("file")] [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Together.JsonConverters.OneOfJsonConverter))] @@ -34,7 +34,7 @@ public sealed partial class AudioTranscriptionRequest public string? Language { get; set; } /// - /// Optional text to bias decoding. + /// Optional text to bias decoding. Supported only on Whisper-family models (e.g. `openai/whisper-large-v3`). Other STT models (e.g. `nvidia/parakeet-tdt-0.6b-v3`) accept the field for API compatibility but ignore it. /// [global::System.Text.Json.Serialization.JsonPropertyName("prompt")] public string? Prompt { get; set; } @@ -105,7 +105,7 @@ public sealed partial class AudioTranscriptionRequest /// Initializes a new instance of the class. /// /// - /// Audio file upload or public HTTP/HTTPS URL. Supported formats .wav, .mp3, .m4a, .webm, .flac. + /// Audio file upload or public HTTP/HTTPS URL. Supported formats .wav, .mp3, .m4a, .webm, .flac, .ogg, .opus, .aac. /// /// /// Model to use for transcription
@@ -117,7 +117,7 @@ public sealed partial class AudioTranscriptionRequest /// Example: en /// /// - /// Optional text to bias decoding. + /// Optional text to bias decoding. Supported only on Whisper-family models (e.g. `openai/whisper-large-v3`). Other STT models (e.g. `nvidia/parakeet-tdt-0.6b-v3`) accept the field for API compatibility but ignore it. /// /// /// The format of the response
@@ -187,5 +187,6 @@ public AudioTranscriptionRequest( public AudioTranscriptionRequest() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.AudioTranscriptionResponse.g.cs b/src/libs/Together/Generated/Together.Models.AudioTranscriptionResponse.g.cs index 9d8700dc..9556d4e7 100644 --- a/src/libs/Together/Generated/Together.Models.AudioTranscriptionResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.AudioTranscriptionResponse.g.cs @@ -26,6 +26,26 @@ namespace Together #endif public bool IsJson => Json != null; + /// + /// + /// + public bool TryPickJson( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Together.AudioTranscriptionJsonResponse? value) + { + value = Json; + return IsJson; + } + + /// + /// + /// + public global::Together.AudioTranscriptionJsonResponse PickJson() => IsJson + ? Json! + : throw new global::System.InvalidOperationException($"Expected union variant 'Json' but the value was {ToString()}."); + /// /// /// @@ -42,6 +62,26 @@ namespace Together [global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(VerboseJson))] #endif public bool IsVerboseJson => VerboseJson != null; + + /// + /// + /// + public bool TryPickVerboseJson( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Together.AudioTranscriptionVerboseJsonResponse? value) + { + value = VerboseJson; + return IsVerboseJson; + } + + /// + /// + /// + public global::Together.AudioTranscriptionVerboseJsonResponse PickVerboseJson() => IsVerboseJson + ? VerboseJson! + : throw new global::System.InvalidOperationException($"Expected union variant 'VerboseJson' but the value was {ToString()}."); /// /// /// @@ -60,6 +100,11 @@ public AudioTranscriptionResponse(global::Together.AudioTranscriptionJsonRespons Json = value; } + /// + /// + /// + public static AudioTranscriptionResponse FromJson(global::Together.AudioTranscriptionJsonResponse? value) => new AudioTranscriptionResponse(value); + /// /// /// @@ -78,6 +123,11 @@ public AudioTranscriptionResponse(global::Together.AudioTranscriptionVerboseJson VerboseJson = value; } + /// + /// + /// + public static AudioTranscriptionResponse FromVerboseJson(global::Together.AudioTranscriptionVerboseJsonResponse? value) => new AudioTranscriptionResponse(value); + /// /// /// @@ -118,8 +168,8 @@ public bool Validate() /// /// public TResult? Match( - global::System.Func? json = null, - global::System.Func? verboseJson = null, + global::System.Func? json = null, + global::System.Func? verboseJson = null, bool validate = true) { if (validate) @@ -143,8 +193,32 @@ public bool Validate() /// /// public void Match( - global::System.Action? json = null, - global::System.Action? verboseJson = null, + global::System.Action? json = null, + + global::System.Action? verboseJson = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (IsJson) + { + json?.Invoke(Json!); + } + else if (IsVerboseJson) + { + verboseJson?.Invoke(VerboseJson!); + } + } + + /// + /// + /// + public void Switch( + global::System.Action? json = null, + global::System.Action? verboseJson = null, bool validate = true) { if (validate) diff --git a/src/libs/Together/Generated/Together.Models.AudioTranscriptionSegment.g.cs b/src/libs/Together/Generated/Together.Models.AudioTranscriptionSegment.g.cs index 960e5494..ded786a2 100644 --- a/src/libs/Together/Generated/Together.Models.AudioTranscriptionSegment.g.cs +++ b/src/libs/Together/Generated/Together.Models.AudioTranscriptionSegment.g.cs @@ -90,5 +90,6 @@ public AudioTranscriptionSegment( public AudioTranscriptionSegment() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.AudioTranscriptionSpeakerSegment.g.cs b/src/libs/Together/Generated/Together.Models.AudioTranscriptionSpeakerSegment.g.cs index 571185a2..e1af6e2f 100644 --- a/src/libs/Together/Generated/Together.Models.AudioTranscriptionSpeakerSegment.g.cs +++ b/src/libs/Together/Generated/Together.Models.AudioTranscriptionSpeakerSegment.g.cs @@ -117,5 +117,6 @@ public AudioTranscriptionSpeakerSegment( public AudioTranscriptionSpeakerSegment() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.AudioTranscriptionVerboseJsonResponse.g.cs b/src/libs/Together/Generated/Together.Models.AudioTranscriptionVerboseJsonResponse.g.cs index 1fd64daa..a86439a2 100644 --- a/src/libs/Together/Generated/Together.Models.AudioTranscriptionVerboseJsonResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.AudioTranscriptionVerboseJsonResponse.g.cs @@ -8,16 +8,6 @@ namespace Together /// public sealed partial class AudioTranscriptionVerboseJsonResponse { - /// - /// The task performed
- /// Example: transcribe - ///
- /// transcribe - [global::System.Text.Json.Serialization.JsonPropertyName("task")] - [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Together.JsonConverters.AudioTranscriptionVerboseJsonResponseTaskJsonConverter))] - [global::System.Text.Json.Serialization.JsonRequired] - public required global::Together.AudioTranscriptionVerboseJsonResponseTask Task { get; set; } - /// /// The language of the audio
/// Example: english @@ -73,10 +63,6 @@ public sealed partial class AudioTranscriptionVerboseJsonResponse /// /// Initializes a new instance of the class. /// - /// - /// The task performed
- /// Example: transcribe - /// /// /// The language of the audio
/// Example: english @@ -102,7 +88,6 @@ public sealed partial class AudioTranscriptionVerboseJsonResponse [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] #endif public AudioTranscriptionVerboseJsonResponse( - global::Together.AudioTranscriptionVerboseJsonResponseTask task, string language, float duration, string text, @@ -110,7 +95,6 @@ public AudioTranscriptionVerboseJsonResponse( global::System.Collections.Generic.IList? words, global::System.Collections.Generic.IList? speakerSegments) { - this.Task = task; this.Language = language ?? throw new global::System.ArgumentNullException(nameof(language)); this.Duration = duration; this.Text = text ?? throw new global::System.ArgumentNullException(nameof(text)); @@ -125,5 +109,6 @@ public AudioTranscriptionVerboseJsonResponse( public AudioTranscriptionVerboseJsonResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.AudioTranscriptionVerboseJsonResponseTask.g.cs b/src/libs/Together/Generated/Together.Models.AudioTranscriptionVerboseJsonResponseTask.g.cs deleted file mode 100644 index d952c17c..00000000 --- a/src/libs/Together/Generated/Together.Models.AudioTranscriptionVerboseJsonResponseTask.g.cs +++ /dev/null @@ -1,52 +0,0 @@ - -#nullable enable - -namespace Together -{ - /// - /// The task performed
- /// Example: transcribe - ///
- public enum AudioTranscriptionVerboseJsonResponseTask - { - /// - /// - /// - Transcribe, - /// - /// - /// - Translate, - } - - /// - /// Enum extensions to do fast conversions without the reflection. - /// - public static class AudioTranscriptionVerboseJsonResponseTaskExtensions - { - /// - /// Converts an enum to a string. - /// - public static string ToValueString(this AudioTranscriptionVerboseJsonResponseTask value) - { - return value switch - { - AudioTranscriptionVerboseJsonResponseTask.Transcribe => "transcribe", - AudioTranscriptionVerboseJsonResponseTask.Translate => "translate", - _ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null), - }; - } - /// - /// Converts an string to a enum. - /// - public static AudioTranscriptionVerboseJsonResponseTask? ToEnum(string value) - { - return value switch - { - "transcribe" => AudioTranscriptionVerboseJsonResponseTask.Transcribe, - "translate" => AudioTranscriptionVerboseJsonResponseTask.Translate, - _ => null, - }; - } - } -} \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.AudioTranscriptionWord.g.cs b/src/libs/Together/Generated/Together.Models.AudioTranscriptionWord.g.cs index 58da7930..bab04301 100644 --- a/src/libs/Together/Generated/Together.Models.AudioTranscriptionWord.g.cs +++ b/src/libs/Together/Generated/Together.Models.AudioTranscriptionWord.g.cs @@ -89,5 +89,6 @@ public AudioTranscriptionWord( public AudioTranscriptionWord() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.AudioTranslationJsonResponse.g.cs b/src/libs/Together/Generated/Together.Models.AudioTranslationJsonResponse.g.cs index 3795ebfe..2d14a26e 100644 --- a/src/libs/Together/Generated/Together.Models.AudioTranslationJsonResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.AudioTranslationJsonResponse.g.cs @@ -45,5 +45,6 @@ public AudioTranslationJsonResponse( public AudioTranslationJsonResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.AudioTranslationRequest.g.cs b/src/libs/Together/Generated/Together.Models.AudioTranslationRequest.g.cs index f01bb393..45dba763 100644 --- a/src/libs/Together/Generated/Together.Models.AudioTranslationRequest.g.cs +++ b/src/libs/Together/Generated/Together.Models.AudioTranslationRequest.g.cs @@ -9,7 +9,7 @@ namespace Together public sealed partial class AudioTranslationRequest { /// - /// Audio file upload or public HTTP/HTTPS URL. Supported formats .wav, .mp3, .m4a, .webm, .flac. + /// Audio file upload or public HTTP/HTTPS URL. Supported formats .wav, .mp3, .m4a, .webm, .flac, .ogg, .opus, .aac. /// [global::System.Text.Json.Serialization.JsonPropertyName("file")] [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Together.JsonConverters.OneOfJsonConverter))] @@ -34,7 +34,7 @@ public sealed partial class AudioTranslationRequest public string? Language { get; set; } /// - /// Optional text to bias decoding. + /// Optional text to bias decoding. Supported only on Whisper-family models (e.g. `openai/whisper-large-v3`). Other STT models (e.g. `nvidia/parakeet-tdt-0.6b-v3`) accept the field for API compatibility but ignore it. /// [global::System.Text.Json.Serialization.JsonPropertyName("prompt")] public string? Prompt { get; set; } @@ -74,7 +74,7 @@ public sealed partial class AudioTranslationRequest /// Initializes a new instance of the class. ///
/// - /// Audio file upload or public HTTP/HTTPS URL. Supported formats .wav, .mp3, .m4a, .webm, .flac. + /// Audio file upload or public HTTP/HTTPS URL. Supported formats .wav, .mp3, .m4a, .webm, .flac, .ogg, .opus, .aac. /// /// /// Model to use for translation
@@ -86,7 +86,7 @@ public sealed partial class AudioTranslationRequest /// Example: en /// /// - /// Optional text to bias decoding. + /// Optional text to bias decoding. Supported only on Whisper-family models (e.g. `openai/whisper-large-v3`). Other STT models (e.g. `nvidia/parakeet-tdt-0.6b-v3`) accept the field for API compatibility but ignore it. /// /// /// The format of the response
@@ -128,5 +128,6 @@ public AudioTranslationRequest( public AudioTranslationRequest() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.AudioTranslationResponse.g.cs b/src/libs/Together/Generated/Together.Models.AudioTranslationResponse.g.cs index 3097ad63..35904af6 100644 --- a/src/libs/Together/Generated/Together.Models.AudioTranslationResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.AudioTranslationResponse.g.cs @@ -26,6 +26,26 @@ namespace Together #endif public bool IsJson => Json != null; + /// + /// + /// + public bool TryPickJson( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Together.AudioTranslationJsonResponse? value) + { + value = Json; + return IsJson; + } + + /// + /// + /// + public global::Together.AudioTranslationJsonResponse PickJson() => IsJson + ? Json! + : throw new global::System.InvalidOperationException($"Expected union variant 'Json' but the value was {ToString()}."); + /// /// /// @@ -42,6 +62,26 @@ namespace Together [global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(VerboseJson))] #endif public bool IsVerboseJson => VerboseJson != null; + + /// + /// + /// + public bool TryPickVerboseJson( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Together.AudioTranslationVerboseJsonResponse? value) + { + value = VerboseJson; + return IsVerboseJson; + } + + /// + /// + /// + public global::Together.AudioTranslationVerboseJsonResponse PickVerboseJson() => IsVerboseJson + ? VerboseJson! + : throw new global::System.InvalidOperationException($"Expected union variant 'VerboseJson' but the value was {ToString()}."); /// /// /// @@ -60,6 +100,11 @@ public AudioTranslationResponse(global::Together.AudioTranslationJsonResponse? v Json = value; } + /// + /// + /// + public static AudioTranslationResponse FromJson(global::Together.AudioTranslationJsonResponse? value) => new AudioTranslationResponse(value); + /// /// /// @@ -78,6 +123,11 @@ public AudioTranslationResponse(global::Together.AudioTranslationVerboseJsonResp VerboseJson = value; } + /// + /// + /// + public static AudioTranslationResponse FromVerboseJson(global::Together.AudioTranslationVerboseJsonResponse? value) => new AudioTranslationResponse(value); + /// /// /// @@ -118,8 +168,8 @@ public bool Validate() /// /// public TResult? Match( - global::System.Func? json = null, - global::System.Func? verboseJson = null, + global::System.Func? json = null, + global::System.Func? verboseJson = null, bool validate = true) { if (validate) @@ -143,8 +193,32 @@ public bool Validate() /// /// public void Match( - global::System.Action? json = null, - global::System.Action? verboseJson = null, + global::System.Action? json = null, + + global::System.Action? verboseJson = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (IsJson) + { + json?.Invoke(Json!); + } + else if (IsVerboseJson) + { + verboseJson?.Invoke(VerboseJson!); + } + } + + /// + /// + /// + public void Switch( + global::System.Action? json = null, + global::System.Action? verboseJson = null, bool validate = true) { if (validate) diff --git a/src/libs/Together/Generated/Together.Models.AudioTranslationVerboseJsonResponse.g.cs b/src/libs/Together/Generated/Together.Models.AudioTranslationVerboseJsonResponse.g.cs index 8649c060..7bcf2d83 100644 --- a/src/libs/Together/Generated/Together.Models.AudioTranslationVerboseJsonResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.AudioTranslationVerboseJsonResponse.g.cs @@ -8,16 +8,6 @@ namespace Together /// public sealed partial class AudioTranslationVerboseJsonResponse { - /// - /// The task performed
- /// Example: translate - ///
- /// translate - [global::System.Text.Json.Serialization.JsonPropertyName("task")] - [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Together.JsonConverters.AudioTranslationVerboseJsonResponseTaskJsonConverter))] - [global::System.Text.Json.Serialization.JsonRequired] - public required global::Together.AudioTranslationVerboseJsonResponseTask Task { get; set; } - /// /// The target language of the translation
/// Example: english @@ -67,10 +57,6 @@ public sealed partial class AudioTranslationVerboseJsonResponse /// /// Initializes a new instance of the class. /// - /// - /// The task performed
- /// Example: translate - /// /// /// The target language of the translation
/// Example: english @@ -93,14 +79,12 @@ public sealed partial class AudioTranslationVerboseJsonResponse [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] #endif public AudioTranslationVerboseJsonResponse( - global::Together.AudioTranslationVerboseJsonResponseTask task, string language, float duration, string text, global::System.Collections.Generic.IList segments, global::System.Collections.Generic.IList? words) { - this.Task = task; this.Language = language ?? throw new global::System.ArgumentNullException(nameof(language)); this.Duration = duration; this.Text = text ?? throw new global::System.ArgumentNullException(nameof(text)); @@ -114,5 +98,6 @@ public AudioTranslationVerboseJsonResponse( public AudioTranslationVerboseJsonResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.Autoscaling.g.cs b/src/libs/Together/Generated/Together.Models.Autoscaling.g.cs index e62b7cb8..3966eb7b 100644 --- a/src/libs/Together/Generated/Together.Models.Autoscaling.g.cs +++ b/src/libs/Together/Generated/Together.Models.Autoscaling.g.cs @@ -54,5 +54,6 @@ public Autoscaling( public Autoscaling() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.BatchErrorResponse.g.cs b/src/libs/Together/Generated/Together.Models.BatchErrorResponse.g.cs index 164c5965..33051174 100644 --- a/src/libs/Together/Generated/Together.Models.BatchErrorResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.BatchErrorResponse.g.cs @@ -39,5 +39,6 @@ public BatchErrorResponse( public BatchErrorResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.BatchJob.g.cs b/src/libs/Together/Generated/Together.Models.BatchJob.g.cs index 63ee81a6..d4385c5f 100644 --- a/src/libs/Together/Generated/Together.Models.BatchJob.g.cs +++ b/src/libs/Together/Generated/Together.Models.BatchJob.g.cs @@ -204,5 +204,6 @@ public BatchJob( public BatchJob() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.BatchJobWithWarning.g.cs b/src/libs/Together/Generated/Together.Models.BatchJobWithWarning.g.cs index f63f3b66..eab25521 100644 --- a/src/libs/Together/Generated/Together.Models.BatchJobWithWarning.g.cs +++ b/src/libs/Together/Generated/Together.Models.BatchJobWithWarning.g.cs @@ -48,5 +48,6 @@ public BatchJobWithWarning( public BatchJobWithWarning() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionAssistantMessageParam.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionAssistantMessageParam.g.cs index c780f2b0..a173af98 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionAssistantMessageParam.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionAssistantMessageParam.g.cs @@ -76,5 +76,6 @@ public ChatCompletionAssistantMessageParam( public ChatCompletionAssistantMessageParam() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionAssistantMessageParamFunctionCall.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionAssistantMessageParamFunctionCall.g.cs index d273ab2e..1656a226 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionAssistantMessageParamFunctionCall.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionAssistantMessageParamFunctionCall.g.cs @@ -53,5 +53,6 @@ public ChatCompletionAssistantMessageParamFunctionCall( public ChatCompletionAssistantMessageParamFunctionCall() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionChoice.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionChoice.g.cs index fa311bd1..8a9f800b 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionChoice.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionChoice.g.cs @@ -70,5 +70,6 @@ public ChatCompletionChoice( public ChatCompletionChoice() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionChoiceDelta.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionChoiceDelta.g.cs index 61db1d0c..861691ab 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionChoiceDelta.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionChoiceDelta.g.cs @@ -86,5 +86,6 @@ public ChatCompletionChoiceDelta( public ChatCompletionChoiceDelta() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionChoiceDeltaFunctionCall.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionChoiceDeltaFunctionCall.g.cs index c8ca2728..35436152 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionChoiceDeltaFunctionCall.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionChoiceDeltaFunctionCall.g.cs @@ -53,5 +53,6 @@ public ChatCompletionChoiceDeltaFunctionCall( public ChatCompletionChoiceDeltaFunctionCall() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionChoicesDataItem.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionChoicesDataItem.g.cs index 40626297..5b98f223 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionChoicesDataItem.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionChoicesDataItem.g.cs @@ -97,5 +97,6 @@ public ChatCompletionChoicesDataItem( public ChatCompletionChoicesDataItem() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionChunk.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionChunk.g.cs index f342a4f4..9a4a1247 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionChunk.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionChunk.g.cs @@ -113,5 +113,6 @@ public ChatCompletionChunk( public ChatCompletionChunk() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionChunkChoice.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionChunkChoice.g.cs index 1ff5b437..f7521de4 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionChunkChoice.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionChunkChoice.g.cs @@ -90,5 +90,6 @@ public ChatCompletionChunkChoice( public ChatCompletionChunkChoice() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionChunkChoiceDelta.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionChunkChoiceDelta.g.cs index d152a855..fde3250c 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionChunkChoiceDelta.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionChunkChoiceDelta.g.cs @@ -86,5 +86,6 @@ public ChatCompletionChunkChoiceDelta( public ChatCompletionChunkChoiceDelta() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionChunkChoiceDeltaFunctionCall.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionChunkChoiceDeltaFunctionCall.g.cs index d8377be8..7fcf0863 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionChunkChoiceDeltaFunctionCall.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionChunkChoiceDeltaFunctionCall.g.cs @@ -53,5 +53,6 @@ public ChatCompletionChunkChoiceDeltaFunctionCall( public ChatCompletionChunkChoiceDeltaFunctionCall() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionChunkObject.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionChunkObject.g.cs index 67b6f1c1..36dc8cf3 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionChunkObject.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionChunkObject.g.cs @@ -14,5 +14,6 @@ public sealed partial class ChatCompletionChunkObject ///
[global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionEvent.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionEvent.g.cs index 2fa6e6a3..7db5bb83 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionEvent.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionEvent.g.cs @@ -40,5 +40,6 @@ public ChatCompletionEvent( public ChatCompletionEvent() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionFunctionMessageParam.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionFunctionMessageParam.g.cs index 92c5e11a..a1d622cf 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionFunctionMessageParam.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionFunctionMessageParam.g.cs @@ -64,5 +64,6 @@ public ChatCompletionFunctionMessageParam( public ChatCompletionFunctionMessageParam() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionMessage.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionMessage.g.cs index 55a30f69..520d66c6 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionMessage.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionMessage.g.cs @@ -76,5 +76,6 @@ public ChatCompletionMessage( public ChatCompletionMessage() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionMessageFunctionCall.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionMessageFunctionCall.g.cs index fc276408..9d94523a 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionMessageFunctionCall.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionMessageFunctionCall.g.cs @@ -53,5 +53,6 @@ public ChatCompletionMessageFunctionCall( public ChatCompletionMessageFunctionCall() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionMessageParam.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionMessageParam.g.cs index 22cf9b9e..877851ad 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionMessageParam.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionMessageParam.g.cs @@ -26,6 +26,26 @@ namespace Together #endif public bool IsSystem => System != null; + /// + /// + /// + public bool TryPickSystem( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Together.ChatCompletionSystemMessageParam? value) + { + value = System; + return IsSystem; + } + + /// + /// + /// + public global::Together.ChatCompletionSystemMessageParam PickSystem() => IsSystem + ? System! + : throw new global::System.InvalidOperationException($"Expected union variant 'System' but the value was {ToString()}."); + /// /// /// @@ -43,6 +63,26 @@ namespace Together #endif public bool IsUser => User != null; + /// + /// + /// + public bool TryPickUser( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Together.ChatCompletionUserMessageParam? value) + { + value = User; + return IsUser; + } + + /// + /// + /// + public global::Together.ChatCompletionUserMessageParam PickUser() => IsUser + ? User! + : throw new global::System.InvalidOperationException($"Expected union variant 'User' but the value was {ToString()}."); + /// /// /// @@ -60,6 +100,26 @@ namespace Together #endif public bool IsAssistant => Assistant != null; + /// + /// + /// + public bool TryPickAssistant( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Together.ChatCompletionAssistantMessageParam? value) + { + value = Assistant; + return IsAssistant; + } + + /// + /// + /// + public global::Together.ChatCompletionAssistantMessageParam PickAssistant() => IsAssistant + ? Assistant! + : throw new global::System.InvalidOperationException($"Expected union variant 'Assistant' but the value was {ToString()}."); + /// /// /// @@ -77,6 +137,26 @@ namespace Together #endif public bool IsTool => Tool != null; + /// + /// + /// + public bool TryPickTool( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Together.ChatCompletionToolMessageParam? value) + { + value = Tool; + return IsTool; + } + + /// + /// + /// + public global::Together.ChatCompletionToolMessageParam PickTool() => IsTool + ? Tool! + : throw new global::System.InvalidOperationException($"Expected union variant 'Tool' but the value was {ToString()}."); + /// /// /// @@ -93,6 +173,26 @@ namespace Together [global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(Function))] #endif public bool IsFunction => Function != null; + + /// + /// + /// + public bool TryPickFunction( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Together.ChatCompletionFunctionMessageParam? value) + { + value = Function; + return IsFunction; + } + + /// + /// + /// + public global::Together.ChatCompletionFunctionMessageParam PickFunction() => IsFunction + ? Function! + : throw new global::System.InvalidOperationException($"Expected union variant 'Function' but the value was {ToString()}."); /// /// /// @@ -111,6 +211,11 @@ public ChatCompletionMessageParam(global::Together.ChatCompletionSystemMessagePa System = value; } + /// + /// + /// + public static ChatCompletionMessageParam FromSystem(global::Together.ChatCompletionSystemMessageParam? value) => new ChatCompletionMessageParam(value); + /// /// /// @@ -129,6 +234,11 @@ public ChatCompletionMessageParam(global::Together.ChatCompletionUserMessagePara User = value; } + /// + /// + /// + public static ChatCompletionMessageParam FromUser(global::Together.ChatCompletionUserMessageParam? value) => new ChatCompletionMessageParam(value); + /// /// /// @@ -147,6 +257,11 @@ public ChatCompletionMessageParam(global::Together.ChatCompletionAssistantMessag Assistant = value; } + /// + /// + /// + public static ChatCompletionMessageParam FromAssistant(global::Together.ChatCompletionAssistantMessageParam? value) => new ChatCompletionMessageParam(value); + /// /// /// @@ -165,6 +280,11 @@ public ChatCompletionMessageParam(global::Together.ChatCompletionToolMessagePara Tool = value; } + /// + /// + /// + public static ChatCompletionMessageParam FromTool(global::Together.ChatCompletionToolMessageParam? value) => new ChatCompletionMessageParam(value); + /// /// /// @@ -183,6 +303,11 @@ public ChatCompletionMessageParam(global::Together.ChatCompletionFunctionMessage Function = value; } + /// + /// + /// + public static ChatCompletionMessageParam FromFunction(global::Together.ChatCompletionFunctionMessageParam? value) => new ChatCompletionMessageParam(value); + /// /// /// @@ -235,11 +360,11 @@ public bool Validate() /// /// public TResult? Match( - global::System.Func? system = null, - global::System.Func? user = null, - global::System.Func? assistant = null, - global::System.Func? tool = null, - global::System.Func? function = null, + global::System.Func? system = null, + global::System.Func? user = null, + global::System.Func? assistant = null, + global::System.Func? tool = null, + global::System.Func? function = null, bool validate = true) { if (validate) @@ -275,11 +400,53 @@ public bool Validate() /// /// public void Match( - global::System.Action? system = null, - global::System.Action? user = null, - global::System.Action? assistant = null, - global::System.Action? tool = null, - global::System.Action? function = null, + global::System.Action? system = null, + + global::System.Action? user = null, + + global::System.Action? assistant = null, + + global::System.Action? tool = null, + + global::System.Action? function = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (IsSystem) + { + system?.Invoke(System!); + } + else if (IsUser) + { + user?.Invoke(User!); + } + else if (IsAssistant) + { + assistant?.Invoke(Assistant!); + } + else if (IsTool) + { + tool?.Invoke(Tool!); + } + else if (IsFunction) + { + function?.Invoke(Function!); + } + } + + /// + /// + /// + public void Switch( + global::System.Action? system = null, + global::System.Action? user = null, + global::System.Action? assistant = null, + global::System.Action? tool = null, + global::System.Action? function = null, bool validate = true) { if (validate) diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionRequest.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionRequest.g.cs index 6b61eef1..15b6aeca 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionRequest.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionRequest.g.cs @@ -31,7 +31,7 @@ public sealed partial class ChatCompletionRequest public int? MaxTokens { get; set; } /// - /// A list of string sequences that will truncate (stop) inference text output. For example, "</s>" will stop generation as soon as the model generates the given token. + /// A list of string sequences that truncate (stop) inference text output. For example, "</s>" stops generation as soon as the model generates the given token. /// [global::System.Text.Json.Serialization.JsonPropertyName("stop")] public global::System.Collections.Generic.IList? Stop { get; set; } @@ -55,7 +55,7 @@ public sealed partial class ChatCompletionRequest public int? TopK { get; set; } /// - /// Defined the behavior of the API when max_tokens exceed the maximum context length of the model. When set to 'error', API will return 400 with appropriate error message. When set to 'truncate', override the max_tokens with maximum context length of the model.
+ /// Defines the behavior of the API when max_tokens exceed the maximum context length of the model. When set to 'error', the API returns 400 with an appropriate error message. When set to 'truncate', overrides max_tokens with the maximum context length of the model.
/// Default Value: error ///
[global::System.Text.Json.Serialization.JsonPropertyName("context_length_exceeded_behavior")] @@ -75,13 +75,13 @@ public sealed partial class ChatCompletionRequest public bool? Stream { get; set; } /// - /// An integer between 0 and 20 of the top k tokens to return log probabilities for at each generation step, instead of just the sampled token. Log probabilities help assess model confidence in token predictions. + /// An integer between 0 and 20 of the top k tokens to return log probabilities for at each generation step, instead of only the sampled token. Log probabilities help assess model confidence in token predictions. /// [global::System.Text.Json.Serialization.JsonPropertyName("logprobs")] public int? Logprobs { get; set; } /// - /// If true, the response will contain the prompt. Can be used with `logprobs` to return prompt logprobs. + /// If true, the response contains the prompt. Can be used with `logprobs` to return prompt logprobs. /// [global::System.Text.Json.Serialization.JsonPropertyName("echo")] public bool? Echo { get; set; } @@ -214,7 +214,7 @@ public sealed partial class ChatCompletionRequest /// The maximum number of tokens to generate. /// /// - /// A list of string sequences that will truncate (stop) inference text output. For example, "</s>" will stop generation as soon as the model generates the given token. + /// A list of string sequences that truncate (stop) inference text output. For example, "</s>" stops generation as soon as the model generates the given token. /// /// /// A decimal number from 0-1 that determines the degree of randomness in the response. A temperature less than 1 favors more correctness and is appropriate for question answering or summarization. A value closer to 1 introduces more randomness in the output. @@ -226,7 +226,7 @@ public sealed partial class ChatCompletionRequest /// An integer that's used to limit the number of choices for the next predicted word or token. It specifies the maximum number of tokens to consider at each step, based on their probability of occurrence. This technique helps to speed up the generation process and can improve the quality of the generated text by focusing on the most likely options. /// /// - /// Defined the behavior of the API when max_tokens exceed the maximum context length of the model. When set to 'error', API will return 400 with appropriate error message. When set to 'truncate', override the max_tokens with maximum context length of the model.
+ /// Defines the behavior of the API when max_tokens exceed the maximum context length of the model. When set to 'error', the API returns 400 with an appropriate error message. When set to 'truncate', overrides max_tokens with the maximum context length of the model.
/// Default Value: error /// /// @@ -236,10 +236,10 @@ public sealed partial class ChatCompletionRequest /// If true, stream tokens as Server-Sent Events as the model generates them instead of waiting for the full model response. The stream terminates with `data: [DONE]`. If false, return a single JSON object containing the results. /// /// - /// An integer between 0 and 20 of the top k tokens to return log probabilities for at each generation step, instead of just the sampled token. Log probabilities help assess model confidence in token predictions. + /// An integer between 0 and 20 of the top k tokens to return log probabilities for at each generation step, instead of only the sampled token. Log probabilities help assess model confidence in token predictions. /// /// - /// If true, the response will contain the prompt. Can be used with `logprobs` to return prompt logprobs. + /// If true, the response contains the prompt. Can be used with `logprobs` to return prompt logprobs. /// /// /// The number of completions to generate for each prompt. @@ -360,5 +360,6 @@ public ChatCompletionRequest( public ChatCompletionRequest() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionRequestChatTemplateKwargs.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionRequestChatTemplateKwargs.g.cs index 1edb1226..53cbae70 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionRequestChatTemplateKwargs.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionRequestChatTemplateKwargs.g.cs @@ -14,5 +14,6 @@ public sealed partial class ChatCompletionRequestChatTemplateKwargs /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionRequestCompliance.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionRequestCompliance.g.cs index 9d6a6dfa..423138eb 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionRequestCompliance.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionRequestCompliance.g.cs @@ -14,5 +14,6 @@ public sealed partial class ChatCompletionRequestCompliance /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionRequestContextLengthExceededBehavior.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionRequestContextLengthExceededBehavior.g.cs index cc29205f..e859a941 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionRequestContextLengthExceededBehavior.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionRequestContextLengthExceededBehavior.g.cs @@ -4,7 +4,7 @@ namespace Together { /// - /// Defined the behavior of the API when max_tokens exceed the maximum context length of the model. When set to 'error', API will return 400 with appropriate error message. When set to 'truncate', override the max_tokens with maximum context length of the model.
+ /// Defines the behavior of the API when max_tokens exceed the maximum context length of the model. When set to 'error', the API returns 400 with an appropriate error message. When set to 'truncate', overrides max_tokens with the maximum context length of the model.
/// Default Value: error ///
public enum ChatCompletionRequestContextLengthExceededBehavior diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionRequestFunctionCallEnum2.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionRequestFunctionCallEnum2.g.cs index 379704fb..8c49f9b1 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionRequestFunctionCallEnum2.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionRequestFunctionCallEnum2.g.cs @@ -40,5 +40,6 @@ public ChatCompletionRequestFunctionCallEnum2( public ChatCompletionRequestFunctionCallEnum2() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionRequestLogitBias.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionRequestLogitBias.g.cs index f058e720..51ddaa8f 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionRequestLogitBias.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionRequestLogitBias.g.cs @@ -15,5 +15,6 @@ public sealed partial class ChatCompletionRequestLogitBias /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionRequestReasoning.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionRequestReasoning.g.cs index 4eadf3f3..33c6a69d 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionRequestReasoning.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionRequestReasoning.g.cs @@ -39,5 +39,6 @@ public ChatCompletionRequestReasoning( public ChatCompletionRequestReasoning() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionRequestResponseFormatDiscriminator.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionRequestResponseFormatDiscriminator.g.cs index 5e323be1..f654c4db 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionRequestResponseFormatDiscriminator.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionRequestResponseFormatDiscriminator.g.cs @@ -12,7 +12,8 @@ public sealed partial class ChatCompletionRequestResponseFormatDiscriminator /// /// [global::System.Text.Json.Serialization.JsonPropertyName("type")] - public string? Type { get; set; } + [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Together.JsonConverters.ChatCompletionRequestResponseFormatDiscriminatorTypeJsonConverter))] + public global::Together.ChatCompletionRequestResponseFormatDiscriminatorType? Type { get; set; } /// /// Additional properties that are not explicitly defined in the schema @@ -28,7 +29,7 @@ public sealed partial class ChatCompletionRequestResponseFormatDiscriminator [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] #endif public ChatCompletionRequestResponseFormatDiscriminator( - string? type) + global::Together.ChatCompletionRequestResponseFormatDiscriminatorType? type) { this.Type = type; } @@ -39,5 +40,6 @@ public ChatCompletionRequestResponseFormatDiscriminator( public ChatCompletionRequestResponseFormatDiscriminator() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionRequestResponseFormatDiscriminatorType.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionRequestResponseFormatDiscriminatorType.g.cs new file mode 100644 index 00000000..66f7055f --- /dev/null +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionRequestResponseFormatDiscriminatorType.g.cs @@ -0,0 +1,57 @@ + +#nullable enable + +namespace Together +{ + /// + /// + /// + public enum ChatCompletionRequestResponseFormatDiscriminatorType + { + /// + /// + /// + JsonObject, + /// + /// + /// + JsonSchema, + /// + /// + /// + Text, + } + + /// + /// Enum extensions to do fast conversions without the reflection. + /// + public static class ChatCompletionRequestResponseFormatDiscriminatorTypeExtensions + { + /// + /// Converts an enum to a string. + /// + public static string ToValueString(this ChatCompletionRequestResponseFormatDiscriminatorType value) + { + return value switch + { + ChatCompletionRequestResponseFormatDiscriminatorType.JsonObject => "json_object", + ChatCompletionRequestResponseFormatDiscriminatorType.JsonSchema => "json_schema", + ChatCompletionRequestResponseFormatDiscriminatorType.Text => "text", + _ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null), + }; + } + /// + /// Converts an string to a enum. + /// + public static ChatCompletionRequestResponseFormatDiscriminatorType? ToEnum(string value) + { + return value switch + { + "json_object" => ChatCompletionRequestResponseFormatDiscriminatorType.JsonObject, + "json_schema" => ChatCompletionRequestResponseFormatDiscriminatorType.JsonSchema, + "text" => ChatCompletionRequestResponseFormatDiscriminatorType.Text, + _ => null, + }; + } + } +} \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionResponse.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionResponse.g.cs index cf5850fd..f2f8270c 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionResponse.g.cs @@ -112,5 +112,6 @@ public ChatCompletionResponse( public ChatCompletionResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionResponseObject.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionResponseObject.g.cs index 930f0cc2..cb5ddd1b 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionResponseObject.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionResponseObject.g.cs @@ -14,5 +14,6 @@ public sealed partial class ChatCompletionResponseObject /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionStream.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionStream.g.cs index 8611011b..3c1b6d5f 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionStream.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionStream.g.cs @@ -26,6 +26,26 @@ namespace Together #endif public bool IsEvent => Event != null; + /// + /// + /// + public bool TryPickEvent( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Together.ChatCompletionEvent? value) + { + value = Event; + return IsEvent; + } + + /// + /// + /// + public global::Together.ChatCompletionEvent PickEvent() => IsEvent + ? Event! + : throw new global::System.InvalidOperationException($"Expected union variant 'Event' but the value was {ToString()}."); + /// /// /// @@ -42,6 +62,26 @@ namespace Together [global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(Sentinel))] #endif public bool IsSentinel => Sentinel != null; + + /// + /// + /// + public bool TryPickSentinel( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Together.StreamSentinel? value) + { + value = Sentinel; + return IsSentinel; + } + + /// + /// + /// + public global::Together.StreamSentinel PickSentinel() => IsSentinel + ? Sentinel! + : throw new global::System.InvalidOperationException($"Expected union variant 'Sentinel' but the value was {ToString()}."); /// /// /// @@ -60,6 +100,11 @@ public ChatCompletionStream(global::Together.ChatCompletionEvent? value) Event = value; } + /// + /// + /// + public static ChatCompletionStream FromEvent(global::Together.ChatCompletionEvent? value) => new ChatCompletionStream(value); + /// /// /// @@ -78,6 +123,11 @@ public ChatCompletionStream(global::Together.StreamSentinel? value) Sentinel = value; } + /// + /// + /// + public static ChatCompletionStream FromSentinel(global::Together.StreamSentinel? value) => new ChatCompletionStream(value); + /// /// /// @@ -118,8 +168,8 @@ public bool Validate() /// /// public TResult? Match( - global::System.Func? @event = null, - global::System.Func? sentinel = null, + global::System.Func? @event = null, + global::System.Func? sentinel = null, bool validate = true) { if (validate) @@ -143,8 +193,32 @@ public bool Validate() /// /// public void Match( - global::System.Action? @event = null, - global::System.Action? sentinel = null, + global::System.Action? @event = null, + + global::System.Action? sentinel = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (IsEvent) + { + @event?.Invoke(Event!); + } + else if (IsSentinel) + { + sentinel?.Invoke(Sentinel!); + } + } + + /// + /// + /// + public void Switch( + global::System.Action? @event = null, + global::System.Action? sentinel = null, bool validate = true) { if (validate) diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionSystemMessageParam.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionSystemMessageParam.g.cs index eb3379e5..dc36fd51 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionSystemMessageParam.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionSystemMessageParam.g.cs @@ -59,5 +59,6 @@ public ChatCompletionSystemMessageParam( public ChatCompletionSystemMessageParam() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionToken.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionToken.g.cs index 89c427fd..faeddb08 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionToken.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionToken.g.cs @@ -70,5 +70,6 @@ public ChatCompletionToken( public ChatCompletionToken() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionTool.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionTool.g.cs index eb2e0f41..c75c2490 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionTool.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionTool.g.cs @@ -50,5 +50,6 @@ public ChatCompletionTool( public ChatCompletionTool() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionToolFunction.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionToolFunction.g.cs index 4c2fb738..39f43bf1 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionToolFunction.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionToolFunction.g.cs @@ -58,5 +58,6 @@ public ChatCompletionToolFunction( public ChatCompletionToolFunction() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionToolFunctionParameters.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionToolFunctionParameters.g.cs index b50c9874..52c13f25 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionToolFunctionParameters.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionToolFunctionParameters.g.cs @@ -14,5 +14,6 @@ public sealed partial class ChatCompletionToolFunctionParameters /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionToolMessageParam.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionToolMessageParam.g.cs index 66418e96..049d53d6 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionToolMessageParam.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionToolMessageParam.g.cs @@ -69,5 +69,6 @@ public ChatCompletionToolMessageParam( public ChatCompletionToolMessageParam() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContent.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContent.g.cs index 04bd26cc..61b2df0e 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContent.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContent.g.cs @@ -26,6 +26,26 @@ namespace Together #endif public bool IsString => String != null; + /// + /// + /// + public bool TryPickString( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out string? value) + { + value = String; + return IsString; + } + + /// + /// + /// + public string PickString() => IsString + ? String! + : throw new global::System.InvalidOperationException($"Expected union variant 'String' but the value was {ToString()}."); + /// /// A structured message with mixed content types. /// @@ -42,6 +62,26 @@ namespace Together [global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(Multimodal))] #endif public bool IsMultimodal => Multimodal != null; + + /// + /// + /// + public bool TryPickMultimodal( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::System.Collections.Generic.IList>? value) + { + value = Multimodal; + return IsMultimodal; + } + + /// + /// + /// + public global::System.Collections.Generic.IList> PickMultimodal() => IsMultimodal + ? Multimodal! + : throw new global::System.InvalidOperationException($"Expected union variant 'Multimodal' but the value was {ToString()}."); /// /// /// @@ -60,6 +100,11 @@ public ChatCompletionUserMessageContent(string? value) String = value; } + /// + /// + /// + public static ChatCompletionUserMessageContent FromString(string? value) => new ChatCompletionUserMessageContent(value); + /// /// /// @@ -100,8 +145,8 @@ public bool Validate() /// /// public TResult? Match( - global::System.Func? @string = null, - global::System.Func>?, TResult>? multimodal = null, + global::System.Func? @string = null, + global::System.Func>, TResult>? multimodal = null, bool validate = true) { if (validate) @@ -125,8 +170,32 @@ public bool Validate() /// /// public void Match( - global::System.Action? @string = null, - global::System.Action>?>? multimodal = null, + global::System.Action? @string = null, + + global::System.Action>>? multimodal = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (IsString) + { + @string?.Invoke(String!); + } + else if (IsMultimodal) + { + multimodal?.Invoke(Multimodal!); + } + } + + /// + /// + /// + public void Switch( + global::System.Action? @string = null, + global::System.Action>>? multimodal = null, bool validate = true) { if (validate) diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemAudio.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemAudio.g.cs index ccf119bd..ec3c7e9c 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemAudio.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemAudio.g.cs @@ -50,5 +50,6 @@ public ChatCompletionUserMessageContentMultimodalItemAudio( public ChatCompletionUserMessageContentMultimodalItemAudio() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemAudioAudioUrl.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemAudioAudioUrl.g.cs index 55572c2a..b5bf83af 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemAudioAudioUrl.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemAudioAudioUrl.g.cs @@ -42,5 +42,6 @@ public ChatCompletionUserMessageContentMultimodalItemAudioAudioUrl( public ChatCompletionUserMessageContentMultimodalItemAudioAudioUrl() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemInputAudio.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemInputAudio.g.cs index f17ed4e2..cd628c06 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemInputAudio.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemInputAudio.g.cs @@ -50,5 +50,6 @@ public ChatCompletionUserMessageContentMultimodalItemInputAudio( public ChatCompletionUserMessageContentMultimodalItemInputAudio() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemInputAudioInputAudio.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemInputAudioInputAudio.g.cs index 43185c2d..7c298136 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemInputAudioInputAudio.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemInputAudioInputAudio.g.cs @@ -54,5 +54,6 @@ public ChatCompletionUserMessageContentMultimodalItemInputAudioInputAudio( public ChatCompletionUserMessageContentMultimodalItemInputAudioInputAudio() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemVariant1.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemVariant1.g.cs index cdfa430c..8c711f99 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemVariant1.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemVariant1.g.cs @@ -50,5 +50,6 @@ public ChatCompletionUserMessageContentMultimodalItemVariant1( public ChatCompletionUserMessageContentMultimodalItemVariant1() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemVariant2.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemVariant2.g.cs index fafdb995..e0b7d14d 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemVariant2.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemVariant2.g.cs @@ -49,5 +49,6 @@ public ChatCompletionUserMessageContentMultimodalItemVariant2( public ChatCompletionUserMessageContentMultimodalItemVariant2() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemVariant2ImageUrl.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemVariant2ImageUrl.g.cs index 7d78f5e0..e5bc4cf8 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemVariant2ImageUrl.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemVariant2ImageUrl.g.cs @@ -42,5 +42,6 @@ public ChatCompletionUserMessageContentMultimodalItemVariant2ImageUrl( public ChatCompletionUserMessageContentMultimodalItemVariant2ImageUrl() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemVideo.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemVideo.g.cs index 964cdbf6..7e96cd15 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemVideo.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemVideo.g.cs @@ -50,5 +50,6 @@ public ChatCompletionUserMessageContentMultimodalItemVideo( public ChatCompletionUserMessageContentMultimodalItemVideo() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemVideoVideoUrl.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemVideoVideoUrl.g.cs index cc38174f..a9860bd9 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemVideoVideoUrl.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageContentMultimodalItemVideoVideoUrl.g.cs @@ -42,5 +42,6 @@ public ChatCompletionUserMessageContentMultimodalItemVideoVideoUrl( public ChatCompletionUserMessageContentMultimodalItemVideoVideoUrl() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageParam.g.cs b/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageParam.g.cs index 2f5fb579..7b09ad83 100644 --- a/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageParam.g.cs +++ b/src/libs/Together/Generated/Together.Models.ChatCompletionUserMessageParam.g.cs @@ -62,5 +62,6 @@ public ChatCompletionUserMessageParam( public ChatCompletionUserMessageParam() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ClusterDriverVersionInfo.g.cs b/src/libs/Together/Generated/Together.Models.ClusterDriverVersionInfo.g.cs index f9d6871b..de1e8084 100644 --- a/src/libs/Together/Generated/Together.Models.ClusterDriverVersionInfo.g.cs +++ b/src/libs/Together/Generated/Together.Models.ClusterDriverVersionInfo.g.cs @@ -11,9 +11,9 @@ public sealed partial class ClusterDriverVersionInfo /// /// CUDA driver version. /// - [global::System.Text.Json.Serialization.JsonPropertyName("cuda_driver_version")] + [global::System.Text.Json.Serialization.JsonPropertyName("cuda_version")] [global::System.Text.Json.Serialization.JsonRequired] - public required string CudaDriverVersion { get; set; } + public required string CudaVersion { get; set; } /// /// NVIDIA driver version. @@ -31,7 +31,7 @@ public sealed partial class ClusterDriverVersionInfo /// /// Initializes a new instance of the class. /// - /// + /// /// CUDA driver version. /// /// @@ -41,10 +41,10 @@ public sealed partial class ClusterDriverVersionInfo [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] #endif public ClusterDriverVersionInfo( - string cudaDriverVersion, + string cudaVersion, string nvidiaDriverVersion) { - this.CudaDriverVersion = cudaDriverVersion ?? throw new global::System.ArgumentNullException(nameof(cudaDriverVersion)); + this.CudaVersion = cudaVersion ?? throw new global::System.ArgumentNullException(nameof(cudaVersion)); this.NvidiaDriverVersion = nvidiaDriverVersion ?? throw new global::System.ArgumentNullException(nameof(nvidiaDriverVersion)); } @@ -54,5 +54,6 @@ public ClusterDriverVersionInfo( public ClusterDriverVersionInfo() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.CompletionChoice.g.cs b/src/libs/Together/Generated/Together.Models.CompletionChoice.g.cs index d7def169..737b4903 100644 --- a/src/libs/Together/Generated/Together.Models.CompletionChoice.g.cs +++ b/src/libs/Together/Generated/Together.Models.CompletionChoice.g.cs @@ -58,5 +58,6 @@ public CompletionChoice( public CompletionChoice() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.CompletionChoiceDelta.g.cs b/src/libs/Together/Generated/Together.Models.CompletionChoiceDelta.g.cs index b07e7f08..593c0b44 100644 --- a/src/libs/Together/Generated/Together.Models.CompletionChoiceDelta.g.cs +++ b/src/libs/Together/Generated/Together.Models.CompletionChoiceDelta.g.cs @@ -86,5 +86,6 @@ public CompletionChoiceDelta( public CompletionChoiceDelta() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.CompletionChoiceDeltaFunctionCall.g.cs b/src/libs/Together/Generated/Together.Models.CompletionChoiceDeltaFunctionCall.g.cs index eeba9a8f..a5e05dcb 100644 --- a/src/libs/Together/Generated/Together.Models.CompletionChoiceDeltaFunctionCall.g.cs +++ b/src/libs/Together/Generated/Together.Models.CompletionChoiceDeltaFunctionCall.g.cs @@ -53,5 +53,6 @@ public CompletionChoiceDeltaFunctionCall( public CompletionChoiceDeltaFunctionCall() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.CompletionChoicesDataItem.g.cs b/src/libs/Together/Generated/Together.Models.CompletionChoicesDataItem.g.cs index 8d94cf2a..74424763 100644 --- a/src/libs/Together/Generated/Together.Models.CompletionChoicesDataItem.g.cs +++ b/src/libs/Together/Generated/Together.Models.CompletionChoicesDataItem.g.cs @@ -70,5 +70,6 @@ public CompletionChoicesDataItem( public CompletionChoicesDataItem() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.CompletionChunk.g.cs b/src/libs/Together/Generated/Together.Models.CompletionChunk.g.cs index 73e30bab..689236b4 100644 --- a/src/libs/Together/Generated/Together.Models.CompletionChunk.g.cs +++ b/src/libs/Together/Generated/Together.Models.CompletionChunk.g.cs @@ -111,5 +111,6 @@ public CompletionChunk( public CompletionChunk() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.CompletionChunkObject.g.cs b/src/libs/Together/Generated/Together.Models.CompletionChunkObject.g.cs index ad4016b7..520cc6a2 100644 --- a/src/libs/Together/Generated/Together.Models.CompletionChunkObject.g.cs +++ b/src/libs/Together/Generated/Together.Models.CompletionChunkObject.g.cs @@ -14,5 +14,6 @@ public sealed partial class CompletionChunkObject /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.CompletionEvent.g.cs b/src/libs/Together/Generated/Together.Models.CompletionEvent.g.cs index fb5ef5f9..0e8f2d2c 100644 --- a/src/libs/Together/Generated/Together.Models.CompletionEvent.g.cs +++ b/src/libs/Together/Generated/Together.Models.CompletionEvent.g.cs @@ -40,5 +40,6 @@ public CompletionEvent( public CompletionEvent() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.CompletionRequest.g.cs b/src/libs/Together/Generated/Together.Models.CompletionRequest.g.cs index ac1f33cf..e1bd6a48 100644 --- a/src/libs/Together/Generated/Together.Models.CompletionRequest.g.cs +++ b/src/libs/Together/Generated/Together.Models.CompletionRequest.g.cs @@ -34,7 +34,7 @@ public sealed partial class CompletionRequest public int? MaxTokens { get; set; } /// - /// A list of string sequences that will truncate (stop) inference text output. For example, "</s>" will stop generation as soon as the model generates the given token. + /// A list of string sequences that truncate (stop) inference text output. For example, "</s>" stops generation as soon as the model generates the given token. /// [global::System.Text.Json.Serialization.JsonPropertyName("stop")] public global::System.Collections.Generic.IList? Stop { get; set; } @@ -70,13 +70,13 @@ public sealed partial class CompletionRequest public bool? Stream { get; set; } /// - /// An integer between 0 and 20 of the top k tokens to return log probabilities for at each generation step, instead of just the sampled token. Log probabilities help assess model confidence in token predictions. + /// An integer between 0 and 20 of the top k tokens to return log probabilities for at each generation step, instead of only the sampled token. Log probabilities help assess model confidence in token predictions. /// [global::System.Text.Json.Serialization.JsonPropertyName("logprobs")] public int? Logprobs { get; set; } /// - /// If true, the response will contain the prompt. Can be used with `logprobs` to return prompt logprobs. + /// If true, the response contains the prompt. Can be used with `logprobs` to return prompt logprobs. /// [global::System.Text.Json.Serialization.JsonPropertyName("echo")] public bool? Echo { get; set; } @@ -151,7 +151,7 @@ public sealed partial class CompletionRequest /// The maximum number of tokens to generate. /// /// - /// A list of string sequences that will truncate (stop) inference text output. For example, "</s>" will stop generation as soon as the model generates the given token. + /// A list of string sequences that truncate (stop) inference text output. For example, "</s>" stops generation as soon as the model generates the given token. /// /// /// A decimal number from 0-1 that determines the degree of randomness in the response. A temperature less than 1 favors more correctness and is appropriate for question answering or summarization. A value closer to 1 introduces more randomness in the output. @@ -169,10 +169,10 @@ public sealed partial class CompletionRequest /// If true, stream tokens as Server-Sent Events as the model generates them instead of waiting for the full model response. The stream terminates with `data: [DONE]`. If false, return a single JSON object containing the results. /// /// - /// An integer between 0 and 20 of the top k tokens to return log probabilities for at each generation step, instead of just the sampled token. Log probabilities help assess model confidence in token predictions. + /// An integer between 0 and 20 of the top k tokens to return log probabilities for at each generation step, instead of only the sampled token. Log probabilities help assess model confidence in token predictions. /// /// - /// If true, the response will contain the prompt. Can be used with `logprobs` to return prompt logprobs. + /// If true, the response contains the prompt. Can be used with `logprobs` to return prompt logprobs. /// /// /// The number of completions to generate for each prompt. @@ -247,5 +247,6 @@ public CompletionRequest( public CompletionRequest() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.CompletionRequestLogitBias.g.cs b/src/libs/Together/Generated/Together.Models.CompletionRequestLogitBias.g.cs index 147b2224..a0bc75b0 100644 --- a/src/libs/Together/Generated/Together.Models.CompletionRequestLogitBias.g.cs +++ b/src/libs/Together/Generated/Together.Models.CompletionRequestLogitBias.g.cs @@ -15,5 +15,6 @@ public sealed partial class CompletionRequestLogitBias /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.CompletionResponse.g.cs b/src/libs/Together/Generated/Together.Models.CompletionResponse.g.cs index 114dc8e1..2ee70014 100644 --- a/src/libs/Together/Generated/Together.Models.CompletionResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.CompletionResponse.g.cs @@ -103,5 +103,6 @@ public CompletionResponse( public CompletionResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.CompletionResponseObject.g.cs b/src/libs/Together/Generated/Together.Models.CompletionResponseObject.g.cs index 1dd7835c..e3025da7 100644 --- a/src/libs/Together/Generated/Together.Models.CompletionResponseObject.g.cs +++ b/src/libs/Together/Generated/Together.Models.CompletionResponseObject.g.cs @@ -14,5 +14,6 @@ public sealed partial class CompletionResponseObject /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.CompletionStream.g.cs b/src/libs/Together/Generated/Together.Models.CompletionStream.g.cs index 822823a2..c6922bc3 100644 --- a/src/libs/Together/Generated/Together.Models.CompletionStream.g.cs +++ b/src/libs/Together/Generated/Together.Models.CompletionStream.g.cs @@ -26,6 +26,26 @@ namespace Together #endif public bool IsEvent => Event != null; + /// + /// + /// + public bool TryPickEvent( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Together.CompletionEvent? value) + { + value = Event; + return IsEvent; + } + + /// + /// + /// + public global::Together.CompletionEvent PickEvent() => IsEvent + ? Event! + : throw new global::System.InvalidOperationException($"Expected union variant 'Event' but the value was {ToString()}."); + /// /// /// @@ -42,6 +62,26 @@ namespace Together [global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(Sentinel))] #endif public bool IsSentinel => Sentinel != null; + + /// + /// + /// + public bool TryPickSentinel( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Together.StreamSentinel? value) + { + value = Sentinel; + return IsSentinel; + } + + /// + /// + /// + public global::Together.StreamSentinel PickSentinel() => IsSentinel + ? Sentinel! + : throw new global::System.InvalidOperationException($"Expected union variant 'Sentinel' but the value was {ToString()}."); /// /// /// @@ -60,6 +100,11 @@ public CompletionStream(global::Together.CompletionEvent? value) Event = value; } + /// + /// + /// + public static CompletionStream FromEvent(global::Together.CompletionEvent? value) => new CompletionStream(value); + /// /// /// @@ -78,6 +123,11 @@ public CompletionStream(global::Together.StreamSentinel? value) Sentinel = value; } + /// + /// + /// + public static CompletionStream FromSentinel(global::Together.StreamSentinel? value) => new CompletionStream(value); + /// /// /// @@ -118,8 +168,8 @@ public bool Validate() /// /// public TResult? Match( - global::System.Func? @event = null, - global::System.Func? sentinel = null, + global::System.Func? @event = null, + global::System.Func? sentinel = null, bool validate = true) { if (validate) @@ -143,8 +193,32 @@ public bool Validate() /// /// public void Match( - global::System.Action? @event = null, - global::System.Action? sentinel = null, + global::System.Action? @event = null, + + global::System.Action? sentinel = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (IsEvent) + { + @event?.Invoke(Event!); + } + else if (IsSentinel) + { + sentinel?.Invoke(Sentinel!); + } + } + + /// + /// + /// + public void Switch( + global::System.Action? @event = null, + global::System.Action? sentinel = null, bool validate = true) { if (validate) diff --git a/src/libs/Together/Generated/Together.Models.CompletionToken.g.cs b/src/libs/Together/Generated/Together.Models.CompletionToken.g.cs index 9ce58d30..4cc225dc 100644 --- a/src/libs/Together/Generated/Together.Models.CompletionToken.g.cs +++ b/src/libs/Together/Generated/Together.Models.CompletionToken.g.cs @@ -70,5 +70,6 @@ public CompletionToken( public CompletionToken() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ContainerStatus.g.cs b/src/libs/Together/Generated/Together.Models.ContainerStatus.g.cs index 2c9f7d50..24a3a7ec 100644 --- a/src/libs/Together/Generated/Together.Models.ContainerStatus.g.cs +++ b/src/libs/Together/Generated/Together.Models.ContainerStatus.g.cs @@ -96,5 +96,6 @@ public ContainerStatus( public ContainerStatus() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.CosineLRSchedulerArgs.g.cs b/src/libs/Together/Generated/Together.Models.CosineLRSchedulerArgs.g.cs index a7b6ef4d..bb05567b 100644 --- a/src/libs/Together/Generated/Together.Models.CosineLRSchedulerArgs.g.cs +++ b/src/libs/Together/Generated/Together.Models.CosineLRSchedulerArgs.g.cs @@ -58,5 +58,6 @@ public CosineLRSchedulerArgs( public CosineLRSchedulerArgs() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.CreateBatchRequest.g.cs b/src/libs/Together/Generated/Together.Models.CreateBatchRequest.g.cs index 51faaa0a..a73a89df 100644 --- a/src/libs/Together/Generated/Together.Models.CreateBatchRequest.g.cs +++ b/src/libs/Together/Generated/Together.Models.CreateBatchRequest.g.cs @@ -9,13 +9,17 @@ namespace Together public sealed partial class CreateBatchRequest { /// - /// The endpoint to use for batch processing
+ /// The endpoint to use for batch processing. Each line of the uploaded input file is dispatched against this endpoint.
+ /// - `/v1/chat/completions` — chat completion batches
+ /// - `/v1/audio/transcriptions` — audio transcription batches (e.g. `openai/whisper-large-v3`)
+ /// - `/v1/audio/translations` — audio translation batches
/// Example: /v1/chat/completions ///
/// /v1/chat/completions [global::System.Text.Json.Serialization.JsonPropertyName("endpoint")] + [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Together.JsonConverters.CreateBatchRequestEndpointJsonConverter))] [global::System.Text.Json.Serialization.JsonRequired] - public required string Endpoint { get; set; } + public required global::Together.CreateBatchRequestEndpoint Endpoint { get; set; } /// /// ID of the uploaded input file containing batch requests
@@ -60,7 +64,10 @@ public sealed partial class CreateBatchRequest /// Initializes a new instance of the class. ///
/// - /// The endpoint to use for batch processing
+ /// The endpoint to use for batch processing. Each line of the uploaded input file is dispatched against this endpoint.
+ /// - `/v1/chat/completions` — chat completion batches
+ /// - `/v1/audio/transcriptions` — audio transcription batches (e.g. `openai/whisper-large-v3`)
+ /// - `/v1/audio/translations` — audio translation batches
/// Example: /v1/chat/completions /// /// @@ -83,13 +90,13 @@ public sealed partial class CreateBatchRequest [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] #endif public CreateBatchRequest( - string endpoint, + global::Together.CreateBatchRequestEndpoint endpoint, string inputFileId, string? completionWindow, int? priority, string? modelId) { - this.Endpoint = endpoint ?? throw new global::System.ArgumentNullException(nameof(endpoint)); + this.Endpoint = endpoint; this.InputFileId = inputFileId ?? throw new global::System.ArgumentNullException(nameof(inputFileId)); this.CompletionWindow = completionWindow; this.Priority = priority; @@ -102,5 +109,6 @@ public CreateBatchRequest( public CreateBatchRequest() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.CreateBatchRequestEndpoint.g.cs b/src/libs/Together/Generated/Together.Models.CreateBatchRequestEndpoint.g.cs new file mode 100644 index 00000000..964dba07 --- /dev/null +++ b/src/libs/Together/Generated/Together.Models.CreateBatchRequestEndpoint.g.cs @@ -0,0 +1,61 @@ + +#nullable enable + +namespace Together +{ + /// + /// The endpoint to use for batch processing. Each line of the uploaded input file is dispatched against this endpoint.
+ /// - `/v1/chat/completions` — chat completion batches
+ /// - `/v1/audio/transcriptions` — audio transcription batches (e.g. `openai/whisper-large-v3`)
+ /// - `/v1/audio/translations` — audio translation batches
+ /// Example: /v1/chat/completions + ///
+ public enum CreateBatchRequestEndpoint + { + /// + /// + /// + V1AudioTranscriptions, + /// + /// + /// + V1AudioTranslations, + /// + /// + /// + V1ChatCompletions, + } + + /// + /// Enum extensions to do fast conversions without the reflection. + /// + public static class CreateBatchRequestEndpointExtensions + { + /// + /// Converts an enum to a string. + /// + public static string ToValueString(this CreateBatchRequestEndpoint value) + { + return value switch + { + CreateBatchRequestEndpoint.V1AudioTranscriptions => "/v1/audio/transcriptions", + CreateBatchRequestEndpoint.V1AudioTranslations => "/v1/audio/translations", + CreateBatchRequestEndpoint.V1ChatCompletions => "/v1/chat/completions", + _ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null), + }; + } + /// + /// Converts an string to a enum. + /// + public static CreateBatchRequestEndpoint? ToEnum(string value) + { + return value switch + { + "/v1/audio/transcriptions" => CreateBatchRequestEndpoint.V1AudioTranscriptions, + "/v1/audio/translations" => CreateBatchRequestEndpoint.V1AudioTranslations, + "/v1/chat/completions" => CreateBatchRequestEndpoint.V1ChatCompletions, + _ => null, + }; + } + } +} \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.CreateDeploymentRequest.g.cs b/src/libs/Together/Generated/Together.Models.CreateDeploymentRequest.g.cs index 1538f148..58077dc7 100644 --- a/src/libs/Together/Generated/Together.Models.CreateDeploymentRequest.g.cs +++ b/src/libs/Together/Generated/Together.Models.CreateDeploymentRequest.g.cs @@ -56,10 +56,11 @@ public sealed partial class CreateDeploymentRequest /// [global::System.Text.Json.Serialization.JsonPropertyName("gpu_type")] [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Together.JsonConverters.CreateDeploymentRequestGpuTypeJsonConverter))] - public global::Together.CreateDeploymentRequestGpuType GpuType { get; set; } + [global::System.Text.Json.Serialization.JsonRequired] + public required global::Together.CreateDeploymentRequestGpuType GpuType { get; set; } /// - /// HealthCheckPath is the HTTP path for health checks (e.g., "/health"). If set, the platform will check this endpoint to determine container health + /// HealthCheckPath is the HTTP path for health checks (e.g., "/health"). If set, the platform checks this endpoint to determine container health. /// [global::System.Text.Json.Serialization.JsonPropertyName("health_check_path")] public string? HealthCheckPath { get; set; } @@ -72,7 +73,7 @@ public sealed partial class CreateDeploymentRequest public required string Image { get; set; } /// - /// MaxReplicas is the maximum number of container instances that can be scaled up to. If not set, will be set to MinReplicas + /// MaxReplicas is the maximum number of container instances. Defaults to MinReplicas if not set. /// [global::System.Text.Json.Serialization.JsonPropertyName("max_replicas")] public int? MaxReplicas { get; set; } @@ -129,6 +130,9 @@ public sealed partial class CreateDeploymentRequest /// /// Initializes a new instance of the class. /// + /// + /// GPUType specifies the GPU hardware to use (e.g., "h100-80gb"). + /// /// /// Image is the container image to deploy from registry.together.ai. /// @@ -156,14 +160,11 @@ public sealed partial class CreateDeploymentRequest /// /// GPUCount is the number of GPUs to allocate per container instance. Defaults to 0 if not specified /// - /// - /// GPUType specifies the GPU hardware to use (e.g., "h100-80gb"). - /// /// - /// HealthCheckPath is the HTTP path for health checks (e.g., "/health"). If set, the platform will check this endpoint to determine container health + /// HealthCheckPath is the HTTP path for health checks (e.g., "/health"). If set, the platform checks this endpoint to determine container health. /// /// - /// MaxReplicas is the maximum number of container instances that can be scaled up to. If not set, will be set to MinReplicas + /// MaxReplicas is the maximum number of container instances. Defaults to MinReplicas if not set. /// /// /// Memory is the amount of RAM to allocate per container instance in GiB (e.g., 0.5 = 512MiB) @@ -187,6 +188,7 @@ public sealed partial class CreateDeploymentRequest [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] #endif public CreateDeploymentRequest( + global::Together.CreateDeploymentRequestGpuType gpuType, string image, string name, global::System.Collections.Generic.IList? args, @@ -196,7 +198,6 @@ public CreateDeploymentRequest( string? description, global::System.Collections.Generic.IList? environmentVariables, int? gpuCount, - global::Together.CreateDeploymentRequestGpuType gpuType, string? healthCheckPath, int? maxReplicas, double? memory, @@ -232,5 +233,6 @@ public CreateDeploymentRequest( public CreateDeploymentRequest() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.CreateDeploymentRequestGpuType.g.cs b/src/libs/Together/Generated/Together.Models.CreateDeploymentRequestGpuType.g.cs index ea07d692..ca57d890 100644 --- a/src/libs/Together/Generated/Together.Models.CreateDeploymentRequestGpuType.g.cs +++ b/src/libs/Together/Generated/Together.Models.CreateDeploymentRequestGpuType.g.cs @@ -8,6 +8,14 @@ namespace Together /// public enum CreateDeploymentRequestGpuType { + /// + /// + /// + B200192gb, + /// + /// + /// + H10040gbMig, /// /// /// @@ -26,6 +34,8 @@ public static string ToValueString(this CreateDeploymentRequestGpuType value) { return value switch { + CreateDeploymentRequestGpuType.B200192gb => "b200-192gb", + CreateDeploymentRequestGpuType.H10040gbMig => "h100-40gb-mig", CreateDeploymentRequestGpuType.H10080gb => "h100-80gb", _ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null), }; @@ -37,6 +47,8 @@ public static string ToValueString(this CreateDeploymentRequestGpuType value) { return value switch { + "b200-192gb" => CreateDeploymentRequestGpuType.B200192gb, + "h100-40gb-mig" => CreateDeploymentRequestGpuType.H10040gbMig, "h100-80gb" => CreateDeploymentRequestGpuType.H10080gb, _ => null, }; diff --git a/src/libs/Together/Generated/Together.Models.CreateDeploymentsResponse.g.cs b/src/libs/Together/Generated/Together.Models.CreateDeploymentsResponse.g.cs index 3ddc821f..55f46f18 100644 --- a/src/libs/Together/Generated/Together.Models.CreateDeploymentsResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.CreateDeploymentsResponse.g.cs @@ -14,5 +14,6 @@ public sealed partial class CreateDeploymentsResponse /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.CreateDeploymentsResponse2.g.cs b/src/libs/Together/Generated/Together.Models.CreateDeploymentsResponse2.g.cs index b741d990..b4fade88 100644 --- a/src/libs/Together/Generated/Together.Models.CreateDeploymentsResponse2.g.cs +++ b/src/libs/Together/Generated/Together.Models.CreateDeploymentsResponse2.g.cs @@ -14,5 +14,6 @@ public sealed partial class CreateDeploymentsResponse2 /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.CreateDeploymentsSecretsResponse.g.cs b/src/libs/Together/Generated/Together.Models.CreateDeploymentsSecretsResponse.g.cs index b82c4d47..8359981e 100644 --- a/src/libs/Together/Generated/Together.Models.CreateDeploymentsSecretsResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.CreateDeploymentsSecretsResponse.g.cs @@ -14,5 +14,6 @@ public sealed partial class CreateDeploymentsSecretsResponse /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.CreateDeploymentsSecretsResponse2.g.cs b/src/libs/Together/Generated/Together.Models.CreateDeploymentsSecretsResponse2.g.cs index ad3eb77f..5f28c806 100644 --- a/src/libs/Together/Generated/Together.Models.CreateDeploymentsSecretsResponse2.g.cs +++ b/src/libs/Together/Generated/Together.Models.CreateDeploymentsSecretsResponse2.g.cs @@ -14,5 +14,6 @@ public sealed partial class CreateDeploymentsSecretsResponse2 /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.CreateDeploymentsStorageVolumesResponse.g.cs b/src/libs/Together/Generated/Together.Models.CreateDeploymentsStorageVolumesResponse.g.cs index 22ea0b49..9fbcf199 100644 --- a/src/libs/Together/Generated/Together.Models.CreateDeploymentsStorageVolumesResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.CreateDeploymentsStorageVolumesResponse.g.cs @@ -14,5 +14,6 @@ public sealed partial class CreateDeploymentsStorageVolumesResponse /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.CreateDeploymentsStorageVolumesResponse2.g.cs b/src/libs/Together/Generated/Together.Models.CreateDeploymentsStorageVolumesResponse2.g.cs index c2917b55..eaf751aa 100644 --- a/src/libs/Together/Generated/Together.Models.CreateDeploymentsStorageVolumesResponse2.g.cs +++ b/src/libs/Together/Generated/Together.Models.CreateDeploymentsStorageVolumesResponse2.g.cs @@ -14,5 +14,6 @@ public sealed partial class CreateDeploymentsStorageVolumesResponse2 /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.CreateEndpointRequest.g.cs b/src/libs/Together/Generated/Together.Models.CreateEndpointRequest.g.cs index 460e9354..831c3c49 100644 --- a/src/libs/Together/Generated/Together.Models.CreateEndpointRequest.g.cs +++ b/src/libs/Together/Generated/Together.Models.CreateEndpointRequest.g.cs @@ -69,7 +69,7 @@ public sealed partial class CreateEndpointRequest public global::Together.CreateEndpointRequestState? State { get; set; } /// - /// The number of minutes of inactivity after which the endpoint will be automatically stopped. Set to null, omit or set to 0 to disable automatic timeout.
+ /// The number of minutes of inactivity after which the endpoint stops automatically. Set to null, omit, or set to 0 to disable automatic timeout.
/// Example: 60 ///
/// 60 @@ -116,7 +116,7 @@ public sealed partial class CreateEndpointRequest /// Example: STARTED /// /// - /// The number of minutes of inactivity after which the endpoint will be automatically stopped. Set to null, omit or set to 0 to disable automatic timeout.
+ /// The number of minutes of inactivity after which the endpoint stops automatically. Set to null, omit, or set to 0 to disable automatic timeout.
/// Example: 60 /// /// @@ -151,5 +151,6 @@ public CreateEndpointRequest( public CreateEndpointRequest() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.CreateFilesUploadRequest.g.cs b/src/libs/Together/Generated/Together.Models.CreateFilesUploadRequest.g.cs index a330e580..6a1114a0 100644 --- a/src/libs/Together/Generated/Together.Models.CreateFilesUploadRequest.g.cs +++ b/src/libs/Together/Generated/Together.Models.CreateFilesUploadRequest.g.cs @@ -90,5 +90,6 @@ public CreateFilesUploadRequest( public CreateFilesUploadRequest() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.CreateFineTunesEstimatePriceRequest.g.cs b/src/libs/Together/Generated/Together.Models.CreateFineTunesEstimatePriceRequest.g.cs index 1300aba2..92c7901b 100644 --- a/src/libs/Together/Generated/Together.Models.CreateFineTunesEstimatePriceRequest.g.cs +++ b/src/libs/Together/Generated/Together.Models.CreateFineTunesEstimatePriceRequest.g.cs @@ -49,7 +49,7 @@ public sealed partial class CreateFineTunesEstimatePriceRequest public global::Together.OneOf? TrainingMethod { get; set; } /// - /// The training type to use. If not provided, the job will default to LoRA training type.
+ /// The training type to use. Defaults to LoRA if not provided.
/// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 ///
[global::System.Text.Json.Serialization.JsonPropertyName("training_type")] @@ -57,7 +57,7 @@ public sealed partial class CreateFineTunesEstimatePriceRequest public global::Together.OneOf? TrainingType { get; set; } /// - /// The checkpoint identifier to continue training from a previous fine-tuning job. Format is `{$JOB_ID}` or `{$OUTPUT_MODEL_NAME}` or `{$JOB_ID}:{$STEP}` or `{$OUTPUT_MODEL_NAME}:{$STEP}`. The step value is optional; without it, the final checkpoint will be used. + /// The checkpoint identifier to continue training from a previous fine-tuning job. Format is `{$JOB_ID}` or `{$OUTPUT_MODEL_NAME}` or `{$JOB_ID}:{$STEP}` or `{$OUTPUT_MODEL_NAME}:{$STEP}`. The step value is optional; without it, uses the final checkpoint. /// [global::System.Text.Json.Serialization.JsonPropertyName("from_checkpoint")] public string? FromCheckpoint { get; set; } @@ -92,11 +92,11 @@ public sealed partial class CreateFineTunesEstimatePriceRequest /// The training method to use. 'sft' for Supervised Fine-Tuning or 'dpo' for Direct Preference Optimization. /// /// - /// The training type to use. If not provided, the job will default to LoRA training type.
+ /// The training type to use. Defaults to LoRA if not provided.
/// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 /// /// - /// The checkpoint identifier to continue training from a previous fine-tuning job. Format is `{$JOB_ID}` or `{$OUTPUT_MODEL_NAME}` or `{$JOB_ID}:{$STEP}` or `{$OUTPUT_MODEL_NAME}:{$STEP}`. The step value is optional; without it, the final checkpoint will be used. + /// The checkpoint identifier to continue training from a previous fine-tuning job. Format is `{$JOB_ID}` or `{$OUTPUT_MODEL_NAME}` or `{$JOB_ID}:{$STEP}` or `{$OUTPUT_MODEL_NAME}:{$STEP}`. The step value is optional; without it, uses the final checkpoint. /// #if NET7_0_OR_GREATER [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] @@ -127,5 +127,6 @@ public CreateFineTunesEstimatePriceRequest( public CreateFineTunesEstimatePriceRequest() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.CreateFineTunesEstimatePriceResponse.g.cs b/src/libs/Together/Generated/Together.Models.CreateFineTunesEstimatePriceResponse.g.cs index e5644fed..bf88a522 100644 --- a/src/libs/Together/Generated/Together.Models.CreateFineTunesEstimatePriceResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.CreateFineTunesEstimatePriceResponse.g.cs @@ -15,7 +15,7 @@ public sealed partial class CreateFineTunesEstimatePriceResponse public double? EstimatedTotalPrice { get; set; } /// - /// Whether the user is allowed to proceed with the fine-tuning job
+ /// Whether you are allowed to proceed with the fine-tuning job.
/// Example: true ///
/// true @@ -23,7 +23,7 @@ public sealed partial class CreateFineTunesEstimatePriceResponse public bool? AllowedToProceed { get; set; } /// - /// The user's credit limit in dollars + /// Your credit limit in dollars. /// [global::System.Text.Json.Serialization.JsonPropertyName("user_limit")] public double? UserLimit { get; set; } @@ -53,11 +53,11 @@ public sealed partial class CreateFineTunesEstimatePriceResponse /// The price of the fine-tuning job /// /// - /// Whether the user is allowed to proceed with the fine-tuning job
+ /// Whether you are allowed to proceed with the fine-tuning job.
/// Example: true /// /// - /// The user's credit limit in dollars + /// Your credit limit in dollars. /// /// /// The estimated number of tokens to be trained @@ -88,5 +88,6 @@ public CreateFineTunesEstimatePriceResponse( public CreateFineTunesEstimatePriceResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.CreateFineTunesRequest.g.cs b/src/libs/Together/Generated/Together.Models.CreateFineTunesRequest.g.cs index 2125c907..7e0da80f 100644 --- a/src/libs/Together/Generated/Together.Models.CreateFineTunesRequest.g.cs +++ b/src/libs/Together/Generated/Together.Models.CreateFineTunesRequest.g.cs @@ -30,6 +30,12 @@ public sealed partial class CreateFineTunesRequest [global::System.Text.Json.Serialization.JsonPropertyName("packing")] public bool? Packing { get; set; } + /// + /// Maximum sequence length to use for training. If not specified, the maximum allowed for the model and training method will be used. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("max_seq_length")] + public int? MaxSeqLength { get; set; } + /// /// Name of the base model to run fine-tune job on /// @@ -66,6 +72,13 @@ public sealed partial class CreateFineTunesRequest [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Together.JsonConverters.OneOfJsonConverter))] public global::Together.OneOf? BatchSize { get; set; } + /// + /// Number of steps to accumulate gradients before performing a weight update. Effectively increases the batch size without requiring more memory. For example, with batch_size=4 and gradient_accumulation_steps=8, the effective batch size is 32.
+ /// Default Value: 1 + ///
+ [global::System.Text.Json.Serialization.JsonPropertyName("gradient_accumulation_steps")] + public int? GradientAccumulationSteps { get; set; } + /// /// Controls how quickly the model adapts to new information (too high may cause instability, too low may slow convergence)
/// Default Value: 0.00001 @@ -108,7 +121,7 @@ public sealed partial class CreateFineTunesRequest public int? RandomSeed { get; set; } /// - /// Suffix that will be added to your fine-tuned model name + /// Suffix to add to your fine-tuned model name. Must be at most 64 characters long. /// [global::System.Text.Json.Serialization.JsonPropertyName("suffix")] public string? Suffix { get; set; } @@ -126,7 +139,7 @@ public sealed partial class CreateFineTunesRequest public string? WandbBaseUrl { get; set; } /// - /// The Weights & Biases project for your run. If not specified, will use `together` as the project name. + /// The Weights & Biases project for your run. If not specified, uses `together` as the project name. /// [global::System.Text.Json.Serialization.JsonPropertyName("wandb_project_name")] public string? WandbProjectName { get; set; } @@ -144,7 +157,7 @@ public sealed partial class CreateFineTunesRequest public string? WandbEntity { get; set; } /// - /// Whether to mask the user messages in conversational data or prompts in instruction data.
+ /// Whether to mask user messages in conversational data or prompts in instruction data.
/// Default Value: auto ///
[global::System.Text.Json.Serialization.JsonPropertyName("train_on_inputs")] @@ -159,7 +172,7 @@ public sealed partial class CreateFineTunesRequest public global::Together.OneOf? TrainingMethod { get; set; } /// - /// The training type to use. If not provided, the job will default to LoRA training type.
+ /// The training type to use. Defaults to LoRA if not provided.
/// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 ///
[global::System.Text.Json.Serialization.JsonPropertyName("training_type")] @@ -173,7 +186,7 @@ public sealed partial class CreateFineTunesRequest public global::Together.MultimodalParams? MultimodalParams { get; set; } /// - /// The checkpoint identifier to continue training from a previous fine-tuning job. Format is `{$JOB_ID}` or `{$OUTPUT_MODEL_NAME}` or `{$JOB_ID}:{$STEP}` or `{$OUTPUT_MODEL_NAME}:{$STEP}`. The step value is optional; without it, the final checkpoint will be used. + /// The checkpoint identifier to continue training from a previous fine-tuning job. Format is `{$JOB_ID}` or `{$OUTPUT_MODEL_NAME}` or `{$JOB_ID}:{$STEP}` or `{$OUTPUT_MODEL_NAME}:{$STEP}`. The step value is optional; without it, uses the final checkpoint. /// [global::System.Text.Json.Serialization.JsonPropertyName("from_checkpoint")] public string? FromCheckpoint { get; set; } @@ -224,6 +237,9 @@ public sealed partial class CreateFineTunesRequest /// Whether to use sequence packing for training.
/// Default Value: true /// + /// + /// Maximum sequence length to use for training. If not specified, the maximum allowed for the model and training method will be used. + /// /// /// Number of complete passes through the training dataset (higher values may improve results but increase cost and risk of overfitting)
/// Default Value: 1 @@ -240,6 +256,10 @@ public sealed partial class CreateFineTunesRequest /// Number of training examples processed together (larger batches use more memory but may train faster). Defaults to "max". We use training optimizations like packing, so the effective batch size may be different than the value you set.
/// Default Value: max /// + /// + /// Number of steps to accumulate gradients before performing a weight update. Effectively increases the batch size without requiring more memory. For example, with batch_size=4 and gradient_accumulation_steps=8, the effective batch size is 32.
+ /// Default Value: 1 + /// /// /// Controls how quickly the model adapts to new information (too high may cause instability, too low may slow convergence)
/// Default Value: 0.00001 @@ -264,7 +284,7 @@ public sealed partial class CreateFineTunesRequest /// Random seed for reproducible training. When set, the same seed produces the same run (e.g. data shuffle, init). If omitted or null, the server applies its default seed (e.g. 42). /// /// - /// Suffix that will be added to your fine-tuned model name + /// Suffix to add to your fine-tuned model name. Must be at most 64 characters long. /// /// /// Integration key for tracking experiments and model metrics on W&B platform @@ -273,7 +293,7 @@ public sealed partial class CreateFineTunesRequest /// The base URL of a dedicated Weights & Biases instance. /// /// - /// The Weights & Biases project for your run. If not specified, will use `together` as the project name. + /// The Weights & Biases project for your run. If not specified, uses `together` as the project name. /// /// /// The Weights & Biases name for your run. @@ -285,12 +305,12 @@ public sealed partial class CreateFineTunesRequest /// The training method to use. 'sft' for Supervised Fine-Tuning or 'dpo' for Direct Preference Optimization. /// /// - /// The training type to use. If not provided, the job will default to LoRA training type.
+ /// The training type to use. Defaults to LoRA if not provided.
/// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 /// /// /// - /// The checkpoint identifier to continue training from a previous fine-tuning job. Format is `{$JOB_ID}` or `{$OUTPUT_MODEL_NAME}` or `{$JOB_ID}:{$STEP}` or `{$OUTPUT_MODEL_NAME}:{$STEP}`. The step value is optional; without it, the final checkpoint will be used. + /// The checkpoint identifier to continue training from a previous fine-tuning job. Format is `{$JOB_ID}` or `{$OUTPUT_MODEL_NAME}` or `{$JOB_ID}:{$STEP}` or `{$OUTPUT_MODEL_NAME}:{$STEP}`. The step value is optional; without it, uses the final checkpoint. /// /// /// The Hugging Face Hub repo to start training from. Should be as close as possible to the base model (specified by the `model` argument) in terms of architecture and size. @@ -312,10 +332,12 @@ public CreateFineTunesRequest( string model, string? validationFile, bool? packing, + int? maxSeqLength, int? nEpochs, int? nCheckpoints, int? nEvals, global::Together.OneOf? batchSize, + int? gradientAccumulationSteps, float? learningRate, global::Together.LRScheduler? lrScheduler, float? warmupRatio, @@ -340,11 +362,13 @@ public CreateFineTunesRequest( this.TrainingFile = trainingFile ?? throw new global::System.ArgumentNullException(nameof(trainingFile)); this.ValidationFile = validationFile; this.Packing = packing; + this.MaxSeqLength = maxSeqLength; this.Model = model ?? throw new global::System.ArgumentNullException(nameof(model)); this.NEpochs = nEpochs; this.NCheckpoints = nCheckpoints; this.NEvals = nEvals; this.BatchSize = batchSize; + this.GradientAccumulationSteps = gradientAccumulationSteps; this.LearningRate = learningRate; this.LrScheduler = lrScheduler; this.WarmupRatio = warmupRatio; @@ -373,5 +397,6 @@ public CreateFineTunesRequest( public CreateFineTunesRequest() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.CreateImagesGenerationsRequest.g.cs b/src/libs/Together/Generated/Together.Models.CreateImagesGenerationsRequest.g.cs index 695c7986..5e7cd759 100644 --- a/src/libs/Together/Generated/Together.Models.CreateImagesGenerationsRequest.g.cs +++ b/src/libs/Together/Generated/Together.Models.CreateImagesGenerationsRequest.g.cs @@ -218,5 +218,6 @@ public CreateImagesGenerationsRequest( public CreateImagesGenerationsRequest() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.CreateImagesGenerationsRequestImageLora.g.cs b/src/libs/Together/Generated/Together.Models.CreateImagesGenerationsRequestImageLora.g.cs index 16c30a2b..17b0463d 100644 --- a/src/libs/Together/Generated/Together.Models.CreateImagesGenerationsRequestImageLora.g.cs +++ b/src/libs/Together/Generated/Together.Models.CreateImagesGenerationsRequestImageLora.g.cs @@ -54,5 +54,6 @@ public CreateImagesGenerationsRequestImageLora( public CreateImagesGenerationsRequestImageLora() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.CreateSecretRequest.g.cs b/src/libs/Together/Generated/Together.Models.CreateSecretRequest.g.cs index 9aec2595..7aeedab7 100644 --- a/src/libs/Together/Generated/Together.Models.CreateSecretRequest.g.cs +++ b/src/libs/Together/Generated/Together.Models.CreateSecretRequest.g.cs @@ -28,7 +28,7 @@ public sealed partial class CreateSecretRequest public string? ProjectId { get; set; } /// - /// Value is the sensitive data to store securely (e.g., API keys, passwords, tokens). This value will be encrypted at rest + /// Value is the sensitive data to store securely (e.g., API keys, passwords, tokens). Encrypted at rest. /// [global::System.Text.Json.Serialization.JsonPropertyName("value")] [global::System.Text.Json.Serialization.JsonRequired] @@ -47,7 +47,7 @@ public sealed partial class CreateSecretRequest /// Name is the unique identifier for the secret. Can contain alphanumeric characters, underscores, hyphens, forward slashes, and periods (1-100 characters) /// /// - /// Value is the sensitive data to store securely (e.g., API keys, passwords, tokens). This value will be encrypted at rest + /// Value is the sensitive data to store securely (e.g., API keys, passwords, tokens). Encrypted at rest. /// /// /// Description is an optional human-readable description of the secret's purpose (max 500 characters) @@ -76,5 +76,6 @@ public CreateSecretRequest( public CreateSecretRequest() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.CreateVideoBody.g.cs b/src/libs/Together/Generated/Together.Models.CreateVideoBody.g.cs index 79a154ba..5d0484a6 100644 --- a/src/libs/Together/Generated/Together.Models.CreateVideoBody.g.cs +++ b/src/libs/Together/Generated/Together.Models.CreateVideoBody.g.cs @@ -222,5 +222,6 @@ public CreateVideoBody( public CreateVideoBody() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.CreateVolumeRequest.g.cs b/src/libs/Together/Generated/Together.Models.CreateVolumeRequest.g.cs index 1498d796..faaedb72 100644 --- a/src/libs/Together/Generated/Together.Models.CreateVolumeRequest.g.cs +++ b/src/libs/Together/Generated/Together.Models.CreateVolumeRequest.g.cs @@ -66,5 +66,6 @@ public CreateVolumeRequest( public CreateVolumeRequest() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.CustomMetricAutoscalingConfig.g.cs b/src/libs/Together/Generated/Together.Models.CustomMetricAutoscalingConfig.g.cs index 333de47c..0f20aa91 100644 --- a/src/libs/Together/Generated/Together.Models.CustomMetricAutoscalingConfig.g.cs +++ b/src/libs/Together/Generated/Together.Models.CustomMetricAutoscalingConfig.g.cs @@ -73,5 +73,6 @@ public CustomMetricAutoscalingConfig( public CustomMetricAutoscalingConfig() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.DataItem3.g.cs b/src/libs/Together/Generated/Together.Models.DataItem3.g.cs index 328906f5..f20c7c2c 100644 --- a/src/libs/Together/Generated/Together.Models.DataItem3.g.cs +++ b/src/libs/Together/Generated/Together.Models.DataItem3.g.cs @@ -12,6 +12,11 @@ namespace Together /// /// /// + public global::Together.ImageResponseDataItemDiscriminatorType? Type { get; } + + /// + /// + /// #if NET6_0_OR_GREATER public global::Together.ImageResponseDataB64? B64Json { get; init; } #else @@ -26,6 +31,26 @@ namespace Together #endif public bool IsB64Json => B64Json != null; + /// + /// + /// + public bool TryPickB64Json( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Together.ImageResponseDataB64? value) + { + value = B64Json; + return IsB64Json; + } + + /// + /// + /// + public global::Together.ImageResponseDataB64 PickB64Json() => IsB64Json + ? B64Json! + : throw new global::System.InvalidOperationException($"Expected union variant 'B64Json' but the value was {ToString()}."); + /// /// /// @@ -42,6 +67,26 @@ namespace Together [global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(Url))] #endif public bool IsUrl => Url != null; + + /// + /// + /// + public bool TryPickUrl( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Together.ImageResponseDataUrl? value) + { + value = Url; + return IsUrl; + } + + /// + /// + /// + public global::Together.ImageResponseDataUrl PickUrl() => IsUrl + ? Url! + : throw new global::System.InvalidOperationException($"Expected union variant 'Url' but the value was {ToString()}."); /// /// /// @@ -60,6 +105,11 @@ public DataItem3(global::Together.ImageResponseDataB64? value) B64Json = value; } + /// + /// + /// + public static DataItem3 FromB64Json(global::Together.ImageResponseDataB64? value) => new DataItem3(value); + /// /// /// @@ -78,14 +128,22 @@ public DataItem3(global::Together.ImageResponseDataUrl? value) Url = value; } + /// + /// + /// + public static DataItem3 FromUrl(global::Together.ImageResponseDataUrl? value) => new DataItem3(value); + /// /// /// public DataItem3( + global::Together.ImageResponseDataItemDiscriminatorType? type, global::Together.ImageResponseDataB64? b64Json, global::Together.ImageResponseDataUrl? url ) { + Type = type; + B64Json = b64Json; Url = url; } @@ -118,8 +176,8 @@ public bool Validate() /// ///
public TResult? Match( - global::System.Func? b64Json = null, - global::System.Func? url = null, + global::System.Func? b64Json = null, + global::System.Func? url = null, bool validate = true) { if (validate) @@ -143,8 +201,32 @@ public bool Validate() /// /// public void Match( - global::System.Action? b64Json = null, - global::System.Action? url = null, + global::System.Action? b64Json = null, + + global::System.Action? url = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (IsB64Json) + { + b64Json?.Invoke(B64Json!); + } + else if (IsUrl) + { + url?.Invoke(Url!); + } + } + + /// + /// + /// + public void Switch( + global::System.Action? b64Json = null, + global::System.Action? url = null, bool validate = true) { if (validate) diff --git a/src/libs/Together/Generated/Together.Models.DedicatedEndpoint.g.cs b/src/libs/Together/Generated/Together.Models.DedicatedEndpoint.g.cs index f2a673bb..821c1821 100644 --- a/src/libs/Together/Generated/Together.Models.DedicatedEndpoint.g.cs +++ b/src/libs/Together/Generated/Together.Models.DedicatedEndpoint.g.cs @@ -190,5 +190,6 @@ public DedicatedEndpoint( public DedicatedEndpoint() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.DedicatedEndpointObject.g.cs b/src/libs/Together/Generated/Together.Models.DedicatedEndpointObject.g.cs index 8cedc516..91551629 100644 --- a/src/libs/Together/Generated/Together.Models.DedicatedEndpointObject.g.cs +++ b/src/libs/Together/Generated/Together.Models.DedicatedEndpointObject.g.cs @@ -14,5 +14,6 @@ public sealed partial class DedicatedEndpointObject /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.DeleteDeploymentsResponse.g.cs b/src/libs/Together/Generated/Together.Models.DeleteDeploymentsResponse.g.cs index 053bd8d6..c79fa326 100644 --- a/src/libs/Together/Generated/Together.Models.DeleteDeploymentsResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.DeleteDeploymentsResponse.g.cs @@ -14,5 +14,6 @@ public sealed partial class DeleteDeploymentsResponse /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.DeleteDeploymentsResponse2.g.cs b/src/libs/Together/Generated/Together.Models.DeleteDeploymentsResponse2.g.cs index 8550124f..eb2a4039 100644 --- a/src/libs/Together/Generated/Together.Models.DeleteDeploymentsResponse2.g.cs +++ b/src/libs/Together/Generated/Together.Models.DeleteDeploymentsResponse2.g.cs @@ -14,5 +14,6 @@ public sealed partial class DeleteDeploymentsResponse2 /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.DeleteDeploymentsResponse3.g.cs b/src/libs/Together/Generated/Together.Models.DeleteDeploymentsResponse3.g.cs index b93cd079..2be5772c 100644 --- a/src/libs/Together/Generated/Together.Models.DeleteDeploymentsResponse3.g.cs +++ b/src/libs/Together/Generated/Together.Models.DeleteDeploymentsResponse3.g.cs @@ -14,5 +14,6 @@ public sealed partial class DeleteDeploymentsResponse3 /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.DeleteDeploymentsSecretsResponse.g.cs b/src/libs/Together/Generated/Together.Models.DeleteDeploymentsSecretsResponse.g.cs index 4971f479..7128d8b5 100644 --- a/src/libs/Together/Generated/Together.Models.DeleteDeploymentsSecretsResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.DeleteDeploymentsSecretsResponse.g.cs @@ -14,5 +14,6 @@ public sealed partial class DeleteDeploymentsSecretsResponse /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.DeleteDeploymentsSecretsResponse2.g.cs b/src/libs/Together/Generated/Together.Models.DeleteDeploymentsSecretsResponse2.g.cs index 3723d139..e86448ec 100644 --- a/src/libs/Together/Generated/Together.Models.DeleteDeploymentsSecretsResponse2.g.cs +++ b/src/libs/Together/Generated/Together.Models.DeleteDeploymentsSecretsResponse2.g.cs @@ -14,5 +14,6 @@ public sealed partial class DeleteDeploymentsSecretsResponse2 /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.DeleteDeploymentsSecretsResponse3.g.cs b/src/libs/Together/Generated/Together.Models.DeleteDeploymentsSecretsResponse3.g.cs index d068d29e..3e57349b 100644 --- a/src/libs/Together/Generated/Together.Models.DeleteDeploymentsSecretsResponse3.g.cs +++ b/src/libs/Together/Generated/Together.Models.DeleteDeploymentsSecretsResponse3.g.cs @@ -14,5 +14,6 @@ public sealed partial class DeleteDeploymentsSecretsResponse3 /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.DeleteDeploymentsStorageVolumesResponse.g.cs b/src/libs/Together/Generated/Together.Models.DeleteDeploymentsStorageVolumesResponse.g.cs index 5e63a0a4..3e0ee1da 100644 --- a/src/libs/Together/Generated/Together.Models.DeleteDeploymentsStorageVolumesResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.DeleteDeploymentsStorageVolumesResponse.g.cs @@ -14,5 +14,6 @@ public sealed partial class DeleteDeploymentsStorageVolumesResponse /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.DeleteDeploymentsStorageVolumesResponse2.g.cs b/src/libs/Together/Generated/Together.Models.DeleteDeploymentsStorageVolumesResponse2.g.cs index 27bdadde..6370abba 100644 --- a/src/libs/Together/Generated/Together.Models.DeleteDeploymentsStorageVolumesResponse2.g.cs +++ b/src/libs/Together/Generated/Together.Models.DeleteDeploymentsStorageVolumesResponse2.g.cs @@ -14,5 +14,6 @@ public sealed partial class DeleteDeploymentsStorageVolumesResponse2 /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.DeleteDeploymentsStorageVolumesResponse3.g.cs b/src/libs/Together/Generated/Together.Models.DeleteDeploymentsStorageVolumesResponse3.g.cs index 52f6fef6..15ca6760 100644 --- a/src/libs/Together/Generated/Together.Models.DeleteDeploymentsStorageVolumesResponse3.g.cs +++ b/src/libs/Together/Generated/Together.Models.DeleteDeploymentsStorageVolumesResponse3.g.cs @@ -14,5 +14,6 @@ public sealed partial class DeleteDeploymentsStorageVolumesResponse3 /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.DeploymentListResponse.g.cs b/src/libs/Together/Generated/Together.Models.DeploymentListResponse.g.cs index a791364a..b85cb5ff 100644 --- a/src/libs/Together/Generated/Together.Models.DeploymentListResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.DeploymentListResponse.g.cs @@ -52,5 +52,6 @@ public DeploymentListResponse( public DeploymentListResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.DeploymentListResponseObject.g.cs b/src/libs/Together/Generated/Together.Models.DeploymentListResponseObject.g.cs index fcb639c4..ed528488 100644 --- a/src/libs/Together/Generated/Together.Models.DeploymentListResponseObject.g.cs +++ b/src/libs/Together/Generated/Together.Models.DeploymentListResponseObject.g.cs @@ -14,5 +14,6 @@ public sealed partial class DeploymentListResponseObject /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.DeploymentLogs.g.cs b/src/libs/Together/Generated/Together.Models.DeploymentLogs.g.cs index 01d7f78d..b34eaaa8 100644 --- a/src/libs/Together/Generated/Together.Models.DeploymentLogs.g.cs +++ b/src/libs/Together/Generated/Together.Models.DeploymentLogs.g.cs @@ -39,5 +39,6 @@ public DeploymentLogs( public DeploymentLogs() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.DeploymentResponseItem.g.cs b/src/libs/Together/Generated/Together.Models.DeploymentResponseItem.g.cs index 3a3ac273..802a91c1 100644 --- a/src/libs/Together/Generated/Together.Models.DeploymentResponseItem.g.cs +++ b/src/libs/Together/Generated/Together.Models.DeploymentResponseItem.g.cs @@ -308,5 +308,6 @@ public DeploymentResponseItem( public DeploymentResponseItem() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.DeploymentResponseItemGpuType.g.cs b/src/libs/Together/Generated/Together.Models.DeploymentResponseItemGpuType.g.cs index 76a6889e..7f6886d2 100644 --- a/src/libs/Together/Generated/Together.Models.DeploymentResponseItemGpuType.g.cs +++ b/src/libs/Together/Generated/Together.Models.DeploymentResponseItemGpuType.g.cs @@ -11,7 +11,11 @@ public enum DeploymentResponseItemGpuType /// /// /// - A10080gb, + B200192gb, + /// + /// + /// + H10040gbMig, /// /// /// @@ -30,7 +34,8 @@ public static string ToValueString(this DeploymentResponseItemGpuType value) { return value switch { - DeploymentResponseItemGpuType.A10080gb => " a100-80gb", + DeploymentResponseItemGpuType.B200192gb => "b200-192gb", + DeploymentResponseItemGpuType.H10040gbMig => "h100-40gb-mig", DeploymentResponseItemGpuType.H10080gb => "h100-80gb", _ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null), }; @@ -42,7 +47,8 @@ public static string ToValueString(this DeploymentResponseItemGpuType value) { return value switch { - " a100-80gb" => DeploymentResponseItemGpuType.A10080gb, + "b200-192gb" => DeploymentResponseItemGpuType.B200192gb, + "h100-40gb-mig" => DeploymentResponseItemGpuType.H10040gbMig, "h100-80gb" => DeploymentResponseItemGpuType.H10080gb, _ => null, }; diff --git a/src/libs/Together/Generated/Together.Models.DeploymentResponseItemObject.g.cs b/src/libs/Together/Generated/Together.Models.DeploymentResponseItemObject.g.cs index ee48e8a6..413c3263 100644 --- a/src/libs/Together/Generated/Together.Models.DeploymentResponseItemObject.g.cs +++ b/src/libs/Together/Generated/Together.Models.DeploymentResponseItemObject.g.cs @@ -14,5 +14,6 @@ public sealed partial class DeploymentResponseItemObject /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.DeploymentResponseItemReplicaEvents.g.cs b/src/libs/Together/Generated/Together.Models.DeploymentResponseItemReplicaEvents.g.cs index 77894bec..409b67e4 100644 --- a/src/libs/Together/Generated/Together.Models.DeploymentResponseItemReplicaEvents.g.cs +++ b/src/libs/Together/Generated/Together.Models.DeploymentResponseItemReplicaEvents.g.cs @@ -14,5 +14,6 @@ public sealed partial class DeploymentResponseItemReplicaEvents /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.DisplayorExecuteOutput.g.cs b/src/libs/Together/Generated/Together.Models.DisplayorExecuteOutput.g.cs index fb76f0a5..70cad4a0 100644 --- a/src/libs/Together/Generated/Together.Models.DisplayorExecuteOutput.g.cs +++ b/src/libs/Together/Generated/Together.Models.DisplayorExecuteOutput.g.cs @@ -51,5 +51,6 @@ public DisplayorExecuteOutput( public DisplayorExecuteOutput() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.DisplayorExecuteOutputData.g.cs b/src/libs/Together/Generated/Together.Models.DisplayorExecuteOutputData.g.cs index df5c171c..647cefbe 100644 --- a/src/libs/Together/Generated/Together.Models.DisplayorExecuteOutputData.g.cs +++ b/src/libs/Together/Generated/Together.Models.DisplayorExecuteOutputData.g.cs @@ -156,5 +156,6 @@ public DisplayorExecuteOutputData( public DisplayorExecuteOutputData() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.DisplayorExecuteOutputDataApplicationGeoJson.g.cs b/src/libs/Together/Generated/Together.Models.DisplayorExecuteOutputDataApplicationGeoJson.g.cs index f66a1431..7e67ab7b 100644 --- a/src/libs/Together/Generated/Together.Models.DisplayorExecuteOutputDataApplicationGeoJson.g.cs +++ b/src/libs/Together/Generated/Together.Models.DisplayorExecuteOutputDataApplicationGeoJson.g.cs @@ -14,5 +14,6 @@ public sealed partial class DisplayorExecuteOutputDataApplicationGeoJson /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.DisplayorExecuteOutputDataApplicationJson.g.cs b/src/libs/Together/Generated/Together.Models.DisplayorExecuteOutputDataApplicationJson.g.cs index a8c0e24e..ff5e3dd6 100644 --- a/src/libs/Together/Generated/Together.Models.DisplayorExecuteOutputDataApplicationJson.g.cs +++ b/src/libs/Together/Generated/Together.Models.DisplayorExecuteOutputDataApplicationJson.g.cs @@ -14,5 +14,6 @@ public sealed partial class DisplayorExecuteOutputDataApplicationJson /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.DisplayorExecuteOutputDataApplicationVndVegaV5Json.g.cs b/src/libs/Together/Generated/Together.Models.DisplayorExecuteOutputDataApplicationVndVegaV5Json.g.cs index 78a4a937..eff7f3d3 100644 --- a/src/libs/Together/Generated/Together.Models.DisplayorExecuteOutputDataApplicationVndVegaV5Json.g.cs +++ b/src/libs/Together/Generated/Together.Models.DisplayorExecuteOutputDataApplicationVndVegaV5Json.g.cs @@ -14,5 +14,6 @@ public sealed partial class DisplayorExecuteOutputDataApplicationVndVegaV5Json /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.DisplayorExecuteOutputDataApplicationVndVegaliteV4Json.g.cs b/src/libs/Together/Generated/Together.Models.DisplayorExecuteOutputDataApplicationVndVegaliteV4Json.g.cs index e4fa8ee6..c3975f5c 100644 --- a/src/libs/Together/Generated/Together.Models.DisplayorExecuteOutputDataApplicationVndVegaliteV4Json.g.cs +++ b/src/libs/Together/Generated/Together.Models.DisplayorExecuteOutputDataApplicationVndVegaliteV4Json.g.cs @@ -14,5 +14,6 @@ public sealed partial class DisplayorExecuteOutputDataApplicationVndVegaliteV4Js /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.EmbeddingsRequest.g.cs b/src/libs/Together/Generated/Together.Models.EmbeddingsRequest.g.cs index b98c08ae..2946d0c9 100644 --- a/src/libs/Together/Generated/Together.Models.EmbeddingsRequest.g.cs +++ b/src/libs/Together/Generated/Together.Models.EmbeddingsRequest.g.cs @@ -60,5 +60,6 @@ public EmbeddingsRequest( public EmbeddingsRequest() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.EmbeddingsResponse.g.cs b/src/libs/Together/Generated/Together.Models.EmbeddingsResponse.g.cs index 53d8ebf4..8a0ebdb8 100644 --- a/src/libs/Together/Generated/Together.Models.EmbeddingsResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.EmbeddingsResponse.g.cs @@ -62,5 +62,6 @@ public EmbeddingsResponse( public EmbeddingsResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.EmbeddingsResponseDataItem.g.cs b/src/libs/Together/Generated/Together.Models.EmbeddingsResponseDataItem.g.cs index b792e170..1d7048cf 100644 --- a/src/libs/Together/Generated/Together.Models.EmbeddingsResponseDataItem.g.cs +++ b/src/libs/Together/Generated/Together.Models.EmbeddingsResponseDataItem.g.cs @@ -62,5 +62,6 @@ public EmbeddingsResponseDataItem( public EmbeddingsResponseDataItem() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.EmbeddingsResponseDataItemObject.g.cs b/src/libs/Together/Generated/Together.Models.EmbeddingsResponseDataItemObject.g.cs index cd7304b4..3299db9d 100644 --- a/src/libs/Together/Generated/Together.Models.EmbeddingsResponseDataItemObject.g.cs +++ b/src/libs/Together/Generated/Together.Models.EmbeddingsResponseDataItemObject.g.cs @@ -14,5 +14,6 @@ public sealed partial class EmbeddingsResponseDataItemObject /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.EmbeddingsResponseObject.g.cs b/src/libs/Together/Generated/Together.Models.EmbeddingsResponseObject.g.cs index e3d3237c..f68b4011 100644 --- a/src/libs/Together/Generated/Together.Models.EmbeddingsResponseObject.g.cs +++ b/src/libs/Together/Generated/Together.Models.EmbeddingsResponseObject.g.cs @@ -14,5 +14,6 @@ public sealed partial class EmbeddingsResponseObject /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.EndpointPricing.g.cs b/src/libs/Together/Generated/Together.Models.EndpointPricing.g.cs index 1bcac2bc..5104ae84 100644 --- a/src/libs/Together/Generated/Together.Models.EndpointPricing.g.cs +++ b/src/libs/Together/Generated/Together.Models.EndpointPricing.g.cs @@ -42,5 +42,6 @@ public EndpointPricing( public EndpointPricing() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.EnvironmentVariable.g.cs b/src/libs/Together/Generated/Together.Models.EnvironmentVariable.g.cs index 970b4b8c..2a022f1d 100644 --- a/src/libs/Together/Generated/Together.Models.EnvironmentVariable.g.cs +++ b/src/libs/Together/Generated/Together.Models.EnvironmentVariable.g.cs @@ -64,5 +64,6 @@ public EnvironmentVariable( public EnvironmentVariable() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.Error.g.cs b/src/libs/Together/Generated/Together.Models.Error.g.cs index dba9f9d7..4ae5f59a 100644 --- a/src/libs/Together/Generated/Together.Models.Error.g.cs +++ b/src/libs/Together/Generated/Together.Models.Error.g.cs @@ -26,6 +26,26 @@ namespace Together #endif public bool IsErrorVariant1 => ErrorVariant1 != null; + /// + /// + /// + public bool TryPickErrorVariant1( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out string? value) + { + value = ErrorVariant1; + return IsErrorVariant1; + } + + /// + /// + /// + public string PickErrorVariant1() => IsErrorVariant1 + ? ErrorVariant1! + : throw new global::System.InvalidOperationException($"Expected union variant 'ErrorVariant1' but the value was {ToString()}."); + /// /// /// @@ -42,6 +62,26 @@ namespace Together [global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(ErrorVariant2))] #endif public bool IsErrorVariant2 => ErrorVariant2 != null; + + /// + /// + /// + public bool TryPickErrorVariant2( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out object? value) + { + value = ErrorVariant2; + return IsErrorVariant2; + } + + /// + /// + /// + public object PickErrorVariant2() => IsErrorVariant2 + ? ErrorVariant2! + : throw new global::System.InvalidOperationException($"Expected union variant 'ErrorVariant2' but the value was {ToString()}."); /// /// /// @@ -60,6 +100,11 @@ public Error(string? value) ErrorVariant1 = value; } + /// + /// + /// + public static Error FromErrorVariant1(string? value) => new Error(value); + /// /// /// @@ -100,8 +145,8 @@ public bool Validate() /// /// public TResult? Match( - global::System.Func? errorVariant1 = null, - global::System.Func? errorVariant2 = null, + global::System.Func? errorVariant1 = null, + global::System.Func? errorVariant2 = null, bool validate = true) { if (validate) @@ -125,8 +170,32 @@ public bool Validate() /// /// public void Match( - global::System.Action? errorVariant1 = null, - global::System.Action? errorVariant2 = null, + global::System.Action? errorVariant1 = null, + + global::System.Action? errorVariant2 = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (IsErrorVariant1) + { + errorVariant1?.Invoke(ErrorVariant1!); + } + else if (IsErrorVariant2) + { + errorVariant2?.Invoke(ErrorVariant2!); + } + } + + /// + /// + /// + public void Switch( + global::System.Action? errorVariant1 = null, + global::System.Action? errorVariant2 = null, bool validate = true) { if (validate) diff --git a/src/libs/Together/Generated/Together.Models.ErrorData.g.cs b/src/libs/Together/Generated/Together.Models.ErrorData.g.cs index acd0abf4..96e422a7 100644 --- a/src/libs/Together/Generated/Together.Models.ErrorData.g.cs +++ b/src/libs/Together/Generated/Together.Models.ErrorData.g.cs @@ -40,5 +40,6 @@ public ErrorData( public ErrorData() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ErrorDataError.g.cs b/src/libs/Together/Generated/Together.Models.ErrorDataError.g.cs index c4ce48eb..eda89760 100644 --- a/src/libs/Together/Generated/Together.Models.ErrorDataError.g.cs +++ b/src/libs/Together/Generated/Together.Models.ErrorDataError.g.cs @@ -72,5 +72,6 @@ public ErrorDataError( public ErrorDataError() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ErrorOutput.g.cs b/src/libs/Together/Generated/Together.Models.ErrorOutput.g.cs index 1966688d..eb368114 100644 --- a/src/libs/Together/Generated/Together.Models.ErrorOutput.g.cs +++ b/src/libs/Together/Generated/Together.Models.ErrorOutput.g.cs @@ -50,5 +50,6 @@ public ErrorOutput( public ErrorOutput() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ErrorResponse.g.cs b/src/libs/Together/Generated/Together.Models.ErrorResponse.g.cs index d56be765..98eda9ab 100644 --- a/src/libs/Together/Generated/Together.Models.ErrorResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.ErrorResponse.g.cs @@ -48,5 +48,6 @@ public ErrorResponse( public ErrorResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ErrorVariant2.g.cs b/src/libs/Together/Generated/Together.Models.ErrorVariant2.g.cs index 666a139b..8d9af258 100644 --- a/src/libs/Together/Generated/Together.Models.ErrorVariant2.g.cs +++ b/src/libs/Together/Generated/Together.Models.ErrorVariant2.g.cs @@ -14,5 +14,6 @@ public sealed partial class ErrorVariant2 /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.EvaluationClassifyParameters.g.cs b/src/libs/Together/Generated/Together.Models.EvaluationClassifyParameters.g.cs index 409335eb..f1378731 100644 --- a/src/libs/Together/Generated/Together.Models.EvaluationClassifyParameters.g.cs +++ b/src/libs/Together/Generated/Together.Models.EvaluationClassifyParameters.g.cs @@ -95,5 +95,6 @@ public EvaluationClassifyParameters( public EvaluationClassifyParameters() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.EvaluationClassifyResults.g.cs b/src/libs/Together/Generated/Together.Models.EvaluationClassifyResults.g.cs index 1bdfcf19..9b200a89 100644 --- a/src/libs/Together/Generated/Together.Models.EvaluationClassifyResults.g.cs +++ b/src/libs/Together/Generated/Together.Models.EvaluationClassifyResults.g.cs @@ -114,5 +114,6 @@ public EvaluationClassifyResults( public EvaluationClassifyResults() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.EvaluationCompareParameters.g.cs b/src/libs/Together/Generated/Together.Models.EvaluationCompareParameters.g.cs index d07d6912..f36b0893 100644 --- a/src/libs/Together/Generated/Together.Models.EvaluationCompareParameters.g.cs +++ b/src/libs/Together/Generated/Together.Models.EvaluationCompareParameters.g.cs @@ -72,5 +72,6 @@ public EvaluationCompareParameters( public EvaluationCompareParameters() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.EvaluationCompareResults.g.cs b/src/libs/Together/Generated/Together.Models.EvaluationCompareResults.g.cs index c7a4b053..90cbfc31 100644 --- a/src/libs/Together/Generated/Together.Models.EvaluationCompareResults.g.cs +++ b/src/libs/Together/Generated/Together.Models.EvaluationCompareResults.g.cs @@ -113,5 +113,6 @@ public EvaluationCompareResults( public EvaluationCompareResults() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.EvaluationJob.g.cs b/src/libs/Together/Generated/Together.Models.EvaluationJob.g.cs index 4aeff591..3ebb4403 100644 --- a/src/libs/Together/Generated/Together.Models.EvaluationJob.g.cs +++ b/src/libs/Together/Generated/Together.Models.EvaluationJob.g.cs @@ -147,5 +147,6 @@ public EvaluationJob( public EvaluationJob() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.EvaluationJobParameters.g.cs b/src/libs/Together/Generated/Together.Models.EvaluationJobParameters.g.cs index 85ed4595..a5681e72 100644 --- a/src/libs/Together/Generated/Together.Models.EvaluationJobParameters.g.cs +++ b/src/libs/Together/Generated/Together.Models.EvaluationJobParameters.g.cs @@ -14,5 +14,6 @@ public sealed partial class EvaluationJobParameters /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.EvaluationJobResults.g.cs b/src/libs/Together/Generated/Together.Models.EvaluationJobResults.g.cs index 8ed7f34d..d3ea6f04 100644 --- a/src/libs/Together/Generated/Together.Models.EvaluationJobResults.g.cs +++ b/src/libs/Together/Generated/Together.Models.EvaluationJobResults.g.cs @@ -39,5 +39,6 @@ public EvaluationJobResults( public EvaluationJobResults() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.EvaluationJobStatusUpdate.g.cs b/src/libs/Together/Generated/Together.Models.EvaluationJobStatusUpdate.g.cs index 8026979f..1358b9d0 100644 --- a/src/libs/Together/Generated/Together.Models.EvaluationJobStatusUpdate.g.cs +++ b/src/libs/Together/Generated/Together.Models.EvaluationJobStatusUpdate.g.cs @@ -72,5 +72,6 @@ public EvaluationJobStatusUpdate( public EvaluationJobStatusUpdate() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.EvaluationJudgeModelConfig.g.cs b/src/libs/Together/Generated/Together.Models.EvaluationJudgeModelConfig.g.cs index 5684dc76..bcaa0914 100644 --- a/src/libs/Together/Generated/Together.Models.EvaluationJudgeModelConfig.g.cs +++ b/src/libs/Together/Generated/Together.Models.EvaluationJudgeModelConfig.g.cs @@ -46,6 +46,30 @@ public sealed partial class EvaluationJudgeModelConfig [global::System.Text.Json.Serialization.JsonPropertyName("external_base_url")] public string? ExternalBaseUrl { get; set; } + /// + /// Number of concurrent workers for inference requests. Overrides the default concurrency for this model. Useful for tuning throughput when using proxy endpoints (e.g. OpenRouter) or rate-limited external APIs.
+ /// Example: 5 + ///
+ /// 5 + [global::System.Text.Json.Serialization.JsonPropertyName("num_workers")] + public int? NumWorkers { get; set; } + + /// + /// Maximum number of tokens the judge model can generate. Defaults to 32768. Increase for reasoning models (e.g. Gemini, o-series) that consume output token budget for chain-of-thought.
+ /// Example: 8192 + ///
+ /// 8192 + [global::System.Text.Json.Serialization.JsonPropertyName("max_tokens")] + public int? MaxTokens { get; set; } + + /// + /// Sampling temperature for the judge model. Defaults to 0.05.
+ /// Example: 0.0 + ///
+ /// 0.0 + [global::System.Text.Json.Serialization.JsonPropertyName("temperature")] + public float? Temperature { get; set; } + /// /// Additional properties that are not explicitly defined in the schema /// @@ -72,6 +96,18 @@ public sealed partial class EvaluationJudgeModelConfig /// /// Base URL for external judge models. Must be OpenAI-compatible base URL. /// + /// + /// Number of concurrent workers for inference requests. Overrides the default concurrency for this model. Useful for tuning throughput when using proxy endpoints (e.g. OpenRouter) or rate-limited external APIs.
+ /// Example: 5 + /// + /// + /// Maximum number of tokens the judge model can generate. Defaults to 32768. Increase for reasoning models (e.g. Gemini, o-series) that consume output token budget for chain-of-thought.
+ /// Example: 8192 + /// + /// + /// Sampling temperature for the judge model. Defaults to 0.05.
+ /// Example: 0.0 + /// #if NET7_0_OR_GREATER [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] #endif @@ -80,13 +116,19 @@ public EvaluationJudgeModelConfig( string systemTemplate, global::Together.EvaluationJudgeModelConfigModelSource modelSource, string? externalApiToken, - string? externalBaseUrl) + string? externalBaseUrl, + int? numWorkers, + int? maxTokens, + float? temperature) { this.Model = model ?? throw new global::System.ArgumentNullException(nameof(model)); this.SystemTemplate = systemTemplate ?? throw new global::System.ArgumentNullException(nameof(systemTemplate)); this.ModelSource = modelSource; this.ExternalApiToken = externalApiToken; this.ExternalBaseUrl = externalBaseUrl; + this.NumWorkers = numWorkers; + this.MaxTokens = maxTokens; + this.Temperature = temperature; } /// @@ -95,5 +137,6 @@ public EvaluationJudgeModelConfig( public EvaluationJudgeModelConfig() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.EvaluationModelOrString.g.cs b/src/libs/Together/Generated/Together.Models.EvaluationModelOrString.g.cs index 09ea02e8..dbde27e0 100644 --- a/src/libs/Together/Generated/Together.Models.EvaluationModelOrString.g.cs +++ b/src/libs/Together/Generated/Together.Models.EvaluationModelOrString.g.cs @@ -26,6 +26,26 @@ namespace Together #endif public bool IsEvaluationModelOrStringVariant1 => EvaluationModelOrStringVariant1 != null; + /// + /// + /// + public bool TryPickEvaluationModelOrStringVariant1( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out string? value) + { + value = EvaluationModelOrStringVariant1; + return IsEvaluationModelOrStringVariant1; + } + + /// + /// + /// + public string PickEvaluationModelOrStringVariant1() => IsEvaluationModelOrStringVariant1 + ? EvaluationModelOrStringVariant1! + : throw new global::System.InvalidOperationException($"Expected union variant 'EvaluationModelOrStringVariant1' but the value was {ToString()}."); + /// /// /// @@ -42,6 +62,26 @@ namespace Together [global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(Request))] #endif public bool IsRequest => Request != null; + + /// + /// + /// + public bool TryPickRequest( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Together.EvaluationModelRequest? value) + { + value = Request; + return IsRequest; + } + + /// + /// + /// + public global::Together.EvaluationModelRequest PickRequest() => IsRequest + ? Request! + : throw new global::System.InvalidOperationException($"Expected union variant 'Request' but the value was {ToString()}."); /// /// /// @@ -60,6 +100,11 @@ public EvaluationModelOrString(string? value) EvaluationModelOrStringVariant1 = value; } + /// + /// + /// + public static EvaluationModelOrString FromEvaluationModelOrStringVariant1(string? value) => new EvaluationModelOrString(value); + /// /// /// @@ -78,6 +123,11 @@ public EvaluationModelOrString(global::Together.EvaluationModelRequest? value) Request = value; } + /// + /// + /// + public static EvaluationModelOrString FromRequest(global::Together.EvaluationModelRequest? value) => new EvaluationModelOrString(value); + /// /// /// @@ -118,8 +168,8 @@ public bool Validate() /// /// public TResult? Match( - global::System.Func? evaluationModelOrStringVariant1 = null, - global::System.Func? request = null, + global::System.Func? evaluationModelOrStringVariant1 = null, + global::System.Func? request = null, bool validate = true) { if (validate) @@ -143,8 +193,32 @@ public bool Validate() /// /// public void Match( - global::System.Action? evaluationModelOrStringVariant1 = null, - global::System.Action? request = null, + global::System.Action? evaluationModelOrStringVariant1 = null, + + global::System.Action? request = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (IsEvaluationModelOrStringVariant1) + { + evaluationModelOrStringVariant1?.Invoke(EvaluationModelOrStringVariant1!); + } + else if (IsRequest) + { + request?.Invoke(Request!); + } + } + + /// + /// + /// + public void Switch( + global::System.Action? evaluationModelOrStringVariant1 = null, + global::System.Action? request = null, bool validate = true) { if (validate) diff --git a/src/libs/Together/Generated/Together.Models.EvaluationModelRequest.g.cs b/src/libs/Together/Generated/Together.Models.EvaluationModelRequest.g.cs index 958f517f..b234b529 100644 --- a/src/libs/Together/Generated/Together.Models.EvaluationModelRequest.g.cs +++ b/src/libs/Together/Generated/Together.Models.EvaluationModelRequest.g.cs @@ -73,6 +73,14 @@ public sealed partial class EvaluationModelRequest [global::System.Text.Json.Serialization.JsonPropertyName("external_base_url")] public string? ExternalBaseUrl { get; set; } + /// + /// Number of concurrent workers for inference requests. Overrides the default concurrency for this model. Useful for tuning throughput when using proxy endpoints (e.g. OpenRouter) or rate-limited external APIs.
+ /// Example: 5 + ///
+ /// 5 + [global::System.Text.Json.Serialization.JsonPropertyName("num_workers")] + public int? NumWorkers { get; set; } + /// /// Additional properties that are not explicitly defined in the schema /// @@ -111,6 +119,10 @@ public sealed partial class EvaluationModelRequest /// /// Base URL for external models. Must be OpenAI-compatible base URL /// + /// + /// Number of concurrent workers for inference requests. Overrides the default concurrency for this model. Useful for tuning throughput when using proxy endpoints (e.g. OpenRouter) or rate-limited external APIs.
+ /// Example: 5 + /// #if NET7_0_OR_GREATER [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] #endif @@ -122,7 +134,8 @@ public EvaluationModelRequest( string inputTemplate, global::Together.EvaluationModelRequestModelSource modelSource, string? externalApiToken, - string? externalBaseUrl) + string? externalBaseUrl, + int? numWorkers) { this.Model = model ?? throw new global::System.ArgumentNullException(nameof(model)); this.MaxTokens = maxTokens; @@ -132,6 +145,7 @@ public EvaluationModelRequest( this.ModelSource = modelSource; this.ExternalApiToken = externalApiToken; this.ExternalBaseUrl = externalBaseUrl; + this.NumWorkers = numWorkers; } /// @@ -140,5 +154,6 @@ public EvaluationModelRequest( public EvaluationModelRequest() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.EvaluationResponse.g.cs b/src/libs/Together/Generated/Together.Models.EvaluationResponse.g.cs index e7050e43..9f1a23ce 100644 --- a/src/libs/Together/Generated/Together.Models.EvaluationResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.EvaluationResponse.g.cs @@ -56,5 +56,6 @@ public EvaluationResponse( public EvaluationResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.EvaluationScoreParameters.g.cs b/src/libs/Together/Generated/Together.Models.EvaluationScoreParameters.g.cs index b2e5c6ed..544f9048 100644 --- a/src/libs/Together/Generated/Together.Models.EvaluationScoreParameters.g.cs +++ b/src/libs/Together/Generated/Together.Models.EvaluationScoreParameters.g.cs @@ -110,5 +110,6 @@ public EvaluationScoreParameters( public EvaluationScoreParameters() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.EvaluationScoreResults.g.cs b/src/libs/Together/Generated/Together.Models.EvaluationScoreResults.g.cs index 4675204c..3ac58eaa 100644 --- a/src/libs/Together/Generated/Together.Models.EvaluationScoreResults.g.cs +++ b/src/libs/Together/Generated/Together.Models.EvaluationScoreResults.g.cs @@ -103,5 +103,6 @@ public EvaluationScoreResults( public EvaluationScoreResults() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.EvaluationScoreResultsAggregatedScores.g.cs b/src/libs/Together/Generated/Together.Models.EvaluationScoreResultsAggregatedScores.g.cs index 3a082425..4e7bf9ed 100644 --- a/src/libs/Together/Generated/Together.Models.EvaluationScoreResultsAggregatedScores.g.cs +++ b/src/libs/Together/Generated/Together.Models.EvaluationScoreResultsAggregatedScores.g.cs @@ -57,5 +57,6 @@ public EvaluationScoreResultsAggregatedScores( public EvaluationScoreResultsAggregatedScores() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.EvaluationTypedRequest.g.cs b/src/libs/Together/Generated/Together.Models.EvaluationTypedRequest.g.cs index e564ae1f..93957d50 100644 --- a/src/libs/Together/Generated/Together.Models.EvaluationTypedRequest.g.cs +++ b/src/libs/Together/Generated/Together.Models.EvaluationTypedRequest.g.cs @@ -59,5 +59,6 @@ public EvaluationTypedRequest( public EvaluationTypedRequest() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ExecuteRequest.g.cs b/src/libs/Together/Generated/Together.Models.ExecuteRequest.g.cs index e882a6dd..d3cfff73 100644 --- a/src/libs/Together/Generated/Together.Models.ExecuteRequest.g.cs +++ b/src/libs/Together/Generated/Together.Models.ExecuteRequest.g.cs @@ -18,13 +18,13 @@ public sealed partial class ExecuteRequest public required string Code { get; set; } /// - /// Files to upload to the session. If present, files will be uploaded before executing the given code. + /// Files to upload to the session. If present, files are uploaded before executing the given code. /// [global::System.Text.Json.Serialization.JsonPropertyName("files")] public global::System.Collections.Generic.IList? Files { get; set; } /// - /// Programming language for the code to execute. Currently only supports Python, but more will be added.
+ /// Programming language for the code to execute. Currently only supports Python.
/// Default Value: python ///
/// global::Together.ExecuteRequestLanguage.Python @@ -33,7 +33,7 @@ public sealed partial class ExecuteRequest public global::Together.ExecuteRequestLanguage Language { get; set; } = global::Together.ExecuteRequestLanguage.Python; /// - /// Identifier of the current session. Used to make follow-up calls. Requests will return an error if the session does not belong to the caller or has expired.
+ /// Identifier of the current session. Used to make follow-up calls. Returns an error if the session does not belong to the caller or has expired.
/// Example: ses_abcDEF123 ///
/// ses_abcDEF123 @@ -54,14 +54,14 @@ public sealed partial class ExecuteRequest /// Example: print('Hello, world!') /// /// - /// Files to upload to the session. If present, files will be uploaded before executing the given code. + /// Files to upload to the session. If present, files are uploaded before executing the given code. /// /// - /// Identifier of the current session. Used to make follow-up calls. Requests will return an error if the session does not belong to the caller or has expired.
+ /// Identifier of the current session. Used to make follow-up calls. Returns an error if the session does not belong to the caller or has expired.
/// Example: ses_abcDEF123 /// /// - /// Programming language for the code to execute. Currently only supports Python, but more will be added.
+ /// Programming language for the code to execute. Currently only supports Python.
/// Default Value: python /// #if NET7_0_OR_GREATER @@ -85,5 +85,18 @@ public ExecuteRequest( public ExecuteRequest() { } + + /// + /// Creates a new from its single non-const required field, + /// hardcoding any const discriminator fields. + /// + public static ExecuteRequest FromCode(string code) + { + return new ExecuteRequest + { + Code = code, + }; + } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ExecuteRequestFile.g.cs b/src/libs/Together/Generated/Together.Models.ExecuteRequestFile.g.cs index 194d7fc2..0f1bbd16 100644 --- a/src/libs/Together/Generated/Together.Models.ExecuteRequestFile.g.cs +++ b/src/libs/Together/Generated/Together.Models.ExecuteRequestFile.g.cs @@ -63,5 +63,6 @@ public ExecuteRequestFile( public ExecuteRequestFile() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ExecuteRequestLanguage.g.cs b/src/libs/Together/Generated/Together.Models.ExecuteRequestLanguage.g.cs index afe4a598..f42ee8b2 100644 --- a/src/libs/Together/Generated/Together.Models.ExecuteRequestLanguage.g.cs +++ b/src/libs/Together/Generated/Together.Models.ExecuteRequestLanguage.g.cs @@ -4,7 +4,7 @@ namespace Together { /// - /// Programming language for the code to execute. Currently only supports Python, but more will be added.
+ /// Programming language for the code to execute. Currently only supports Python.
/// Default Value: python ///
public enum ExecuteRequestLanguage diff --git a/src/libs/Together/Generated/Together.Models.ExecuteResponse.g.cs b/src/libs/Together/Generated/Together.Models.ExecuteResponse.g.cs index 6b57ef70..62994a4e 100644 --- a/src/libs/Together/Generated/Together.Models.ExecuteResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.ExecuteResponse.g.cs @@ -5,7 +5,7 @@ namespace Together { /// - /// The result of the execution. If successful, `data` contains the result and `errors` will be null. If unsuccessful, `data` will be null and `errors` will contain the errors. + /// The result of the execution. If successful, `data` contains the result and `errors` is null. If unsuccessful, `data` is null and `errors` contains the errors. /// public readonly partial struct ExecuteResponse : global::System.IEquatable { @@ -26,6 +26,26 @@ namespace Together #endif public bool IsSuccessfulExecution => SuccessfulExecution != null; + /// + /// + /// + public bool TryPickSuccessfulExecution( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Together.ExecuteResponseSuccessfulExecution? value) + { + value = SuccessfulExecution; + return IsSuccessfulExecution; + } + + /// + /// + /// + public global::Together.ExecuteResponseSuccessfulExecution PickSuccessfulExecution() => IsSuccessfulExecution + ? SuccessfulExecution! + : throw new global::System.InvalidOperationException($"Expected union variant 'SuccessfulExecution' but the value was {ToString()}."); + /// /// /// @@ -42,6 +62,26 @@ namespace Together [global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(FailedExecution))] #endif public bool IsFailedExecution => FailedExecution != null; + + /// + /// + /// + public bool TryPickFailedExecution( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Together.ExecuteResponseFailedExecution? value) + { + value = FailedExecution; + return IsFailedExecution; + } + + /// + /// + /// + public global::Together.ExecuteResponseFailedExecution PickFailedExecution() => IsFailedExecution + ? FailedExecution! + : throw new global::System.InvalidOperationException($"Expected union variant 'FailedExecution' but the value was {ToString()}."); /// /// /// @@ -60,6 +100,11 @@ public ExecuteResponse(global::Together.ExecuteResponseSuccessfulExecution? valu SuccessfulExecution = value; } + /// + /// + /// + public static ExecuteResponse FromSuccessfulExecution(global::Together.ExecuteResponseSuccessfulExecution? value) => new ExecuteResponse(value); + /// /// /// @@ -78,6 +123,11 @@ public ExecuteResponse(global::Together.ExecuteResponseFailedExecution? value) FailedExecution = value; } + /// + /// + /// + public static ExecuteResponse FromFailedExecution(global::Together.ExecuteResponseFailedExecution? value) => new ExecuteResponse(value); + /// /// /// @@ -118,8 +168,8 @@ public bool Validate() /// ///
public TResult? Match( - global::System.Func? successfulExecution = null, - global::System.Func? failedExecution = null, + global::System.Func? successfulExecution = null, + global::System.Func? failedExecution = null, bool validate = true) { if (validate) @@ -143,8 +193,32 @@ public bool Validate() /// /// public void Match( - global::System.Action? successfulExecution = null, - global::System.Action? failedExecution = null, + global::System.Action? successfulExecution = null, + + global::System.Action? failedExecution = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (IsSuccessfulExecution) + { + successfulExecution?.Invoke(SuccessfulExecution!); + } + else if (IsFailedExecution) + { + failedExecution?.Invoke(FailedExecution!); + } + } + + /// + /// + /// + public void Switch( + global::System.Action? successfulExecution = null, + global::System.Action? failedExecution = null, bool validate = true) { if (validate) diff --git a/src/libs/Together/Generated/Together.Models.ExecuteResponseFailedExecution.g.cs b/src/libs/Together/Generated/Together.Models.ExecuteResponseFailedExecution.g.cs index 93a6a9c4..25326d46 100644 --- a/src/libs/Together/Generated/Together.Models.ExecuteResponseFailedExecution.g.cs +++ b/src/libs/Together/Generated/Together.Models.ExecuteResponseFailedExecution.g.cs @@ -49,5 +49,6 @@ public ExecuteResponseFailedExecution( public ExecuteResponseFailedExecution() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ExecuteResponseFailedExecutionError.g.cs b/src/libs/Together/Generated/Together.Models.ExecuteResponseFailedExecutionError.g.cs index 58c6f4c7..26922a0f 100644 --- a/src/libs/Together/Generated/Together.Models.ExecuteResponseFailedExecutionError.g.cs +++ b/src/libs/Together/Generated/Together.Models.ExecuteResponseFailedExecutionError.g.cs @@ -14,5 +14,6 @@ public sealed partial class ExecuteResponseFailedExecutionError /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecution.g.cs b/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecution.g.cs index 11efd200..d742ae1a 100644 --- a/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecution.g.cs +++ b/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecution.g.cs @@ -49,5 +49,6 @@ public ExecuteResponseSuccessfulExecution( public ExecuteResponseSuccessfulExecution() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionData.g.cs b/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionData.g.cs index c1964471..d6b10f0b 100644 --- a/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionData.g.cs +++ b/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionData.g.cs @@ -67,5 +67,6 @@ public ExecuteResponseSuccessfulExecutionData( public ExecuteResponseSuccessfulExecutionData() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputDiscriminator.g.cs b/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputDiscriminator.g.cs index 7bb06cad..399812d3 100644 --- a/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputDiscriminator.g.cs +++ b/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputDiscriminator.g.cs @@ -12,7 +12,8 @@ public sealed partial class ExecuteResponseSuccessfulExecutionDataOutputDiscrimi /// /// [global::System.Text.Json.Serialization.JsonPropertyName("type")] - public string? Type { get; set; } + [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Together.JsonConverters.ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorTypeJsonConverter))] + public global::Together.ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorType? Type { get; set; } /// /// Additional properties that are not explicitly defined in the schema @@ -28,7 +29,7 @@ public sealed partial class ExecuteResponseSuccessfulExecutionDataOutputDiscrimi [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] #endif public ExecuteResponseSuccessfulExecutionDataOutputDiscriminator( - string? type) + global::Together.ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorType? type) { this.Type = type; } @@ -39,5 +40,6 @@ public ExecuteResponseSuccessfulExecutionDataOutputDiscriminator( public ExecuteResponseSuccessfulExecutionDataOutputDiscriminator() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorType.g.cs b/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorType.g.cs new file mode 100644 index 00000000..d7588258 --- /dev/null +++ b/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorType.g.cs @@ -0,0 +1,45 @@ + +#nullable enable + +namespace Together +{ + /// + /// + /// + public enum ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorType + { + /// + /// + /// + Error, + } + + /// + /// Enum extensions to do fast conversions without the reflection. + /// + public static class ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorTypeExtensions + { + /// + /// Converts an enum to a string. + /// + public static string ToValueString(this ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorType value) + { + return value switch + { + ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorType.Error => "error", + _ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null), + }; + } + /// + /// Converts an string to a enum. + /// + public static ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorType? ToEnum(string value) + { + return value switch + { + "error" => ExecuteResponseSuccessfulExecutionDataOutputDiscriminatorType.Error, + _ => null, + }; + } + } +} \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutput.g.cs b/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutput.g.cs index 2cf47920..18bee5ef 100644 --- a/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutput.g.cs +++ b/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutput.g.cs @@ -51,5 +51,6 @@ public ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutput( public ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutput() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutputData.g.cs b/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutputData.g.cs index 8661f1ad..16ac088e 100644 --- a/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutputData.g.cs +++ b/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutputData.g.cs @@ -156,5 +156,6 @@ public ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutputData( public ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutputData() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutputDataApplicationGeoJson.g.cs b/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutputDataApplicationGeoJson.g.cs index b8e4a196..da053a88 100644 --- a/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutputDataApplicationGeoJson.g.cs +++ b/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutputDataApplicationGeoJson.g.cs @@ -14,5 +14,6 @@ public sealed partial class ExecuteResponseSuccessfulExecutionDataOutputDisplayo /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutputDataApplicationJson.g.cs b/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutputDataApplicationJson.g.cs index 2c0b1853..01bd07db 100644 --- a/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutputDataApplicationJson.g.cs +++ b/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutputDataApplicationJson.g.cs @@ -14,5 +14,6 @@ public sealed partial class ExecuteResponseSuccessfulExecutionDataOutputDisplayo /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutputDataApplicationVndVegaV5Json.g.cs b/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutputDataApplicationVndVegaV5Json.g.cs index a66138e2..71b1312b 100644 --- a/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutputDataApplicationVndVegaV5Json.g.cs +++ b/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutputDataApplicationVndVegaV5Json.g.cs @@ -14,5 +14,6 @@ public sealed partial class ExecuteResponseSuccessfulExecutionDataOutputDisplayo /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutputDataApplicationVndVegaliteV4Json.g.cs b/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutputDataApplicationVndVegaliteV4Json.g.cs index 0e99d642..073cb257 100644 --- a/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutputDataApplicationVndVegaliteV4Json.g.cs +++ b/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutputDataApplicationVndVegaliteV4Json.g.cs @@ -14,5 +14,6 @@ public sealed partial class ExecuteResponseSuccessfulExecutionDataOutputDisplayo /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputErrorOutput.g.cs b/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputErrorOutput.g.cs index 090d511d..9fff3b67 100644 --- a/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputErrorOutput.g.cs +++ b/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputErrorOutput.g.cs @@ -50,5 +50,6 @@ public ExecuteResponseSuccessfulExecutionDataOutputErrorOutput( public ExecuteResponseSuccessfulExecutionDataOutputErrorOutput() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputStreamOutput.g.cs b/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputStreamOutput.g.cs index 688c2e44..7be51adc 100644 --- a/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputStreamOutput.g.cs +++ b/src/libs/Together/Generated/Together.Models.ExecuteResponseSuccessfulExecutionDataOutputStreamOutput.g.cs @@ -51,5 +51,6 @@ public ExecuteResponseSuccessfulExecutionDataOutputStreamOutput( public ExecuteResponseSuccessfulExecutionDataOutputStreamOutput() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.FileDeleteResponse.g.cs b/src/libs/Together/Generated/Together.Models.FileDeleteResponse.g.cs index 1dac40ee..2a4157e3 100644 --- a/src/libs/Together/Generated/Together.Models.FileDeleteResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.FileDeleteResponse.g.cs @@ -48,5 +48,6 @@ public FileDeleteResponse( public FileDeleteResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.FileInfo.g.cs b/src/libs/Together/Generated/Together.Models.FileInfo.g.cs index 492fe08b..5bd3435e 100644 --- a/src/libs/Together/Generated/Together.Models.FileInfo.g.cs +++ b/src/libs/Together/Generated/Together.Models.FileInfo.g.cs @@ -63,5 +63,6 @@ public FileInfo( public FileInfo() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.FileList.g.cs b/src/libs/Together/Generated/Together.Models.FileList.g.cs index 1c18065c..5c4decd2 100644 --- a/src/libs/Together/Generated/Together.Models.FileList.g.cs +++ b/src/libs/Together/Generated/Together.Models.FileList.g.cs @@ -40,5 +40,6 @@ public FileList( public FileList() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.FilePurpose.g.cs b/src/libs/Together/Generated/Together.Models.FilePurpose.g.cs index e288dd79..64852c54 100644 --- a/src/libs/Together/Generated/Together.Models.FilePurpose.g.cs +++ b/src/libs/Together/Generated/Together.Models.FilePurpose.g.cs @@ -16,26 +16,10 @@ public enum FilePurpose /// /// /// - BatchGenerated, - /// - /// - /// Eval, /// /// /// - EvalOutput, - /// - /// - /// - EvalSample, - /// - /// - /// - EvalSummary, - /// - /// - /// FineTune, } @@ -52,11 +36,7 @@ public static string ToValueString(this FilePurpose value) return value switch { FilePurpose.BatchApi => "batch-api", - FilePurpose.BatchGenerated => "batch-generated", FilePurpose.Eval => "eval", - FilePurpose.EvalOutput => "eval-output", - FilePurpose.EvalSample => "eval-sample", - FilePurpose.EvalSummary => "eval-summary", FilePurpose.FineTune => "fine-tune", _ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null), }; @@ -69,11 +49,7 @@ public static string ToValueString(this FilePurpose value) return value switch { "batch-api" => FilePurpose.BatchApi, - "batch-generated" => FilePurpose.BatchGenerated, "eval" => FilePurpose.Eval, - "eval-output" => FilePurpose.EvalOutput, - "eval-sample" => FilePurpose.EvalSample, - "eval-summary" => FilePurpose.EvalSummary, "fine-tune" => FilePurpose.FineTune, _ => null, }; diff --git a/src/libs/Together/Generated/Together.Models.FileResponse.g.cs b/src/libs/Together/Generated/Together.Models.FileResponse.g.cs index 08a2437f..a98f2dad 100644 --- a/src/libs/Together/Generated/Together.Models.FileResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.FileResponse.g.cs @@ -140,5 +140,6 @@ public FileResponse( public FileResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.FileResponseObject.g.cs b/src/libs/Together/Generated/Together.Models.FileResponseObject.g.cs index d4098a8b..b08ea65e 100644 --- a/src/libs/Together/Generated/Together.Models.FileResponseObject.g.cs +++ b/src/libs/Together/Generated/Together.Models.FileResponseObject.g.cs @@ -14,5 +14,6 @@ public sealed partial class FileResponseObject /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.FineTuneCheckpoint.g.cs b/src/libs/Together/Generated/Together.Models.FineTuneCheckpoint.g.cs index a48cf282..339ca0a4 100644 --- a/src/libs/Together/Generated/Together.Models.FineTuneCheckpoint.g.cs +++ b/src/libs/Together/Generated/Together.Models.FineTuneCheckpoint.g.cs @@ -70,5 +70,6 @@ public FineTuneCheckpoint( public FineTuneCheckpoint() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.FineTuneEvent.g.cs b/src/libs/Together/Generated/Together.Models.FineTuneEvent.g.cs index d26ebee2..a2bf192b 100644 --- a/src/libs/Together/Generated/Together.Models.FineTuneEvent.g.cs +++ b/src/libs/Together/Generated/Together.Models.FineTuneEvent.g.cs @@ -173,5 +173,6 @@ public FineTuneEvent( public FineTuneEvent() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.FineTuneEventObject.g.cs b/src/libs/Together/Generated/Together.Models.FineTuneEventObject.g.cs index b104c2f4..62831464 100644 --- a/src/libs/Together/Generated/Together.Models.FineTuneEventObject.g.cs +++ b/src/libs/Together/Generated/Together.Models.FineTuneEventObject.g.cs @@ -14,5 +14,6 @@ public sealed partial class FineTuneEventObject /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.FineTuneModelLimits.g.cs b/src/libs/Together/Generated/Together.Models.FineTuneModelLimits.g.cs index 1e530e0e..f87d7b87 100644 --- a/src/libs/Together/Generated/Together.Models.FineTuneModelLimits.g.cs +++ b/src/libs/Together/Generated/Together.Models.FineTuneModelLimits.g.cs @@ -160,5 +160,6 @@ public FineTuneModelLimits( public FineTuneModelLimits() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.FineTuneModelLimitsFullTraining.g.cs b/src/libs/Together/Generated/Together.Models.FineTuneModelLimitsFullTraining.g.cs index 5e21f90a..9938747a 100644 --- a/src/libs/Together/Generated/Together.Models.FineTuneModelLimitsFullTraining.g.cs +++ b/src/libs/Together/Generated/Together.Models.FineTuneModelLimitsFullTraining.g.cs @@ -66,5 +66,6 @@ public FineTuneModelLimitsFullTraining( public FineTuneModelLimitsFullTraining() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.FineTuneModelLimitsLoraTraining.g.cs b/src/libs/Together/Generated/Together.Models.FineTuneModelLimitsLoraTraining.g.cs index 3ff5f60e..8122a82b 100644 --- a/src/libs/Together/Generated/Together.Models.FineTuneModelLimitsLoraTraining.g.cs +++ b/src/libs/Together/Generated/Together.Models.FineTuneModelLimitsLoraTraining.g.cs @@ -90,5 +90,6 @@ public FineTuneModelLimitsLoraTraining( public FineTuneModelLimitsLoraTraining() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.FineTuneProgress.g.cs b/src/libs/Together/Generated/Together.Models.FineTuneProgress.g.cs index 39eb6051..8fac0eaf 100644 --- a/src/libs/Together/Generated/Together.Models.FineTuneProgress.g.cs +++ b/src/libs/Together/Generated/Together.Models.FineTuneProgress.g.cs @@ -54,5 +54,6 @@ public FineTuneProgress( public FineTuneProgress() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.FinetuneDeleteResponse.g.cs b/src/libs/Together/Generated/Together.Models.FinetuneDeleteResponse.g.cs index 60b9f3f4..707880e2 100644 --- a/src/libs/Together/Generated/Together.Models.FinetuneDeleteResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.FinetuneDeleteResponse.g.cs @@ -41,5 +41,6 @@ public FinetuneDeleteResponse( public FinetuneDeleteResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.FinetuneListCheckpoints.g.cs b/src/libs/Together/Generated/Together.Models.FinetuneListCheckpoints.g.cs index 598a381b..49baf958 100644 --- a/src/libs/Together/Generated/Together.Models.FinetuneListCheckpoints.g.cs +++ b/src/libs/Together/Generated/Together.Models.FinetuneListCheckpoints.g.cs @@ -40,5 +40,6 @@ public FinetuneListCheckpoints( public FinetuneListCheckpoints() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.FinetuneListEvents.g.cs b/src/libs/Together/Generated/Together.Models.FinetuneListEvents.g.cs index 917092b3..f58159d7 100644 --- a/src/libs/Together/Generated/Together.Models.FinetuneListEvents.g.cs +++ b/src/libs/Together/Generated/Together.Models.FinetuneListEvents.g.cs @@ -40,5 +40,6 @@ public FinetuneListEvents( public FinetuneListEvents() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.FinetuneResponse.g.cs b/src/libs/Together/Generated/Together.Models.FinetuneResponse.g.cs index d3042134..ecafb034 100644 --- a/src/libs/Together/Generated/Together.Models.FinetuneResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.FinetuneResponse.g.cs @@ -394,5 +394,6 @@ public FinetuneResponse( public FinetuneResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.FinetuneResponseTruncated.g.cs b/src/libs/Together/Generated/Together.Models.FinetuneResponseTruncated.g.cs index cbef880d..38a96107 100644 --- a/src/libs/Together/Generated/Together.Models.FinetuneResponseTruncated.g.cs +++ b/src/libs/Together/Generated/Together.Models.FinetuneResponseTruncated.g.cs @@ -45,7 +45,7 @@ public sealed partial class FinetuneResponseTruncated public global::System.DateTime? StartedAt { get; set; } /// - /// Identifier for the user who created the job + /// Identifier for who created the job. /// [global::System.Text.Json.Serialization.JsonPropertyName("user_id")] public string? UserId { get; set; } @@ -92,6 +92,12 @@ public sealed partial class FinetuneResponseTruncated [global::System.Text.Json.Serialization.JsonPropertyName("packing")] public bool? Packing { get; set; } + /// + /// Maximum sequence length to use for training. If not specified, uses the maximum allowed for the model and training method. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("max_seq_length")] + public int? MaxSeqLength { get; set; } + /// /// Base model used for fine-tuning /// @@ -243,7 +249,7 @@ public sealed partial class FinetuneResponseTruncated /// Start timestamp of the current stage of the fine-tune job /// /// - /// Identifier for the user who created the job + /// Identifier for who created the job. /// /// /// Owner address information @@ -266,6 +272,9 @@ public sealed partial class FinetuneResponseTruncated /// /// Whether sequence packing is being used for training. /// + /// + /// Maximum sequence length to use for training. If not specified, uses the maximum allowed for the model and training method. + /// /// /// Base model used for fine-tuning /// @@ -344,6 +353,7 @@ public FinetuneResponseTruncated( string? trainingFile, string? validationFile, bool? packing, + int? maxSeqLength, string? model, string? modelOutputName, string? suffix, @@ -379,6 +389,7 @@ public FinetuneResponseTruncated( this.TrainingFile = trainingFile; this.ValidationFile = validationFile; this.Packing = packing; + this.MaxSeqLength = maxSeqLength; this.Model = model; this.ModelOutputName = modelOutputName; this.Suffix = suffix; @@ -408,5 +419,6 @@ public FinetuneResponseTruncated( public FinetuneResponseTruncated() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.FinetuneTruncatedList.g.cs b/src/libs/Together/Generated/Together.Models.FinetuneTruncatedList.g.cs index 3f814355..2d585be0 100644 --- a/src/libs/Together/Generated/Together.Models.FinetuneTruncatedList.g.cs +++ b/src/libs/Together/Generated/Together.Models.FinetuneTruncatedList.g.cs @@ -40,5 +40,6 @@ public FinetuneTruncatedList( public FinetuneTruncatedList() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.FullTrainingType.g.cs b/src/libs/Together/Generated/Together.Models.FullTrainingType.g.cs index 3306d0bc..2c28a1ee 100644 --- a/src/libs/Together/Generated/Together.Models.FullTrainingType.g.cs +++ b/src/libs/Together/Generated/Together.Models.FullTrainingType.g.cs @@ -40,5 +40,6 @@ public FullTrainingType( public FullTrainingType() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GPUClusterControlPlaneNode.g.cs b/src/libs/Together/Generated/Together.Models.GPUClusterControlPlaneNode.g.cs index 076e1787..e0482c83 100644 --- a/src/libs/Together/Generated/Together.Models.GPUClusterControlPlaneNode.g.cs +++ b/src/libs/Together/Generated/Together.Models.GPUClusterControlPlaneNode.g.cs @@ -100,5 +100,6 @@ public GPUClusterControlPlaneNode( public GPUClusterControlPlaneNode() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GPUClusterCreateRequest.g.cs b/src/libs/Together/Generated/Together.Models.GPUClusterCreateRequest.g.cs index fb1a7540..072b5c43 100644 --- a/src/libs/Together/Generated/Together.Models.GPUClusterCreateRequest.g.cs +++ b/src/libs/Together/Generated/Together.Models.GPUClusterCreateRequest.g.cs @@ -50,14 +50,6 @@ public sealed partial class GPUClusterCreateRequest [global::System.Text.Json.Serialization.JsonPropertyName("duration_days")] public int? DurationDays { get; set; } - /// - /// NVIDIA driver version to use in the cluster. - /// - [global::System.Text.Json.Serialization.JsonPropertyName("driver_version")] - [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Together.JsonConverters.GPUClusterCreateRequestDriverVersionJsonConverter))] - [global::System.Text.Json.Serialization.JsonRequired] - public required global::Together.GPUClusterCreateRequestDriverVersion DriverVersion { get; set; } - /// /// Inline configuration to create a shared volume with the cluster creation. /// @@ -72,13 +64,85 @@ public sealed partial class GPUClusterCreateRequest /// /// RESERVED billing types allow you to specify the duration of the cluster reservation via the duration_days field.
- /// ON_DEMAND billing types will give you ownership of the cluster until you delete it. + /// ON_DEMAND billing types will give you ownership of the cluster until you delete it.
+ /// SCHEDULED_CAPACITY billing types allow you to reserve capacity for a scheduled time window. You must specify the reservation_start_time and reservation_end_time with this request. ///
[global::System.Text.Json.Serialization.JsonPropertyName("billing_type")] [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Together.JsonConverters.GPUClusterCreateRequestBillingTypeJsonConverter))] [global::System.Text.Json.Serialization.JsonRequired] public required global::Together.GPUClusterCreateRequestBillingType BillingType { get; set; } + /// + /// Whether automated GPU node failover should be enabled for this cluster. By default, it is disabled.
+ /// Default Value: false + ///
+ [global::System.Text.Json.Serialization.JsonPropertyName("gpu_node_failover_enabled")] + public bool? GpuNodeFailoverEnabled { get; set; } + + /// + /// Whether GPU cluster should be auto-scaled based on the workload. By default, it is not auto-scaled.
+ /// Default Value: false + ///
+ [global::System.Text.Json.Serialization.JsonPropertyName("auto_scaled")] + public bool? AutoScaled { get; set; } + + /// + /// Maximum number of GPUs to which the cluster can be auto-scaled up. This field is required if auto_scaled is true. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("auto_scale_max_gpus")] + public int? AutoScaleMaxGpus { get; set; } + + /// + /// Shared memory size in GiB for Slurm cluster. This field is required if cluster_type is SLURM. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("slurm_shm_size_gib")] + public int? SlurmShmSizeGib { get; set; } + + /// + /// ID of the capacity pool to use for the cluster. This field is optional and only applicable if the cluster is created from a capacity pool. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("capacity_pool_id")] + public string? CapacityPoolId { get; set; } + + /// + /// Reservation start time of the cluster. This field is required for SCHEDULED billing to specify the reservation start time for the cluster. If not provided, the cluster provisions immediately. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("reservation_start_time")] + public global::System.DateTime? ReservationStartTime { get; set; } + + /// + /// Reservation end time of the cluster. This field is required for SCHEDULED billing to specify the reservation end time for the cluster. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("reservation_end_time")] + public global::System.DateTime? ReservationEndTime { get; set; } + + /// + /// Whether to install Traefik ingress controller in the cluster. This field is only applicable for Kubernetes clusters and is false by default.
+ /// Default Value: false + ///
+ [global::System.Text.Json.Serialization.JsonPropertyName("install_traefik")] + public bool? InstallTraefik { get; set; } + + /// + /// CUDA version for this cluster. For example, 12.5 + /// + [global::System.Text.Json.Serialization.JsonPropertyName("cuda_version")] + [global::System.Text.Json.Serialization.JsonRequired] + public required string CudaVersion { get; set; } + + /// + /// Nvidia driver version for this cluster. For example, 550. Only some combination of cuda_version and nvidia_driver_version are supported. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("nvidia_driver_version")] + [global::System.Text.Json.Serialization.JsonRequired] + public required string NvidiaDriverVersion { get; set; } + + /// + /// Custom Slurm image for Slurm clusters. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("slurm_image")] + public string? SlurmImage { get; set; } + /// /// Additional properties that are not explicitly defined in the schema /// @@ -100,12 +164,16 @@ public sealed partial class GPUClusterCreateRequest /// /// Name of the GPU cluster. /// - /// - /// NVIDIA driver version to use in the cluster. - /// /// /// RESERVED billing types allow you to specify the duration of the cluster reservation via the duration_days field.
- /// ON_DEMAND billing types will give you ownership of the cluster until you delete it. + /// ON_DEMAND billing types will give you ownership of the cluster until you delete it.
+ /// SCHEDULED_CAPACITY billing types allow you to reserve capacity for a scheduled time window. You must specify the reservation_start_time and reservation_end_time with this request. + /// + /// + /// CUDA version for this cluster. For example, 12.5 + /// + /// + /// Nvidia driver version for this cluster. For example, 550. Only some combination of cuda_version and nvidia_driver_version are supported. /// /// /// Type of cluster to create. @@ -119,6 +187,36 @@ public sealed partial class GPUClusterCreateRequest /// /// ID of an existing volume to use with the cluster creation. /// + /// + /// Whether automated GPU node failover should be enabled for this cluster. By default, it is disabled.
+ /// Default Value: false + /// + /// + /// Whether GPU cluster should be auto-scaled based on the workload. By default, it is not auto-scaled.
+ /// Default Value: false + /// + /// + /// Maximum number of GPUs to which the cluster can be auto-scaled up. This field is required if auto_scaled is true. + /// + /// + /// Shared memory size in GiB for Slurm cluster. This field is required if cluster_type is SLURM. + /// + /// + /// ID of the capacity pool to use for the cluster. This field is optional and only applicable if the cluster is created from a capacity pool. + /// + /// + /// Reservation start time of the cluster. This field is required for SCHEDULED billing to specify the reservation start time for the cluster. If not provided, the cluster provisions immediately. + /// + /// + /// Reservation end time of the cluster. This field is required for SCHEDULED billing to specify the reservation end time for the cluster. + /// + /// + /// Whether to install Traefik ingress controller in the cluster. This field is only applicable for Kubernetes clusters and is false by default.
+ /// Default Value: false + /// + /// + /// Custom Slurm image for Slurm clusters. + /// #if NET7_0_OR_GREATER [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] #endif @@ -127,12 +225,22 @@ public GPUClusterCreateRequest( global::Together.GPUClusterCreateRequestGpuType gpuType, int numGpus, string clusterName, - global::Together.GPUClusterCreateRequestDriverVersion driverVersion, global::Together.GPUClusterCreateRequestBillingType billingType, + string cudaVersion, + string nvidiaDriverVersion, global::Together.GPUClusterCreateRequestClusterType? clusterType, int? durationDays, global::Together.GPUClustersSharedVolumeCreateRequest? sharedVolume, - string? volumeId) + string? volumeId, + bool? gpuNodeFailoverEnabled, + bool? autoScaled, + int? autoScaleMaxGpus, + int? slurmShmSizeGib, + string? capacityPoolId, + global::System.DateTime? reservationStartTime, + global::System.DateTime? reservationEndTime, + bool? installTraefik, + string? slurmImage) { this.ClusterType = clusterType; this.Region = region ?? throw new global::System.ArgumentNullException(nameof(region)); @@ -140,10 +248,20 @@ public GPUClusterCreateRequest( this.NumGpus = numGpus; this.ClusterName = clusterName ?? throw new global::System.ArgumentNullException(nameof(clusterName)); this.DurationDays = durationDays; - this.DriverVersion = driverVersion; this.SharedVolume = sharedVolume; this.VolumeId = volumeId; this.BillingType = billingType; + this.GpuNodeFailoverEnabled = gpuNodeFailoverEnabled; + this.AutoScaled = autoScaled; + this.AutoScaleMaxGpus = autoScaleMaxGpus; + this.SlurmShmSizeGib = slurmShmSizeGib; + this.CapacityPoolId = capacityPoolId; + this.ReservationStartTime = reservationStartTime; + this.ReservationEndTime = reservationEndTime; + this.InstallTraefik = installTraefik; + this.CudaVersion = cudaVersion ?? throw new global::System.ArgumentNullException(nameof(cudaVersion)); + this.NvidiaDriverVersion = nvidiaDriverVersion ?? throw new global::System.ArgumentNullException(nameof(nvidiaDriverVersion)); + this.SlurmImage = slurmImage; } /// @@ -152,5 +270,6 @@ public GPUClusterCreateRequest( public GPUClusterCreateRequest() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GPUClusterCreateRequestBillingType.g.cs b/src/libs/Together/Generated/Together.Models.GPUClusterCreateRequestBillingType.g.cs index 02d6a5d0..12159647 100644 --- a/src/libs/Together/Generated/Together.Models.GPUClusterCreateRequestBillingType.g.cs +++ b/src/libs/Together/Generated/Together.Models.GPUClusterCreateRequestBillingType.g.cs @@ -5,7 +5,8 @@ namespace Together { /// /// RESERVED billing types allow you to specify the duration of the cluster reservation via the duration_days field.
- /// ON_DEMAND billing types will give you ownership of the cluster until you delete it. + /// ON_DEMAND billing types will give you ownership of the cluster until you delete it.
+ /// SCHEDULED_CAPACITY billing types allow you to reserve capacity for a scheduled time window. You must specify the reservation_start_time and reservation_end_time with this request. ///
public enum GPUClusterCreateRequestBillingType { @@ -17,6 +18,10 @@ public enum GPUClusterCreateRequestBillingType /// ///
Reserved, + /// + /// + /// + ScheduledCapacity, } /// @@ -33,6 +38,7 @@ public static string ToValueString(this GPUClusterCreateRequestBillingType value { GPUClusterCreateRequestBillingType.OnDemand => "ON_DEMAND", GPUClusterCreateRequestBillingType.Reserved => "RESERVED", + GPUClusterCreateRequestBillingType.ScheduledCapacity => "SCHEDULED_CAPACITY", _ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null), }; } @@ -45,6 +51,7 @@ public static string ToValueString(this GPUClusterCreateRequestBillingType value { "ON_DEMAND" => GPUClusterCreateRequestBillingType.OnDemand, "RESERVED" => GPUClusterCreateRequestBillingType.Reserved, + "SCHEDULED_CAPACITY" => GPUClusterCreateRequestBillingType.ScheduledCapacity, _ => null, }; } diff --git a/src/libs/Together/Generated/Together.Models.GPUClusterCreateRequestDriverVersion.g.cs b/src/libs/Together/Generated/Together.Models.GPUClusterCreateRequestDriverVersion.g.cs deleted file mode 100644 index f54512fc..00000000 --- a/src/libs/Together/Generated/Together.Models.GPUClusterCreateRequestDriverVersion.g.cs +++ /dev/null @@ -1,63 +0,0 @@ - -#nullable enable - -namespace Together -{ - /// - /// NVIDIA driver version to use in the cluster. - /// - public enum GPUClusterCreateRequestDriverVersion - { - /// - /// - /// - Cuda125555, - /// - /// - /// - Cuda126560, - /// - /// - /// - Cuda126565, - /// - /// - /// - Cuda128570, - } - - /// - /// Enum extensions to do fast conversions without the reflection. - /// - public static class GPUClusterCreateRequestDriverVersionExtensions - { - /// - /// Converts an enum to a string. - /// - public static string ToValueString(this GPUClusterCreateRequestDriverVersion value) - { - return value switch - { - GPUClusterCreateRequestDriverVersion.Cuda125555 => "CUDA_12_5_555", - GPUClusterCreateRequestDriverVersion.Cuda126560 => "CUDA_12_6_560", - GPUClusterCreateRequestDriverVersion.Cuda126565 => "CUDA_12_6_565", - GPUClusterCreateRequestDriverVersion.Cuda128570 => "CUDA_12_8_570", - _ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null), - }; - } - /// - /// Converts an string to a enum. - /// - public static GPUClusterCreateRequestDriverVersion? ToEnum(string value) - { - return value switch - { - "CUDA_12_5_555" => GPUClusterCreateRequestDriverVersion.Cuda125555, - "CUDA_12_6_560" => GPUClusterCreateRequestDriverVersion.Cuda126560, - "CUDA_12_6_565" => GPUClusterCreateRequestDriverVersion.Cuda126565, - "CUDA_12_8_570" => GPUClusterCreateRequestDriverVersion.Cuda128570, - _ => null, - }; - } - } -} \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GPUClusterGPUWorkerNode.g.cs b/src/libs/Together/Generated/Together.Models.GPUClusterGPUWorkerNode.g.cs index 323ececb..9d9614a4 100644 --- a/src/libs/Together/Generated/Together.Models.GPUClusterGPUWorkerNode.g.cs +++ b/src/libs/Together/Generated/Together.Models.GPUClusterGPUWorkerNode.g.cs @@ -64,6 +64,12 @@ public sealed partial class GPUClusterGPUWorkerNode [global::System.Text.Json.Serialization.JsonRequired] public required global::System.Collections.Generic.IList Networks { get; set; } + /// + /// + /// + [global::System.Text.Json.Serialization.JsonPropertyName("instance_id")] + public string? InstanceId { get; set; } + /// /// Additional properties that are not explicitly defined in the schema /// @@ -81,6 +87,7 @@ public sealed partial class GPUClusterGPUWorkerNode /// /// /// + /// #if NET7_0_OR_GREATER [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] #endif @@ -92,7 +99,8 @@ public GPUClusterGPUWorkerNode( int numCpuCores, int numGpus, double memoryGib, - global::System.Collections.Generic.IList networks) + global::System.Collections.Generic.IList networks, + string? instanceId) { this.NodeId = nodeId ?? throw new global::System.ArgumentNullException(nameof(nodeId)); this.NodeName = nodeName ?? throw new global::System.ArgumentNullException(nameof(nodeName)); @@ -102,6 +110,7 @@ public GPUClusterGPUWorkerNode( this.NumGpus = numGpus; this.MemoryGib = memoryGib; this.Networks = networks ?? throw new global::System.ArgumentNullException(nameof(networks)); + this.InstanceId = instanceId; } /// @@ -110,5 +119,6 @@ public GPUClusterGPUWorkerNode( public GPUClusterGPUWorkerNode() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GPUClusterInfo.g.cs b/src/libs/Together/Generated/Together.Models.GPUClusterInfo.g.cs index 633db0df..20c70b67 100644 --- a/src/libs/Together/Generated/Together.Models.GPUClusterInfo.g.cs +++ b/src/libs/Together/Generated/Together.Models.GPUClusterInfo.g.cs @@ -49,16 +49,7 @@ public sealed partial class GPUClusterInfo /// /// [global::System.Text.Json.Serialization.JsonPropertyName("duration_hours")] - [global::System.Text.Json.Serialization.JsonRequired] - public required int DurationHours { get; set; } - - /// - /// - /// - [global::System.Text.Json.Serialization.JsonPropertyName("driver_version")] - [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Together.JsonConverters.GPUClusterInfoDriverVersionJsonConverter))] - [global::System.Text.Json.Serialization.JsonRequired] - public required global::Together.GPUClusterInfoDriverVersion DriverVersion { get; set; } + public int? DurationHours { get; set; } /// /// @@ -103,6 +94,56 @@ public sealed partial class GPUClusterInfo [global::System.Text.Json.Serialization.JsonRequired] public required int NumGpus { get; set; } + /// + /// + /// + [global::System.Text.Json.Serialization.JsonPropertyName("slurm_shm_size_gib")] + public int? SlurmShmSizeGib { get; set; } + + /// + /// + /// + [global::System.Text.Json.Serialization.JsonPropertyName("capacity_pool_id")] + public string? CapacityPoolId { get; set; } + + /// + /// + /// + [global::System.Text.Json.Serialization.JsonPropertyName("reservation_start_time")] + public global::System.DateTime? ReservationStartTime { get; set; } + + /// + /// + /// + [global::System.Text.Json.Serialization.JsonPropertyName("reservation_end_time")] + public global::System.DateTime? ReservationEndTime { get; set; } + + /// + /// + /// + [global::System.Text.Json.Serialization.JsonPropertyName("install_traefik")] + public bool? InstallTraefik { get; set; } + + /// + /// + /// + [global::System.Text.Json.Serialization.JsonPropertyName("cuda_version")] + [global::System.Text.Json.Serialization.JsonRequired] + public required string CudaVersion { get; set; } + + /// + /// + /// + [global::System.Text.Json.Serialization.JsonPropertyName("nvidia_driver_version")] + [global::System.Text.Json.Serialization.JsonRequired] + public required string NvidiaDriverVersion { get; set; } + + /// + /// + /// + [global::System.Text.Json.Serialization.JsonPropertyName("created_at")] + public global::System.DateTime? CreatedAt { get; set; } + /// /// Additional properties that are not explicitly defined in the schema /// @@ -119,8 +160,6 @@ public sealed partial class GPUClusterInfo /// /// /// - /// - /// /// /// /// Current status of the GPU cluster. @@ -129,6 +168,15 @@ public sealed partial class GPUClusterInfo /// /// /// + /// + /// + /// + /// + /// + /// + /// + /// + /// #if NET7_0_OR_GREATER [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] #endif @@ -138,14 +186,21 @@ public GPUClusterInfo( string region, global::Together.GPUClusterInfoGpuType gpuType, string clusterName, - int durationHours, - global::Together.GPUClusterInfoDriverVersion driverVersion, global::System.Collections.Generic.IList volumes, global::Together.GPUClusterInfoStatus status, global::System.Collections.Generic.IList controlPlaneNodes, global::System.Collections.Generic.IList gpuWorkerNodes, string kubeConfig, - int numGpus) + int numGpus, + string cudaVersion, + string nvidiaDriverVersion, + int? durationHours, + int? slurmShmSizeGib, + string? capacityPoolId, + global::System.DateTime? reservationStartTime, + global::System.DateTime? reservationEndTime, + bool? installTraefik, + global::System.DateTime? createdAt) { this.ClusterId = clusterId ?? throw new global::System.ArgumentNullException(nameof(clusterId)); this.ClusterType = clusterType; @@ -153,13 +208,20 @@ public GPUClusterInfo( this.GpuType = gpuType; this.ClusterName = clusterName ?? throw new global::System.ArgumentNullException(nameof(clusterName)); this.DurationHours = durationHours; - this.DriverVersion = driverVersion; this.Volumes = volumes ?? throw new global::System.ArgumentNullException(nameof(volumes)); this.Status = status; this.ControlPlaneNodes = controlPlaneNodes ?? throw new global::System.ArgumentNullException(nameof(controlPlaneNodes)); this.GpuWorkerNodes = gpuWorkerNodes ?? throw new global::System.ArgumentNullException(nameof(gpuWorkerNodes)); this.KubeConfig = kubeConfig ?? throw new global::System.ArgumentNullException(nameof(kubeConfig)); this.NumGpus = numGpus; + this.SlurmShmSizeGib = slurmShmSizeGib; + this.CapacityPoolId = capacityPoolId; + this.ReservationStartTime = reservationStartTime; + this.ReservationEndTime = reservationEndTime; + this.InstallTraefik = installTraefik; + this.CudaVersion = cudaVersion ?? throw new global::System.ArgumentNullException(nameof(cudaVersion)); + this.NvidiaDriverVersion = nvidiaDriverVersion ?? throw new global::System.ArgumentNullException(nameof(nvidiaDriverVersion)); + this.CreatedAt = createdAt; } /// @@ -168,5 +230,6 @@ public GPUClusterInfo( public GPUClusterInfo() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GPUClusterInfoDriverVersion.g.cs b/src/libs/Together/Generated/Together.Models.GPUClusterInfoDriverVersion.g.cs deleted file mode 100644 index d5644ac8..00000000 --- a/src/libs/Together/Generated/Together.Models.GPUClusterInfoDriverVersion.g.cs +++ /dev/null @@ -1,63 +0,0 @@ - -#nullable enable - -namespace Together -{ - /// - /// - /// - public enum GPUClusterInfoDriverVersion - { - /// - /// - /// - Cuda125555, - /// - /// - /// - Cuda126560, - /// - /// - /// - Cuda126565, - /// - /// - /// - Cuda128570, - } - - /// - /// Enum extensions to do fast conversions without the reflection. - /// - public static class GPUClusterInfoDriverVersionExtensions - { - /// - /// Converts an enum to a string. - /// - public static string ToValueString(this GPUClusterInfoDriverVersion value) - { - return value switch - { - GPUClusterInfoDriverVersion.Cuda125555 => "CUDA_12_5_555", - GPUClusterInfoDriverVersion.Cuda126560 => "CUDA_12_6_560", - GPUClusterInfoDriverVersion.Cuda126565 => "CUDA_12_6_565", - GPUClusterInfoDriverVersion.Cuda128570 => "CUDA_12_8_570", - _ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null), - }; - } - /// - /// Converts an string to a enum. - /// - public static GPUClusterInfoDriverVersion? ToEnum(string value) - { - return value switch - { - "CUDA_12_5_555" => GPUClusterInfoDriverVersion.Cuda125555, - "CUDA_12_6_560" => GPUClusterInfoDriverVersion.Cuda126560, - "CUDA_12_6_565" => GPUClusterInfoDriverVersion.Cuda126565, - "CUDA_12_8_570" => GPUClusterInfoDriverVersion.Cuda128570, - _ => null, - }; - } - } -} \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GPUClusterServiceDeleteResponse.g.cs b/src/libs/Together/Generated/Together.Models.GPUClusterServiceDeleteResponse.g.cs index d108da13..7bcfdae6 100644 --- a/src/libs/Together/Generated/Together.Models.GPUClusterServiceDeleteResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.GPUClusterServiceDeleteResponse.g.cs @@ -40,5 +40,6 @@ public GPUClusterServiceDeleteResponse( public GPUClusterServiceDeleteResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GPUClusterUpdateRequest.g.cs b/src/libs/Together/Generated/Together.Models.GPUClusterUpdateRequest.g.cs index e18f8f10..868a33a0 100644 --- a/src/libs/Together/Generated/Together.Models.GPUClusterUpdateRequest.g.cs +++ b/src/libs/Together/Generated/Together.Models.GPUClusterUpdateRequest.g.cs @@ -21,6 +21,12 @@ public sealed partial class GPUClusterUpdateRequest [global::System.Text.Json.Serialization.JsonPropertyName("num_gpus")] public int? NumGpus { get; set; } + /// + /// Timestamp at which the cluster should be decommissioned. Only accepted for prepaid clusters. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("reservation_end_time")] + public global::System.DateTime? ReservationEndTime { get; set; } + /// /// Additional properties that are not explicitly defined in the schema /// @@ -36,15 +42,20 @@ public sealed partial class GPUClusterUpdateRequest /// /// Number of GPUs to allocate in the cluster. This must be multiple of 8. For example, 8, 16 or 24 /// + /// + /// Timestamp at which the cluster should be decommissioned. Only accepted for prepaid clusters. + /// #if NET7_0_OR_GREATER [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] #endif public GPUClusterUpdateRequest( global::Together.GPUClusterUpdateRequestClusterType? clusterType, - int? numGpus) + int? numGpus, + global::System.DateTime? reservationEndTime) { this.ClusterType = clusterType; this.NumGpus = numGpus; + this.ReservationEndTime = reservationEndTime; } /// @@ -53,5 +64,6 @@ public GPUClusterUpdateRequest( public GPUClusterUpdateRequest() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GPUClusterVolume.g.cs b/src/libs/Together/Generated/Together.Models.GPUClusterVolume.g.cs index cb27e9fa..085d55b6 100644 --- a/src/libs/Together/Generated/Together.Models.GPUClusterVolume.g.cs +++ b/src/libs/Together/Generated/Together.Models.GPUClusterVolume.g.cs @@ -70,5 +70,6 @@ public GPUClusterVolume( public GPUClusterVolume() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GPUClusters.g.cs b/src/libs/Together/Generated/Together.Models.GPUClusters.g.cs index 82250925..d4bce174 100644 --- a/src/libs/Together/Generated/Together.Models.GPUClusters.g.cs +++ b/src/libs/Together/Generated/Together.Models.GPUClusters.g.cs @@ -40,5 +40,6 @@ public GPUClusters( public GPUClusters() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GPUClustersSharedVolume.g.cs b/src/libs/Together/Generated/Together.Models.GPUClustersSharedVolume.g.cs index cd1a7dfc..671a126b 100644 --- a/src/libs/Together/Generated/Together.Models.GPUClustersSharedVolume.g.cs +++ b/src/libs/Together/Generated/Together.Models.GPUClustersSharedVolume.g.cs @@ -79,5 +79,6 @@ public GPUClustersSharedVolume( public GPUClustersSharedVolume() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GPUClustersSharedVolumeCreateRequest.g.cs b/src/libs/Together/Generated/Together.Models.GPUClustersSharedVolumeCreateRequest.g.cs index 266ef0e8..aac676fc 100644 --- a/src/libs/Together/Generated/Together.Models.GPUClustersSharedVolumeCreateRequest.g.cs +++ b/src/libs/Together/Generated/Together.Models.GPUClustersSharedVolumeCreateRequest.g.cs @@ -66,5 +66,6 @@ public GPUClustersSharedVolumeCreateRequest( public GPUClustersSharedVolumeCreateRequest() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GPUClustersSharedVolumeDeleteResponse.g.cs b/src/libs/Together/Generated/Together.Models.GPUClustersSharedVolumeDeleteResponse.g.cs index 7221672b..acd4748f 100644 --- a/src/libs/Together/Generated/Together.Models.GPUClustersSharedVolumeDeleteResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.GPUClustersSharedVolumeDeleteResponse.g.cs @@ -40,5 +40,6 @@ public GPUClustersSharedVolumeDeleteResponse( public GPUClustersSharedVolumeDeleteResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GPUClustersSharedVolumeUpdateRequest.g.cs b/src/libs/Together/Generated/Together.Models.GPUClustersSharedVolumeUpdateRequest.g.cs index 30c4d86b..b974a4e0 100644 --- a/src/libs/Together/Generated/Together.Models.GPUClustersSharedVolumeUpdateRequest.g.cs +++ b/src/libs/Together/Generated/Together.Models.GPUClustersSharedVolumeUpdateRequest.g.cs @@ -52,5 +52,6 @@ public GPUClustersSharedVolumeUpdateRequest( public GPUClustersSharedVolumeUpdateRequest() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GPUClustersSharedVolumes.g.cs b/src/libs/Together/Generated/Together.Models.GPUClustersSharedVolumes.g.cs index 0db4450e..82199074 100644 --- a/src/libs/Together/Generated/Together.Models.GPUClustersSharedVolumes.g.cs +++ b/src/libs/Together/Generated/Together.Models.GPUClustersSharedVolumes.g.cs @@ -40,5 +40,6 @@ public GPUClustersSharedVolumes( public GPUClustersSharedVolumes() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GetDeploymentsLogsResponse.g.cs b/src/libs/Together/Generated/Together.Models.GetDeploymentsLogsResponse.g.cs index e875d8e8..0e0f252b 100644 --- a/src/libs/Together/Generated/Together.Models.GetDeploymentsLogsResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.GetDeploymentsLogsResponse.g.cs @@ -14,5 +14,6 @@ public sealed partial class GetDeploymentsLogsResponse /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GetDeploymentsLogsResponse2.g.cs b/src/libs/Together/Generated/Together.Models.GetDeploymentsLogsResponse2.g.cs index e1cb72c0..88342827 100644 --- a/src/libs/Together/Generated/Together.Models.GetDeploymentsLogsResponse2.g.cs +++ b/src/libs/Together/Generated/Together.Models.GetDeploymentsLogsResponse2.g.cs @@ -14,5 +14,6 @@ public sealed partial class GetDeploymentsLogsResponse2 /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GetDeploymentsResponse.g.cs b/src/libs/Together/Generated/Together.Models.GetDeploymentsResponse.g.cs index bb122879..4a05bdf3 100644 --- a/src/libs/Together/Generated/Together.Models.GetDeploymentsResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.GetDeploymentsResponse.g.cs @@ -14,5 +14,6 @@ public sealed partial class GetDeploymentsResponse /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GetDeploymentsResponse2.g.cs b/src/libs/Together/Generated/Together.Models.GetDeploymentsResponse2.g.cs index 3c5129fd..3a506112 100644 --- a/src/libs/Together/Generated/Together.Models.GetDeploymentsResponse2.g.cs +++ b/src/libs/Together/Generated/Together.Models.GetDeploymentsResponse2.g.cs @@ -14,5 +14,6 @@ public sealed partial class GetDeploymentsResponse2 /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GetDeploymentsResponse3.g.cs b/src/libs/Together/Generated/Together.Models.GetDeploymentsResponse3.g.cs index 7d9e6e41..8085b6d2 100644 --- a/src/libs/Together/Generated/Together.Models.GetDeploymentsResponse3.g.cs +++ b/src/libs/Together/Generated/Together.Models.GetDeploymentsResponse3.g.cs @@ -14,5 +14,6 @@ public sealed partial class GetDeploymentsResponse3 /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GetDeploymentsSecretsResponse.g.cs b/src/libs/Together/Generated/Together.Models.GetDeploymentsSecretsResponse.g.cs index 31acee1a..6471bdc2 100644 --- a/src/libs/Together/Generated/Together.Models.GetDeploymentsSecretsResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.GetDeploymentsSecretsResponse.g.cs @@ -14,5 +14,6 @@ public sealed partial class GetDeploymentsSecretsResponse /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GetDeploymentsSecretsResponse2.g.cs b/src/libs/Together/Generated/Together.Models.GetDeploymentsSecretsResponse2.g.cs index 37b8ea95..449ebf65 100644 --- a/src/libs/Together/Generated/Together.Models.GetDeploymentsSecretsResponse2.g.cs +++ b/src/libs/Together/Generated/Together.Models.GetDeploymentsSecretsResponse2.g.cs @@ -14,5 +14,6 @@ public sealed partial class GetDeploymentsSecretsResponse2 /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GetDeploymentsSecretsResponse3.g.cs b/src/libs/Together/Generated/Together.Models.GetDeploymentsSecretsResponse3.g.cs index 13c0465b..25003c59 100644 --- a/src/libs/Together/Generated/Together.Models.GetDeploymentsSecretsResponse3.g.cs +++ b/src/libs/Together/Generated/Together.Models.GetDeploymentsSecretsResponse3.g.cs @@ -14,5 +14,6 @@ public sealed partial class GetDeploymentsSecretsResponse3 /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GetDeploymentsStorageResponse.g.cs b/src/libs/Together/Generated/Together.Models.GetDeploymentsStorageResponse.g.cs index 084531c5..ca3c831f 100644 --- a/src/libs/Together/Generated/Together.Models.GetDeploymentsStorageResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.GetDeploymentsStorageResponse.g.cs @@ -14,5 +14,6 @@ public sealed partial class GetDeploymentsStorageResponse /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GetDeploymentsStorageResponse2.g.cs b/src/libs/Together/Generated/Together.Models.GetDeploymentsStorageResponse2.g.cs index 507e5b3f..b2b2edba 100644 --- a/src/libs/Together/Generated/Together.Models.GetDeploymentsStorageResponse2.g.cs +++ b/src/libs/Together/Generated/Together.Models.GetDeploymentsStorageResponse2.g.cs @@ -14,5 +14,6 @@ public sealed partial class GetDeploymentsStorageResponse2 /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GetDeploymentsStorageResponse3.g.cs b/src/libs/Together/Generated/Together.Models.GetDeploymentsStorageResponse3.g.cs index ccc80c3a..080876fb 100644 --- a/src/libs/Together/Generated/Together.Models.GetDeploymentsStorageResponse3.g.cs +++ b/src/libs/Together/Generated/Together.Models.GetDeploymentsStorageResponse3.g.cs @@ -14,5 +14,6 @@ public sealed partial class GetDeploymentsStorageResponse3 /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GetDeploymentsStorageVolumesResponse.g.cs b/src/libs/Together/Generated/Together.Models.GetDeploymentsStorageVolumesResponse.g.cs index 1d935a7c..0503186d 100644 --- a/src/libs/Together/Generated/Together.Models.GetDeploymentsStorageVolumesResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.GetDeploymentsStorageVolumesResponse.g.cs @@ -14,5 +14,6 @@ public sealed partial class GetDeploymentsStorageVolumesResponse /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GetDeploymentsStorageVolumesResponse2.g.cs b/src/libs/Together/Generated/Together.Models.GetDeploymentsStorageVolumesResponse2.g.cs index 7ab6bb3f..2eb8fb90 100644 --- a/src/libs/Together/Generated/Together.Models.GetDeploymentsStorageVolumesResponse2.g.cs +++ b/src/libs/Together/Generated/Together.Models.GetDeploymentsStorageVolumesResponse2.g.cs @@ -14,5 +14,6 @@ public sealed partial class GetDeploymentsStorageVolumesResponse2 /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GetDeploymentsStorageVolumesResponse3.g.cs b/src/libs/Together/Generated/Together.Models.GetDeploymentsStorageVolumesResponse3.g.cs index 703a2bc2..499d8d45 100644 --- a/src/libs/Together/Generated/Together.Models.GetDeploymentsStorageVolumesResponse3.g.cs +++ b/src/libs/Together/Generated/Together.Models.GetDeploymentsStorageVolumesResponse3.g.cs @@ -14,5 +14,6 @@ public sealed partial class GetDeploymentsStorageVolumesResponse3 /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GetEvaluationJobStatusAndResultsResponse.g.cs b/src/libs/Together/Generated/Together.Models.GetEvaluationJobStatusAndResultsResponse.g.cs index 80382171..a68ddbbf 100644 --- a/src/libs/Together/Generated/Together.Models.GetEvaluationJobStatusAndResultsResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.GetEvaluationJobStatusAndResultsResponse.g.cs @@ -54,5 +54,6 @@ public GetEvaluationJobStatusAndResultsResponse( public GetEvaluationJobStatusAndResultsResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GetFineTunesMetricsResponse.Json.g.cs b/src/libs/Together/Generated/Together.Models.GetFineTunesMetricsResponse.Json.g.cs new file mode 100644 index 00000000..7550f861 --- /dev/null +++ b/src/libs/Together/Generated/Together.Models.GetFineTunesMetricsResponse.Json.g.cs @@ -0,0 +1,92 @@ +#nullable enable + +namespace Together +{ + public sealed partial class GetFineTunesMetricsResponse + { + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerContext. + /// + public string ToJson( + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Serialize( + this, + this.GetType(), + jsonSerializerContext); + } + + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public string ToJson( + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + return global::System.Text.Json.JsonSerializer.Serialize( + this, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerContext. + /// + public static global::Together.GetFineTunesMetricsResponse? FromJson( + string json, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + typeof(global::Together.GetFineTunesMetricsResponse), + jsonSerializerContext) as global::Together.GetFineTunesMetricsResponse; + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::Together.GetFineTunesMetricsResponse? FromJson( + string json, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerContext. + /// + public static async global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return (await global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + typeof(global::Together.GetFineTunesMetricsResponse), + jsonSerializerContext).ConfigureAwait(false)) as global::Together.GetFineTunesMetricsResponse; + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + return global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + jsonSerializerOptions); + } + } +} diff --git a/src/libs/Together/Generated/Together.Models.GetFineTunesMetricsResponse.g.cs b/src/libs/Together/Generated/Together.Models.GetFineTunesMetricsResponse.g.cs new file mode 100644 index 00000000..758a0b86 --- /dev/null +++ b/src/libs/Together/Generated/Together.Models.GetFineTunesMetricsResponse.g.cs @@ -0,0 +1,44 @@ + +#nullable enable + +namespace Together +{ + /// + /// Example: {"metrics":[{"train/loss":0.5,"train/learning_rate":0.0001,"train/global_step":7},{"train/loss":0.45,"train/learning_rate":0.00009,"train/global_step":14}]} + /// + public sealed partial class GetFineTunesMetricsResponse + { + /// + /// + /// + [global::System.Text.Json.Serialization.JsonPropertyName("metrics")] + public global::System.Collections.Generic.IList>? Metrics { get; set; } + + /// + /// Additional properties that are not explicitly defined in the schema + /// + [global::System.Text.Json.Serialization.JsonExtensionData] + public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + + /// + /// Initializes a new instance of the class. + /// + /// +#if NET7_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] +#endif + public GetFineTunesMetricsResponse( + global::System.Collections.Generic.IList>? metrics) + { + this.Metrics = metrics; + } + + /// + /// Initializes a new instance of the class. + /// + public GetFineTunesMetricsResponse() + { + } + + } +} \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GetFineTunesMetricsResponseMetric.Json.g.cs b/src/libs/Together/Generated/Together.Models.GetFineTunesMetricsResponseMetric.Json.g.cs new file mode 100644 index 00000000..4396cd46 --- /dev/null +++ b/src/libs/Together/Generated/Together.Models.GetFineTunesMetricsResponseMetric.Json.g.cs @@ -0,0 +1,92 @@ +#nullable enable + +namespace Together +{ + public sealed partial class GetFineTunesMetricsResponseMetric + { + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerContext. + /// + public string ToJson( + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Serialize( + this, + this.GetType(), + jsonSerializerContext); + } + + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public string ToJson( + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + return global::System.Text.Json.JsonSerializer.Serialize( + this, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerContext. + /// + public static global::Together.GetFineTunesMetricsResponseMetric? FromJson( + string json, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + typeof(global::Together.GetFineTunesMetricsResponseMetric), + jsonSerializerContext) as global::Together.GetFineTunesMetricsResponseMetric; + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::Together.GetFineTunesMetricsResponseMetric? FromJson( + string json, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerContext. + /// + public static async global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return (await global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + typeof(global::Together.GetFineTunesMetricsResponseMetric), + jsonSerializerContext).ConfigureAwait(false)) as global::Together.GetFineTunesMetricsResponseMetric; + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + return global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + jsonSerializerOptions); + } + } +} diff --git a/src/libs/Together/Generated/Together.Models.GetFineTunesMetricsResponseMetric.g.cs b/src/libs/Together/Generated/Together.Models.GetFineTunesMetricsResponseMetric.g.cs new file mode 100644 index 00000000..79abae5b --- /dev/null +++ b/src/libs/Together/Generated/Together.Models.GetFineTunesMetricsResponseMetric.g.cs @@ -0,0 +1,19 @@ + +#nullable enable + +namespace Together +{ + /// + /// A flat dictionary of scalar metric values. + /// + public sealed partial class GetFineTunesMetricsResponseMetric + { + + /// + /// Additional properties that are not explicitly defined in the schema + /// + [global::System.Text.Json.Serialization.JsonExtensionData] + public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + + } +} \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GetFineTunesModelsLimitsResponse.g.cs b/src/libs/Together/Generated/Together.Models.GetFineTunesModelsLimitsResponse.g.cs index d81ab8aa..ab54c538 100644 --- a/src/libs/Together/Generated/Together.Models.GetFineTunesModelsLimitsResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.GetFineTunesModelsLimitsResponse.g.cs @@ -41,5 +41,6 @@ public GetFineTunesModelsLimitsResponse( public GetFineTunesModelsLimitsResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GetFineTunesModelsSupportedResponse.g.cs b/src/libs/Together/Generated/Together.Models.GetFineTunesModelsSupportedResponse.g.cs index 803b4519..ca5fe25f 100644 --- a/src/libs/Together/Generated/Together.Models.GetFineTunesModelsSupportedResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.GetFineTunesModelsSupportedResponse.g.cs @@ -42,5 +42,6 @@ public GetFineTunesModelsSupportedResponse( public GetFineTunesModelsSupportedResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.GetModelListResponse.g.cs b/src/libs/Together/Generated/Together.Models.GetModelListResponse.g.cs index acc35022..704bd4bd 100644 --- a/src/libs/Together/Generated/Together.Models.GetModelListResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.GetModelListResponse.g.cs @@ -39,5 +39,6 @@ public GetModelListResponse( public GetModelListResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.HTTPAutoscalingConfig.g.cs b/src/libs/Together/Generated/Together.Models.HTTPAutoscalingConfig.g.cs index bd53de82..a9e502c8 100644 --- a/src/libs/Together/Generated/Together.Models.HTTPAutoscalingConfig.g.cs +++ b/src/libs/Together/Generated/Together.Models.HTTPAutoscalingConfig.g.cs @@ -73,5 +73,6 @@ public HTTPAutoscalingConfig( public HTTPAutoscalingConfig() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.HardwareAvailability.g.cs b/src/libs/Together/Generated/Together.Models.HardwareAvailability.g.cs index 8df6588e..461ea796 100644 --- a/src/libs/Together/Generated/Together.Models.HardwareAvailability.g.cs +++ b/src/libs/Together/Generated/Together.Models.HardwareAvailability.g.cs @@ -43,5 +43,6 @@ public HardwareAvailability( public HardwareAvailability() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.HardwareSpec.g.cs b/src/libs/Together/Generated/Together.Models.HardwareSpec.g.cs index cf08a10e..2d14071a 100644 --- a/src/libs/Together/Generated/Together.Models.HardwareSpec.g.cs +++ b/src/libs/Together/Generated/Together.Models.HardwareSpec.g.cs @@ -78,5 +78,6 @@ public HardwareSpec( public HardwareSpec() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.HardwareWithStatus.g.cs b/src/libs/Together/Generated/Together.Models.HardwareWithStatus.g.cs index 90889e58..0fa1455a 100644 --- a/src/libs/Together/Generated/Together.Models.HardwareWithStatus.g.cs +++ b/src/libs/Together/Generated/Together.Models.HardwareWithStatus.g.cs @@ -101,5 +101,6 @@ public HardwareWithStatus( public HardwareWithStatus() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.HardwareWithStatusObject.g.cs b/src/libs/Together/Generated/Together.Models.HardwareWithStatusObject.g.cs index 7f17bd71..06b8dbe8 100644 --- a/src/libs/Together/Generated/Together.Models.HardwareWithStatusObject.g.cs +++ b/src/libs/Together/Generated/Together.Models.HardwareWithStatusObject.g.cs @@ -14,5 +14,6 @@ public sealed partial class HardwareWithStatusObject /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ImageResponse.g.cs b/src/libs/Together/Generated/Together.Models.ImageResponse.g.cs index 6af2d9ad..22bf42fc 100644 --- a/src/libs/Together/Generated/Together.Models.ImageResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.ImageResponse.g.cs @@ -72,5 +72,6 @@ public ImageResponse( public ImageResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ImageResponseDataB64.g.cs b/src/libs/Together/Generated/Together.Models.ImageResponseDataB64.g.cs index dbee7794..eff41934 100644 --- a/src/libs/Together/Generated/Together.Models.ImageResponseDataB64.g.cs +++ b/src/libs/Together/Generated/Together.Models.ImageResponseDataB64.g.cs @@ -60,5 +60,6 @@ public ImageResponseDataB64( public ImageResponseDataB64() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ImageResponseDataItemDiscriminator.g.cs b/src/libs/Together/Generated/Together.Models.ImageResponseDataItemDiscriminator.g.cs index d70a8c7b..b42faa0d 100644 --- a/src/libs/Together/Generated/Together.Models.ImageResponseDataItemDiscriminator.g.cs +++ b/src/libs/Together/Generated/Together.Models.ImageResponseDataItemDiscriminator.g.cs @@ -12,7 +12,8 @@ public sealed partial class ImageResponseDataItemDiscriminator /// /// [global::System.Text.Json.Serialization.JsonPropertyName("type")] - public string? Type { get; set; } + [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Together.JsonConverters.ImageResponseDataItemDiscriminatorTypeJsonConverter))] + public global::Together.ImageResponseDataItemDiscriminatorType? Type { get; set; } /// /// Additional properties that are not explicitly defined in the schema @@ -28,7 +29,7 @@ public sealed partial class ImageResponseDataItemDiscriminator [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] #endif public ImageResponseDataItemDiscriminator( - string? type) + global::Together.ImageResponseDataItemDiscriminatorType? type) { this.Type = type; } @@ -39,5 +40,6 @@ public ImageResponseDataItemDiscriminator( public ImageResponseDataItemDiscriminator() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.AudioTranslationVerboseJsonResponseTask.g.cs b/src/libs/Together/Generated/Together.Models.ImageResponseDataItemDiscriminatorType.g.cs similarity index 51% rename from src/libs/Together/Generated/Together.Models.AudioTranslationVerboseJsonResponseTask.g.cs rename to src/libs/Together/Generated/Together.Models.ImageResponseDataItemDiscriminatorType.g.cs index f7161b7a..ef2a3b3d 100644 --- a/src/libs/Together/Generated/Together.Models.AudioTranslationVerboseJsonResponseTask.g.cs +++ b/src/libs/Together/Generated/Together.Models.ImageResponseDataItemDiscriminatorType.g.cs @@ -4,47 +4,46 @@ namespace Together { /// - /// The task performed
- /// Example: translate + /// ///
- public enum AudioTranslationVerboseJsonResponseTask + public enum ImageResponseDataItemDiscriminatorType { /// /// /// - Transcribe, + B64Json, /// /// /// - Translate, + Url, } /// /// Enum extensions to do fast conversions without the reflection. /// - public static class AudioTranslationVerboseJsonResponseTaskExtensions + public static class ImageResponseDataItemDiscriminatorTypeExtensions { /// /// Converts an enum to a string. /// - public static string ToValueString(this AudioTranslationVerboseJsonResponseTask value) + public static string ToValueString(this ImageResponseDataItemDiscriminatorType value) { return value switch { - AudioTranslationVerboseJsonResponseTask.Transcribe => "transcribe", - AudioTranslationVerboseJsonResponseTask.Translate => "translate", + ImageResponseDataItemDiscriminatorType.B64Json => "b64_json", + ImageResponseDataItemDiscriminatorType.Url => "url", _ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null), }; } /// /// Converts an string to a enum. /// - public static AudioTranslationVerboseJsonResponseTask? ToEnum(string value) + public static ImageResponseDataItemDiscriminatorType? ToEnum(string value) { return value switch { - "transcribe" => AudioTranslationVerboseJsonResponseTask.Transcribe, - "translate" => AudioTranslationVerboseJsonResponseTask.Translate, + "b64_json" => ImageResponseDataItemDiscriminatorType.B64Json, + "url" => ImageResponseDataItemDiscriminatorType.Url, _ => null, }; } diff --git a/src/libs/Together/Generated/Together.Models.ImageResponseDataUrl.g.cs b/src/libs/Together/Generated/Together.Models.ImageResponseDataUrl.g.cs index 45e7156d..8c77ac21 100644 --- a/src/libs/Together/Generated/Together.Models.ImageResponseDataUrl.g.cs +++ b/src/libs/Together/Generated/Together.Models.ImageResponseDataUrl.g.cs @@ -60,5 +60,6 @@ public ImageResponseDataUrl( public ImageResponseDataUrl() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ImageResponseObject.g.cs b/src/libs/Together/Generated/Together.Models.ImageResponseObject.g.cs index 7f96b042..48031160 100644 --- a/src/libs/Together/Generated/Together.Models.ImageResponseObject.g.cs +++ b/src/libs/Together/Generated/Together.Models.ImageResponseObject.g.cs @@ -14,5 +14,6 @@ public sealed partial class ImageResponseObject ///
[global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.InferenceWarning.g.cs b/src/libs/Together/Generated/Together.Models.InferenceWarning.g.cs index cae9e75f..9c1a1abb 100644 --- a/src/libs/Together/Generated/Together.Models.InferenceWarning.g.cs +++ b/src/libs/Together/Generated/Together.Models.InferenceWarning.g.cs @@ -40,5 +40,6 @@ public InferenceWarning( public InferenceWarning() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.InstanceTypesResponse.g.cs b/src/libs/Together/Generated/Together.Models.InstanceTypesResponse.g.cs index 41b0a3ae..6a238d4d 100644 --- a/src/libs/Together/Generated/Together.Models.InstanceTypesResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.InstanceTypesResponse.g.cs @@ -39,5 +39,6 @@ public InstanceTypesResponse( public InstanceTypesResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.InterpreterOutput.g.cs b/src/libs/Together/Generated/Together.Models.InterpreterOutput.g.cs index 0eb29923..10f18d9a 100644 --- a/src/libs/Together/Generated/Together.Models.InterpreterOutput.g.cs +++ b/src/libs/Together/Generated/Together.Models.InterpreterOutput.g.cs @@ -26,6 +26,26 @@ namespace Together #endif public bool IsStreamOutput => StreamOutput != null; + /// + /// + /// + public bool TryPickStreamOutput( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Together.InterpreterOutputStreamOutput? value) + { + value = StreamOutput; + return IsStreamOutput; + } + + /// + /// + /// + public global::Together.InterpreterOutputStreamOutput PickStreamOutput() => IsStreamOutput + ? StreamOutput! + : throw new global::System.InvalidOperationException($"Expected union variant 'StreamOutput' but the value was {ToString()}."); + /// /// Errors and exceptions that occurred. If this output type is present, your code did not execute successfully. /// @@ -43,6 +63,26 @@ namespace Together #endif public bool IsError => Error != null; + /// + /// + /// + public bool TryPickError( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Together.InterpreterOutputErrorOutput? value) + { + value = Error; + return IsError; + } + + /// + /// + /// + public global::Together.InterpreterOutputErrorOutput PickError() => IsError + ? Error! + : throw new global::System.InvalidOperationException($"Expected union variant 'Error' but the value was {ToString()}."); + /// /// /// @@ -59,6 +99,26 @@ namespace Together [global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(DisplayorExecuteOutput))] #endif public bool IsDisplayorExecuteOutput => DisplayorExecuteOutput != null; + + /// + /// + /// + public bool TryPickDisplayorExecuteOutput( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Together.InterpreterOutputDisplayorExecuteOutput? value) + { + value = DisplayorExecuteOutput; + return IsDisplayorExecuteOutput; + } + + /// + /// + /// + public global::Together.InterpreterOutputDisplayorExecuteOutput PickDisplayorExecuteOutput() => IsDisplayorExecuteOutput + ? DisplayorExecuteOutput! + : throw new global::System.InvalidOperationException($"Expected union variant 'DisplayorExecuteOutput' but the value was {ToString()}."); /// /// /// @@ -77,6 +137,11 @@ public InterpreterOutput(global::Together.InterpreterOutputStreamOutput? value) StreamOutput = value; } + /// + /// + /// + public static InterpreterOutput FromStreamOutput(global::Together.InterpreterOutputStreamOutput? value) => new InterpreterOutput(value); + /// /// /// @@ -95,6 +160,11 @@ public InterpreterOutput(global::Together.InterpreterOutputErrorOutput? value) Error = value; } + /// + /// + /// + public static InterpreterOutput FromError(global::Together.InterpreterOutputErrorOutput? value) => new InterpreterOutput(value); + /// /// /// @@ -113,6 +183,11 @@ public InterpreterOutput(global::Together.InterpreterOutputDisplayorExecuteOutpu DisplayorExecuteOutput = value; } + /// + /// + /// + public static InterpreterOutput FromDisplayorExecuteOutput(global::Together.InterpreterOutputDisplayorExecuteOutput? value) => new InterpreterOutput(value); + /// /// /// @@ -157,9 +232,9 @@ public bool Validate() /// /// public TResult? Match( - global::System.Func? streamOutput = null, - global::System.Func? error = null, - global::System.Func? displayorExecuteOutput = null, + global::System.Func? streamOutput = null, + global::System.Func? error = null, + global::System.Func? displayorExecuteOutput = null, bool validate = true) { if (validate) @@ -187,9 +262,39 @@ public bool Validate() /// /// public void Match( - global::System.Action? streamOutput = null, - global::System.Action? error = null, - global::System.Action? displayorExecuteOutput = null, + global::System.Action? streamOutput = null, + + global::System.Action? error = null, + + global::System.Action? displayorExecuteOutput = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (IsStreamOutput) + { + streamOutput?.Invoke(StreamOutput!); + } + else if (IsError) + { + error?.Invoke(Error!); + } + else if (IsDisplayorExecuteOutput) + { + displayorExecuteOutput?.Invoke(DisplayorExecuteOutput!); + } + } + + /// + /// + /// + public void Switch( + global::System.Action? streamOutput = null, + global::System.Action? error = null, + global::System.Action? displayorExecuteOutput = null, bool validate = true) { if (validate) diff --git a/src/libs/Together/Generated/Together.Models.InterpreterOutputDiscriminator.g.cs b/src/libs/Together/Generated/Together.Models.InterpreterOutputDiscriminator.g.cs index a47cebb5..695a2fa8 100644 --- a/src/libs/Together/Generated/Together.Models.InterpreterOutputDiscriminator.g.cs +++ b/src/libs/Together/Generated/Together.Models.InterpreterOutputDiscriminator.g.cs @@ -12,7 +12,8 @@ public sealed partial class InterpreterOutputDiscriminator /// /// [global::System.Text.Json.Serialization.JsonPropertyName("type")] - public string? Type { get; set; } + [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Together.JsonConverters.InterpreterOutputDiscriminatorTypeJsonConverter))] + public global::Together.InterpreterOutputDiscriminatorType? Type { get; set; } /// /// Additional properties that are not explicitly defined in the schema @@ -28,7 +29,7 @@ public sealed partial class InterpreterOutputDiscriminator [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] #endif public InterpreterOutputDiscriminator( - string? type) + global::Together.InterpreterOutputDiscriminatorType? type) { this.Type = type; } @@ -39,5 +40,6 @@ public InterpreterOutputDiscriminator( public InterpreterOutputDiscriminator() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.InterpreterOutputDiscriminatorType.g.cs b/src/libs/Together/Generated/Together.Models.InterpreterOutputDiscriminatorType.g.cs new file mode 100644 index 00000000..a001a7e1 --- /dev/null +++ b/src/libs/Together/Generated/Together.Models.InterpreterOutputDiscriminatorType.g.cs @@ -0,0 +1,45 @@ + +#nullable enable + +namespace Together +{ + /// + /// + /// + public enum InterpreterOutputDiscriminatorType + { + /// + /// + /// + Error, + } + + /// + /// Enum extensions to do fast conversions without the reflection. + /// + public static class InterpreterOutputDiscriminatorTypeExtensions + { + /// + /// Converts an enum to a string. + /// + public static string ToValueString(this InterpreterOutputDiscriminatorType value) + { + return value switch + { + InterpreterOutputDiscriminatorType.Error => "error", + _ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null), + }; + } + /// + /// Converts an string to a enum. + /// + public static InterpreterOutputDiscriminatorType? ToEnum(string value) + { + return value switch + { + "error" => InterpreterOutputDiscriminatorType.Error, + _ => null, + }; + } + } +} \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.InterpreterOutputDisplayorExecuteOutput.g.cs b/src/libs/Together/Generated/Together.Models.InterpreterOutputDisplayorExecuteOutput.g.cs index 00f52555..5440e114 100644 --- a/src/libs/Together/Generated/Together.Models.InterpreterOutputDisplayorExecuteOutput.g.cs +++ b/src/libs/Together/Generated/Together.Models.InterpreterOutputDisplayorExecuteOutput.g.cs @@ -51,5 +51,6 @@ public InterpreterOutputDisplayorExecuteOutput( public InterpreterOutputDisplayorExecuteOutput() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.InterpreterOutputDisplayorExecuteOutputData.g.cs b/src/libs/Together/Generated/Together.Models.InterpreterOutputDisplayorExecuteOutputData.g.cs index f26289c4..cd916816 100644 --- a/src/libs/Together/Generated/Together.Models.InterpreterOutputDisplayorExecuteOutputData.g.cs +++ b/src/libs/Together/Generated/Together.Models.InterpreterOutputDisplayorExecuteOutputData.g.cs @@ -156,5 +156,6 @@ public InterpreterOutputDisplayorExecuteOutputData( public InterpreterOutputDisplayorExecuteOutputData() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.InterpreterOutputDisplayorExecuteOutputDataApplicationGeoJson.g.cs b/src/libs/Together/Generated/Together.Models.InterpreterOutputDisplayorExecuteOutputDataApplicationGeoJson.g.cs index 34bce0aa..aef47b35 100644 --- a/src/libs/Together/Generated/Together.Models.InterpreterOutputDisplayorExecuteOutputDataApplicationGeoJson.g.cs +++ b/src/libs/Together/Generated/Together.Models.InterpreterOutputDisplayorExecuteOutputDataApplicationGeoJson.g.cs @@ -14,5 +14,6 @@ public sealed partial class InterpreterOutputDisplayorExecuteOutputDataApplicati /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.InterpreterOutputDisplayorExecuteOutputDataApplicationJson.g.cs b/src/libs/Together/Generated/Together.Models.InterpreterOutputDisplayorExecuteOutputDataApplicationJson.g.cs index 10139311..8da08ff1 100644 --- a/src/libs/Together/Generated/Together.Models.InterpreterOutputDisplayorExecuteOutputDataApplicationJson.g.cs +++ b/src/libs/Together/Generated/Together.Models.InterpreterOutputDisplayorExecuteOutputDataApplicationJson.g.cs @@ -14,5 +14,6 @@ public sealed partial class InterpreterOutputDisplayorExecuteOutputDataApplicati /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.InterpreterOutputDisplayorExecuteOutputDataApplicationVndVegaV5Json.g.cs b/src/libs/Together/Generated/Together.Models.InterpreterOutputDisplayorExecuteOutputDataApplicationVndVegaV5Json.g.cs index 84fa8237..c86cc19c 100644 --- a/src/libs/Together/Generated/Together.Models.InterpreterOutputDisplayorExecuteOutputDataApplicationVndVegaV5Json.g.cs +++ b/src/libs/Together/Generated/Together.Models.InterpreterOutputDisplayorExecuteOutputDataApplicationVndVegaV5Json.g.cs @@ -14,5 +14,6 @@ public sealed partial class InterpreterOutputDisplayorExecuteOutputDataApplicati /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.InterpreterOutputDisplayorExecuteOutputDataApplicationVndVegaliteV4Json.g.cs b/src/libs/Together/Generated/Together.Models.InterpreterOutputDisplayorExecuteOutputDataApplicationVndVegaliteV4Json.g.cs index 30d817b3..d5223627 100644 --- a/src/libs/Together/Generated/Together.Models.InterpreterOutputDisplayorExecuteOutputDataApplicationVndVegaliteV4Json.g.cs +++ b/src/libs/Together/Generated/Together.Models.InterpreterOutputDisplayorExecuteOutputDataApplicationVndVegaliteV4Json.g.cs @@ -14,5 +14,6 @@ public sealed partial class InterpreterOutputDisplayorExecuteOutputDataApplicati /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.InterpreterOutputErrorOutput.g.cs b/src/libs/Together/Generated/Together.Models.InterpreterOutputErrorOutput.g.cs index fd00600a..13859db5 100644 --- a/src/libs/Together/Generated/Together.Models.InterpreterOutputErrorOutput.g.cs +++ b/src/libs/Together/Generated/Together.Models.InterpreterOutputErrorOutput.g.cs @@ -50,5 +50,6 @@ public InterpreterOutputErrorOutput( public InterpreterOutputErrorOutput() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.InterpreterOutputStreamOutput.g.cs b/src/libs/Together/Generated/Together.Models.InterpreterOutputStreamOutput.g.cs index 56f7a7c3..a2829de2 100644 --- a/src/libs/Together/Generated/Together.Models.InterpreterOutputStreamOutput.g.cs +++ b/src/libs/Together/Generated/Together.Models.InterpreterOutputStreamOutput.g.cs @@ -51,5 +51,6 @@ public InterpreterOutputStreamOutput( public InterpreterOutputStreamOutput() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.JobInfoSuccessResponse.g.cs b/src/libs/Together/Generated/Together.Models.JobInfoSuccessResponse.g.cs index 04832b70..0de16687 100644 --- a/src/libs/Together/Generated/Together.Models.JobInfoSuccessResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.JobInfoSuccessResponse.g.cs @@ -116,5 +116,6 @@ public JobInfoSuccessResponse( public JobInfoSuccessResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.JobInfoSuccessResponseArgs.g.cs b/src/libs/Together/Generated/Together.Models.JobInfoSuccessResponseArgs.g.cs index e5ef0714..faa41bb5 100644 --- a/src/libs/Together/Generated/Together.Models.JobInfoSuccessResponseArgs.g.cs +++ b/src/libs/Together/Generated/Together.Models.JobInfoSuccessResponseArgs.g.cs @@ -66,5 +66,6 @@ public JobInfoSuccessResponseArgs( public JobInfoSuccessResponseArgs() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.JobInfoSuccessResponseStatusUpdate.g.cs b/src/libs/Together/Generated/Together.Models.JobInfoSuccessResponseStatusUpdate.g.cs index 278dff23..d192f6fe 100644 --- a/src/libs/Together/Generated/Together.Models.JobInfoSuccessResponseStatusUpdate.g.cs +++ b/src/libs/Together/Generated/Together.Models.JobInfoSuccessResponseStatusUpdate.g.cs @@ -69,5 +69,6 @@ public JobInfoSuccessResponseStatusUpdate( public JobInfoSuccessResponseStatusUpdate() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.JobsInfoSuccessResponse.g.cs b/src/libs/Together/Generated/Together.Models.JobsInfoSuccessResponse.g.cs index b7f5b256..42a87410 100644 --- a/src/libs/Together/Generated/Together.Models.JobsInfoSuccessResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.JobsInfoSuccessResponse.g.cs @@ -40,5 +40,6 @@ public JobsInfoSuccessResponse( public JobsInfoSuccessResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.KubernetesEvent.g.cs b/src/libs/Together/Generated/Together.Models.KubernetesEvent.g.cs index 6eca791a..a68b55af 100644 --- a/src/libs/Together/Generated/Together.Models.KubernetesEvent.g.cs +++ b/src/libs/Together/Generated/Together.Models.KubernetesEvent.g.cs @@ -96,5 +96,6 @@ public KubernetesEvent( public KubernetesEvent() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.LRScheduler.g.cs b/src/libs/Together/Generated/Together.Models.LRScheduler.g.cs index b3b0079f..2d05603a 100644 --- a/src/libs/Together/Generated/Together.Models.LRScheduler.g.cs +++ b/src/libs/Together/Generated/Together.Models.LRScheduler.g.cs @@ -51,5 +51,6 @@ public LRScheduler( public LRScheduler() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.LinearLRSchedulerArgs.g.cs b/src/libs/Together/Generated/Together.Models.LinearLRSchedulerArgs.g.cs index bd5b4fd9..84f89f3f 100644 --- a/src/libs/Together/Generated/Together.Models.LinearLRSchedulerArgs.g.cs +++ b/src/libs/Together/Generated/Together.Models.LinearLRSchedulerArgs.g.cs @@ -43,5 +43,6 @@ public LinearLRSchedulerArgs( public LinearLRSchedulerArgs() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ListAvailibilityZonesResponse.g.cs b/src/libs/Together/Generated/Together.Models.ListAvailibilityZonesResponse.g.cs index 0022f06b..eb133aea 100644 --- a/src/libs/Together/Generated/Together.Models.ListAvailibilityZonesResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.ListAvailibilityZonesResponse.g.cs @@ -40,5 +40,6 @@ public ListAvailibilityZonesResponse( public ListAvailibilityZonesResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ListEndpoint.g.cs b/src/libs/Together/Generated/Together.Models.ListEndpoint.g.cs index e1f85424..867a8719 100644 --- a/src/libs/Together/Generated/Together.Models.ListEndpoint.g.cs +++ b/src/libs/Together/Generated/Together.Models.ListEndpoint.g.cs @@ -149,5 +149,6 @@ public ListEndpoint( public ListEndpoint() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ListEndpointObject.g.cs b/src/libs/Together/Generated/Together.Models.ListEndpointObject.g.cs index 2fd70734..9597b323 100644 --- a/src/libs/Together/Generated/Together.Models.ListEndpointObject.g.cs +++ b/src/libs/Together/Generated/Together.Models.ListEndpointObject.g.cs @@ -14,5 +14,6 @@ public sealed partial class ListEndpointObject /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ListEndpointsResponse.g.cs b/src/libs/Together/Generated/Together.Models.ListEndpointsResponse.g.cs index 8ec89cd3..cac5b8b0 100644 --- a/src/libs/Together/Generated/Together.Models.ListEndpointsResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.ListEndpointsResponse.g.cs @@ -52,5 +52,6 @@ public ListEndpointsResponse( public ListEndpointsResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ListEndpointsResponseObject.g.cs b/src/libs/Together/Generated/Together.Models.ListEndpointsResponseObject.g.cs index f64d3729..a5dbabdd 100644 --- a/src/libs/Together/Generated/Together.Models.ListEndpointsResponseObject.g.cs +++ b/src/libs/Together/Generated/Together.Models.ListEndpointsResponseObject.g.cs @@ -14,5 +14,6 @@ public sealed partial class ListEndpointsResponseObject /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ListHardwareResponse.g.cs b/src/libs/Together/Generated/Together.Models.ListHardwareResponse.g.cs index 8ab7b40a..6c71cb2b 100644 --- a/src/libs/Together/Generated/Together.Models.ListHardwareResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.ListHardwareResponse.g.cs @@ -52,5 +52,6 @@ public ListHardwareResponse( public ListHardwareResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ListHardwareResponseObject.g.cs b/src/libs/Together/Generated/Together.Models.ListHardwareResponseObject.g.cs index 71219891..ef481381 100644 --- a/src/libs/Together/Generated/Together.Models.ListHardwareResponseObject.g.cs +++ b/src/libs/Together/Generated/Together.Models.ListHardwareResponseObject.g.cs @@ -14,5 +14,6 @@ public sealed partial class ListHardwareResponseObject /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ListSecretsResponse.g.cs b/src/libs/Together/Generated/Together.Models.ListSecretsResponse.g.cs index 0663eac7..e33194cc 100644 --- a/src/libs/Together/Generated/Together.Models.ListSecretsResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.ListSecretsResponse.g.cs @@ -52,5 +52,6 @@ public ListSecretsResponse( public ListSecretsResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ListSecretsResponseObject.g.cs b/src/libs/Together/Generated/Together.Models.ListSecretsResponseObject.g.cs index fd6e76e3..6dbcf509 100644 --- a/src/libs/Together/Generated/Together.Models.ListSecretsResponseObject.g.cs +++ b/src/libs/Together/Generated/Together.Models.ListSecretsResponseObject.g.cs @@ -14,5 +14,6 @@ public sealed partial class ListSecretsResponseObject /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ListVoicesResponse.g.cs b/src/libs/Together/Generated/Together.Models.ListVoicesResponse.g.cs index 57197134..9f58c95d 100644 --- a/src/libs/Together/Generated/Together.Models.ListVoicesResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.ListVoicesResponse.g.cs @@ -40,5 +40,6 @@ public ListVoicesResponse( public ListVoicesResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ListVolumesResponse.g.cs b/src/libs/Together/Generated/Together.Models.ListVolumesResponse.g.cs index cc674098..e933db16 100644 --- a/src/libs/Together/Generated/Together.Models.ListVolumesResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.ListVolumesResponse.g.cs @@ -52,5 +52,6 @@ public ListVolumesResponse( public ListVolumesResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ListVolumesResponseObject.g.cs b/src/libs/Together/Generated/Together.Models.ListVolumesResponseObject.g.cs index cbdff24e..d4defe28 100644 --- a/src/libs/Together/Generated/Together.Models.ListVolumesResponseObject.g.cs +++ b/src/libs/Together/Generated/Together.Models.ListVolumesResponseObject.g.cs @@ -14,5 +14,6 @@ public sealed partial class ListVolumesResponseObject /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.LoRATrainingType.g.cs b/src/libs/Together/Generated/Together.Models.LoRATrainingType.g.cs index 185b6c82..405fb371 100644 --- a/src/libs/Together/Generated/Together.Models.LoRATrainingType.g.cs +++ b/src/libs/Together/Generated/Together.Models.LoRATrainingType.g.cs @@ -82,5 +82,6 @@ public LoRATrainingType( public LoRATrainingType() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.LogprobsPart.g.cs b/src/libs/Together/Generated/Together.Models.LogprobsPart.g.cs index 4a705de3..24863ccd 100644 --- a/src/libs/Together/Generated/Together.Models.LogprobsPart.g.cs +++ b/src/libs/Together/Generated/Together.Models.LogprobsPart.g.cs @@ -74,5 +74,6 @@ public LogprobsPart( public LogprobsPart() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ModelInfo.g.cs b/src/libs/Together/Generated/Together.Models.ModelInfo.g.cs index 37f3e085..045bc5a6 100644 --- a/src/libs/Together/Generated/Together.Models.ModelInfo.g.cs +++ b/src/libs/Together/Generated/Together.Models.ModelInfo.g.cs @@ -148,5 +148,6 @@ public ModelInfo( public ModelInfo() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ModelInfoObject.g.cs b/src/libs/Together/Generated/Together.Models.ModelInfoObject.g.cs index 233ed6e0..db9cf16d 100644 --- a/src/libs/Together/Generated/Together.Models.ModelInfoObject.g.cs +++ b/src/libs/Together/Generated/Together.Models.ModelInfoObject.g.cs @@ -14,5 +14,6 @@ public sealed partial class ModelInfoObject /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ModelUploadRequest.g.cs b/src/libs/Together/Generated/Together.Models.ModelUploadRequest.g.cs index e7e803c5..14c57f8a 100644 --- a/src/libs/Together/Generated/Together.Models.ModelUploadRequest.g.cs +++ b/src/libs/Together/Generated/Together.Models.ModelUploadRequest.g.cs @@ -133,5 +133,6 @@ public ModelUploadRequest( public ModelUploadRequest() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ModelUploadSuccessResponse.g.cs b/src/libs/Together/Generated/Together.Models.ModelUploadSuccessResponse.g.cs index 9b80658d..bfc53100 100644 --- a/src/libs/Together/Generated/Together.Models.ModelUploadSuccessResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.ModelUploadSuccessResponse.g.cs @@ -53,5 +53,6 @@ public ModelUploadSuccessResponse( public ModelUploadSuccessResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ModelUploadSuccessResponseData.g.cs b/src/libs/Together/Generated/Together.Models.ModelUploadSuccessResponseData.g.cs index 400326c6..660dcaec 100644 --- a/src/libs/Together/Generated/Together.Models.ModelUploadSuccessResponseData.g.cs +++ b/src/libs/Together/Generated/Together.Models.ModelUploadSuccessResponseData.g.cs @@ -82,5 +82,6 @@ public ModelUploadSuccessResponseData( public ModelUploadSuccessResponseData() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ModelVoices.g.cs b/src/libs/Together/Generated/Together.Models.ModelVoices.g.cs index 9f68fdb8..7b43e0e8 100644 --- a/src/libs/Together/Generated/Together.Models.ModelVoices.g.cs +++ b/src/libs/Together/Generated/Together.Models.ModelVoices.g.cs @@ -54,5 +54,6 @@ public ModelVoices( public ModelVoices() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ModelVoicesVoice.g.cs b/src/libs/Together/Generated/Together.Models.ModelVoicesVoice.g.cs index 467f6d2d..e7b6cea0 100644 --- a/src/libs/Together/Generated/Together.Models.ModelVoicesVoice.g.cs +++ b/src/libs/Together/Generated/Together.Models.ModelVoicesVoice.g.cs @@ -52,5 +52,6 @@ public ModelVoicesVoice( public ModelVoicesVoice() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.MultimodalParams.g.cs b/src/libs/Together/Generated/Together.Models.MultimodalParams.g.cs index d0a98c40..78c25665 100644 --- a/src/libs/Together/Generated/Together.Models.MultimodalParams.g.cs +++ b/src/libs/Together/Generated/Together.Models.MultimodalParams.g.cs @@ -41,5 +41,6 @@ public MultimodalParams( public MultimodalParams() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.OutputsItem.g.cs b/src/libs/Together/Generated/Together.Models.OutputsItem.g.cs index 2f55f821..c7d0ded2 100644 --- a/src/libs/Together/Generated/Together.Models.OutputsItem.g.cs +++ b/src/libs/Together/Generated/Together.Models.OutputsItem.g.cs @@ -26,6 +26,26 @@ namespace Together #endif public bool IsStreamOutput => StreamOutput != null; + /// + /// + /// + public bool TryPickStreamOutput( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Together.ExecuteResponseSuccessfulExecutionDataOutputStreamOutput? value) + { + value = StreamOutput; + return IsStreamOutput; + } + + /// + /// + /// + public global::Together.ExecuteResponseSuccessfulExecutionDataOutputStreamOutput PickStreamOutput() => IsStreamOutput + ? StreamOutput! + : throw new global::System.InvalidOperationException($"Expected union variant 'StreamOutput' but the value was {ToString()}."); + /// /// Errors and exceptions that occurred. If this output type is present, your code did not execute successfully. /// @@ -43,6 +63,26 @@ namespace Together #endif public bool IsError => Error != null; + /// + /// + /// + public bool TryPickError( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Together.ExecuteResponseSuccessfulExecutionDataOutputErrorOutput? value) + { + value = Error; + return IsError; + } + + /// + /// + /// + public global::Together.ExecuteResponseSuccessfulExecutionDataOutputErrorOutput PickError() => IsError + ? Error! + : throw new global::System.InvalidOperationException($"Expected union variant 'Error' but the value was {ToString()}."); + /// /// /// @@ -59,6 +99,26 @@ namespace Together [global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(DisplayorExecuteOutput))] #endif public bool IsDisplayorExecuteOutput => DisplayorExecuteOutput != null; + + /// + /// + /// + public bool TryPickDisplayorExecuteOutput( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Together.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutput? value) + { + value = DisplayorExecuteOutput; + return IsDisplayorExecuteOutput; + } + + /// + /// + /// + public global::Together.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutput PickDisplayorExecuteOutput() => IsDisplayorExecuteOutput + ? DisplayorExecuteOutput! + : throw new global::System.InvalidOperationException($"Expected union variant 'DisplayorExecuteOutput' but the value was {ToString()}."); /// /// /// @@ -77,6 +137,11 @@ public OutputsItem(global::Together.ExecuteResponseSuccessfulExecutionDataOutput StreamOutput = value; } + /// + /// + /// + public static OutputsItem FromStreamOutput(global::Together.ExecuteResponseSuccessfulExecutionDataOutputStreamOutput? value) => new OutputsItem(value); + /// /// /// @@ -95,6 +160,11 @@ public OutputsItem(global::Together.ExecuteResponseSuccessfulExecutionDataOutput Error = value; } + /// + /// + /// + public static OutputsItem FromError(global::Together.ExecuteResponseSuccessfulExecutionDataOutputErrorOutput? value) => new OutputsItem(value); + /// /// /// @@ -113,6 +183,11 @@ public OutputsItem(global::Together.ExecuteResponseSuccessfulExecutionDataOutput DisplayorExecuteOutput = value; } + /// + /// + /// + public static OutputsItem FromDisplayorExecuteOutput(global::Together.ExecuteResponseSuccessfulExecutionDataOutputDisplayorExecuteOutput? value) => new OutputsItem(value); + /// /// /// @@ -157,9 +232,9 @@ public bool Validate() /// /// public TResult? Match( - global::System.Func? streamOutput = null, - global::System.Func? error = null, - global::System.Func? displayorExecuteOutput = null, + global::System.Func? streamOutput = null, + global::System.Func? error = null, + global::System.Func? displayorExecuteOutput = null, bool validate = true) { if (validate) @@ -187,9 +262,39 @@ public bool Validate() /// /// public void Match( - global::System.Action? streamOutput = null, - global::System.Action? error = null, - global::System.Action? displayorExecuteOutput = null, + global::System.Action? streamOutput = null, + + global::System.Action? error = null, + + global::System.Action? displayorExecuteOutput = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (IsStreamOutput) + { + streamOutput?.Invoke(StreamOutput!); + } + else if (IsError) + { + error?.Invoke(Error!); + } + else if (IsDisplayorExecuteOutput) + { + displayorExecuteOutput?.Invoke(DisplayorExecuteOutput!); + } + } + + /// + /// + /// + public void Switch( + global::System.Action? streamOutput = null, + global::System.Action? error = null, + global::System.Action? displayorExecuteOutput = null, bool validate = true) { if (validate) diff --git a/src/libs/Together/Generated/Together.Models.PatchDeploymentsResponse.g.cs b/src/libs/Together/Generated/Together.Models.PatchDeploymentsResponse.g.cs index bbfebf17..1692c2ea 100644 --- a/src/libs/Together/Generated/Together.Models.PatchDeploymentsResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.PatchDeploymentsResponse.g.cs @@ -14,5 +14,6 @@ public sealed partial class PatchDeploymentsResponse /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.PatchDeploymentsResponse2.g.cs b/src/libs/Together/Generated/Together.Models.PatchDeploymentsResponse2.g.cs index 56ea3490..4e226752 100644 --- a/src/libs/Together/Generated/Together.Models.PatchDeploymentsResponse2.g.cs +++ b/src/libs/Together/Generated/Together.Models.PatchDeploymentsResponse2.g.cs @@ -14,5 +14,6 @@ public sealed partial class PatchDeploymentsResponse2 /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.PatchDeploymentsResponse3.g.cs b/src/libs/Together/Generated/Together.Models.PatchDeploymentsResponse3.g.cs index 9185fcec..1b0bfdc0 100644 --- a/src/libs/Together/Generated/Together.Models.PatchDeploymentsResponse3.g.cs +++ b/src/libs/Together/Generated/Together.Models.PatchDeploymentsResponse3.g.cs @@ -14,5 +14,6 @@ public sealed partial class PatchDeploymentsResponse3 /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.PatchDeploymentsSecretsResponse.g.cs b/src/libs/Together/Generated/Together.Models.PatchDeploymentsSecretsResponse.g.cs index dc95282e..1b8fa85d 100644 --- a/src/libs/Together/Generated/Together.Models.PatchDeploymentsSecretsResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.PatchDeploymentsSecretsResponse.g.cs @@ -14,5 +14,6 @@ public sealed partial class PatchDeploymentsSecretsResponse /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.PatchDeploymentsSecretsResponse2.g.cs b/src/libs/Together/Generated/Together.Models.PatchDeploymentsSecretsResponse2.g.cs index 82beca8e..1991e592 100644 --- a/src/libs/Together/Generated/Together.Models.PatchDeploymentsSecretsResponse2.g.cs +++ b/src/libs/Together/Generated/Together.Models.PatchDeploymentsSecretsResponse2.g.cs @@ -14,5 +14,6 @@ public sealed partial class PatchDeploymentsSecretsResponse2 /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.PatchDeploymentsSecretsResponse3.g.cs b/src/libs/Together/Generated/Together.Models.PatchDeploymentsSecretsResponse3.g.cs index ef05a296..1802cc36 100644 --- a/src/libs/Together/Generated/Together.Models.PatchDeploymentsSecretsResponse3.g.cs +++ b/src/libs/Together/Generated/Together.Models.PatchDeploymentsSecretsResponse3.g.cs @@ -14,5 +14,6 @@ public sealed partial class PatchDeploymentsSecretsResponse3 /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.PatchDeploymentsStorageVolumesResponse.g.cs b/src/libs/Together/Generated/Together.Models.PatchDeploymentsStorageVolumesResponse.g.cs index 24d7e1fe..a361856e 100644 --- a/src/libs/Together/Generated/Together.Models.PatchDeploymentsStorageVolumesResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.PatchDeploymentsStorageVolumesResponse.g.cs @@ -14,5 +14,6 @@ public sealed partial class PatchDeploymentsStorageVolumesResponse /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.PatchDeploymentsStorageVolumesResponse2.g.cs b/src/libs/Together/Generated/Together.Models.PatchDeploymentsStorageVolumesResponse2.g.cs index 5c4fb04d..84737596 100644 --- a/src/libs/Together/Generated/Together.Models.PatchDeploymentsStorageVolumesResponse2.g.cs +++ b/src/libs/Together/Generated/Together.Models.PatchDeploymentsStorageVolumesResponse2.g.cs @@ -14,5 +14,6 @@ public sealed partial class PatchDeploymentsStorageVolumesResponse2 /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.PatchDeploymentsStorageVolumesResponse3.g.cs b/src/libs/Together/Generated/Together.Models.PatchDeploymentsStorageVolumesResponse3.g.cs index 447baab7..f65321f7 100644 --- a/src/libs/Together/Generated/Together.Models.PatchDeploymentsStorageVolumesResponse3.g.cs +++ b/src/libs/Together/Generated/Together.Models.PatchDeploymentsStorageVolumesResponse3.g.cs @@ -14,5 +14,6 @@ public sealed partial class PatchDeploymentsStorageVolumesResponse3 /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.Pricing.g.cs b/src/libs/Together/Generated/Together.Models.Pricing.g.cs index 2f5008e9..fa79ff0b 100644 --- a/src/libs/Together/Generated/Together.Models.Pricing.g.cs +++ b/src/libs/Together/Generated/Together.Models.Pricing.g.cs @@ -8,6 +8,22 @@ namespace Together /// public sealed partial class Pricing { + /// + /// Example: 0 + /// + /// 0 + [global::System.Text.Json.Serialization.JsonPropertyName("base")] + [global::System.Text.Json.Serialization.JsonRequired] + public required double Base { get; set; } + + /// + /// Example: 0 + /// + /// 0 + [global::System.Text.Json.Serialization.JsonPropertyName("finetune")] + [global::System.Text.Json.Serialization.JsonRequired] + public required double Finetune { get; set; } + /// /// Example: 0 /// @@ -33,20 +49,11 @@ public sealed partial class Pricing public required double Output { get; set; } /// - /// Example: 0 + /// Example: 0.2 /// - /// 0 - [global::System.Text.Json.Serialization.JsonPropertyName("base")] - [global::System.Text.Json.Serialization.JsonRequired] - public required double Base { get; set; } - - /// - /// Example: 0 - /// - /// 0 - [global::System.Text.Json.Serialization.JsonPropertyName("finetune")] - [global::System.Text.Json.Serialization.JsonRequired] - public required double Finetune { get; set; } + /// 0.2 + [global::System.Text.Json.Serialization.JsonPropertyName("cached_input")] + public double? CachedInput { get; set; } /// /// Additional properties that are not explicitly defined in the schema @@ -57,6 +64,12 @@ public sealed partial class Pricing /// /// Initializes a new instance of the class. /// + /// + /// Example: 0 + /// + /// + /// Example: 0 + /// /// /// Example: 0 /// @@ -66,27 +79,26 @@ public sealed partial class Pricing /// /// Example: 0.3 /// - /// - /// Example: 0 - /// - /// - /// Example: 0 + /// + /// Example: 0.2 /// #if NET7_0_OR_GREATER [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] #endif public Pricing( + double @base, + double finetune, double hourly, double input, double output, - double @base, - double finetune) + double? cachedInput) { + this.Base = @base; + this.Finetune = finetune; this.Hourly = hourly; this.Input = input; this.Output = output; - this.Base = @base; - this.Finetune = finetune; + this.CachedInput = cachedInput; } /// @@ -95,5 +107,6 @@ public Pricing( public Pricing() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.PromptPartItem.g.cs b/src/libs/Together/Generated/Together.Models.PromptPartItem.g.cs index 080dfd38..d1d06c7d 100644 --- a/src/libs/Together/Generated/Together.Models.PromptPartItem.g.cs +++ b/src/libs/Together/Generated/Together.Models.PromptPartItem.g.cs @@ -51,5 +51,6 @@ public PromptPartItem( public PromptPartItem() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.QueueAutoscalingConfig.g.cs b/src/libs/Together/Generated/Together.Models.QueueAutoscalingConfig.g.cs index 8d3e2256..94d22d48 100644 --- a/src/libs/Together/Generated/Together.Models.QueueAutoscalingConfig.g.cs +++ b/src/libs/Together/Generated/Together.Models.QueueAutoscalingConfig.g.cs @@ -70,5 +70,6 @@ public QueueAutoscalingConfig( public QueueAutoscalingConfig() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.QueueCancelRequest.g.cs b/src/libs/Together/Generated/Together.Models.QueueCancelRequest.g.cs index 95463222..8bc2729f 100644 --- a/src/libs/Together/Generated/Together.Models.QueueCancelRequest.g.cs +++ b/src/libs/Together/Generated/Together.Models.QueueCancelRequest.g.cs @@ -54,5 +54,6 @@ public QueueCancelRequest( public QueueCancelRequest() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.QueueCancelResponse.g.cs b/src/libs/Together/Generated/Together.Models.QueueCancelResponse.g.cs index 863ee18a..15fffc1c 100644 --- a/src/libs/Together/Generated/Together.Models.QueueCancelResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.QueueCancelResponse.g.cs @@ -47,5 +47,6 @@ public QueueCancelResponse( public QueueCancelResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.QueueError.g.cs b/src/libs/Together/Generated/Together.Models.QueueError.g.cs index 81686fdd..2f272503 100644 --- a/src/libs/Together/Generated/Together.Models.QueueError.g.cs +++ b/src/libs/Together/Generated/Together.Models.QueueError.g.cs @@ -74,5 +74,6 @@ public QueueError( public QueueError() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.QueueJobRequest.g.cs b/src/libs/Together/Generated/Together.Models.QueueJobRequest.g.cs index 9bc4a660..fb059e6d 100644 --- a/src/libs/Together/Generated/Together.Models.QueueJobRequest.g.cs +++ b/src/libs/Together/Generated/Together.Models.QueueJobRequest.g.cs @@ -86,5 +86,6 @@ public QueueJobRequest( public QueueJobRequest() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.QueueJobRequestInfo.g.cs b/src/libs/Together/Generated/Together.Models.QueueJobRequestInfo.g.cs index 9081724d..7ac66287 100644 --- a/src/libs/Together/Generated/Together.Models.QueueJobRequestInfo.g.cs +++ b/src/libs/Together/Generated/Together.Models.QueueJobRequestInfo.g.cs @@ -16,5 +16,6 @@ public sealed partial class QueueJobRequestInfo /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.QueueJobRequestPayload.g.cs b/src/libs/Together/Generated/Together.Models.QueueJobRequestPayload.g.cs index f549d5cb..649e2e11 100644 --- a/src/libs/Together/Generated/Together.Models.QueueJobRequestPayload.g.cs +++ b/src/libs/Together/Generated/Together.Models.QueueJobRequestPayload.g.cs @@ -14,5 +14,6 @@ public sealed partial class QueueJobRequestPayload /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.QueueJobResponse.g.cs b/src/libs/Together/Generated/Together.Models.QueueJobResponse.g.cs index 4fcd3aa7..5231b348 100644 --- a/src/libs/Together/Generated/Together.Models.QueueJobResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.QueueJobResponse.g.cs @@ -50,5 +50,6 @@ public QueueJobResponse( public QueueJobResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.QueueJobStatusResponse.g.cs b/src/libs/Together/Generated/Together.Models.QueueJobStatusResponse.g.cs index f2725ba1..e8fda6dc 100644 --- a/src/libs/Together/Generated/Together.Models.QueueJobStatusResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.QueueJobStatusResponse.g.cs @@ -178,5 +178,6 @@ public QueueJobStatusResponse( public QueueJobStatusResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.QueueJobStatusResponseInfo.g.cs b/src/libs/Together/Generated/Together.Models.QueueJobStatusResponseInfo.g.cs index 2ff229a2..5fa583a9 100644 --- a/src/libs/Together/Generated/Together.Models.QueueJobStatusResponseInfo.g.cs +++ b/src/libs/Together/Generated/Together.Models.QueueJobStatusResponseInfo.g.cs @@ -16,5 +16,6 @@ public sealed partial class QueueJobStatusResponseInfo /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.QueueJobStatusResponseInputs.g.cs b/src/libs/Together/Generated/Together.Models.QueueJobStatusResponseInputs.g.cs index 4c7dc7fe..ba176efe 100644 --- a/src/libs/Together/Generated/Together.Models.QueueJobStatusResponseInputs.g.cs +++ b/src/libs/Together/Generated/Together.Models.QueueJobStatusResponseInputs.g.cs @@ -14,5 +14,6 @@ public sealed partial class QueueJobStatusResponseInputs /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.QueueJobStatusResponseOutputs.g.cs b/src/libs/Together/Generated/Together.Models.QueueJobStatusResponseOutputs.g.cs index 5d5b8894..6b99b846 100644 --- a/src/libs/Together/Generated/Together.Models.QueueJobStatusResponseOutputs.g.cs +++ b/src/libs/Together/Generated/Together.Models.QueueJobStatusResponseOutputs.g.cs @@ -14,5 +14,6 @@ public sealed partial class QueueJobStatusResponseOutputs /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.QueueMetricsResponse.g.cs b/src/libs/Together/Generated/Together.Models.QueueMetricsResponse.g.cs index 3a2a081a..d4e59c5a 100644 --- a/src/libs/Together/Generated/Together.Models.QueueMetricsResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.QueueMetricsResponse.g.cs @@ -66,5 +66,6 @@ public QueueMetricsResponse( public QueueMetricsResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RegionListResponse.g.cs b/src/libs/Together/Generated/Together.Models.RegionListResponse.g.cs index accefbfe..f88f7307 100644 --- a/src/libs/Together/Generated/Together.Models.RegionListResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.RegionListResponse.g.cs @@ -40,5 +40,6 @@ public RegionListResponse( public RegionListResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RegionListResponseRegion.g.cs b/src/libs/Together/Generated/Together.Models.RegionListResponseRegion.g.cs index 4d4a9b1f..bc91a21a 100644 --- a/src/libs/Together/Generated/Together.Models.RegionListResponseRegion.g.cs +++ b/src/libs/Together/Generated/Together.Models.RegionListResponseRegion.g.cs @@ -66,5 +66,6 @@ public RegionListResponseRegion( public RegionListResponseRegion() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ReplicaEvent.g.cs b/src/libs/Together/Generated/Together.Models.ReplicaEvent.g.cs index 0834c976..3b2b7f80 100644 --- a/src/libs/Together/Generated/Together.Models.ReplicaEvent.g.cs +++ b/src/libs/Together/Generated/Together.Models.ReplicaEvent.g.cs @@ -129,5 +129,6 @@ public ReplicaEvent( public ReplicaEvent() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RerankRequest.g.cs b/src/libs/Together/Generated/Together.Models.RerankRequest.g.cs index 39d362c8..bb742aed 100644 --- a/src/libs/Together/Generated/Together.Models.RerankRequest.g.cs +++ b/src/libs/Together/Generated/Together.Models.RerankRequest.g.cs @@ -119,5 +119,6 @@ public RerankRequest( public RerankRequest() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RerankRequestDocumentsVariant1Item.g.cs b/src/libs/Together/Generated/Together.Models.RerankRequestDocumentsVariant1Item.g.cs index 6a92f5d4..bf8cc7a1 100644 --- a/src/libs/Together/Generated/Together.Models.RerankRequestDocumentsVariant1Item.g.cs +++ b/src/libs/Together/Generated/Together.Models.RerankRequestDocumentsVariant1Item.g.cs @@ -14,5 +14,6 @@ public sealed partial class RerankRequestDocumentsVariant1Item /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RerankResponse.g.cs b/src/libs/Together/Generated/Together.Models.RerankResponse.g.cs index 58280d2b..6901eb13 100644 --- a/src/libs/Together/Generated/Together.Models.RerankResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.RerankResponse.g.cs @@ -93,5 +93,6 @@ public RerankResponse( public RerankResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RerankResponseObject.g.cs b/src/libs/Together/Generated/Together.Models.RerankResponseObject.g.cs index ebb7af3f..a4d61599 100644 --- a/src/libs/Together/Generated/Together.Models.RerankResponseObject.g.cs +++ b/src/libs/Together/Generated/Together.Models.RerankResponseObject.g.cs @@ -14,5 +14,6 @@ public sealed partial class RerankResponseObject /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RerankResponseResult.g.cs b/src/libs/Together/Generated/Together.Models.RerankResponseResult.g.cs index 831558ab..378d1704 100644 --- a/src/libs/Together/Generated/Together.Models.RerankResponseResult.g.cs +++ b/src/libs/Together/Generated/Together.Models.RerankResponseResult.g.cs @@ -60,5 +60,6 @@ public RerankResponseResult( public RerankResponseResult() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RerankResponseResultDocument.g.cs b/src/libs/Together/Generated/Together.Models.RerankResponseResultDocument.g.cs index b751f219..7270c22c 100644 --- a/src/libs/Together/Generated/Together.Models.RerankResponseResultDocument.g.cs +++ b/src/libs/Together/Generated/Together.Models.RerankResponseResultDocument.g.cs @@ -39,5 +39,6 @@ public RerankResponseResultDocument( public RerankResponseResultDocument() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.Response.g.cs b/src/libs/Together/Generated/Together.Models.Response.g.cs index 1fd5769d..2461a428 100644 --- a/src/libs/Together/Generated/Together.Models.Response.g.cs +++ b/src/libs/Together/Generated/Together.Models.Response.g.cs @@ -39,5 +39,6 @@ public Response( public Response() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ResponseError.g.cs b/src/libs/Together/Generated/Together.Models.ResponseError.g.cs index 33feb070..9884e7db 100644 --- a/src/libs/Together/Generated/Together.Models.ResponseError.g.cs +++ b/src/libs/Together/Generated/Together.Models.ResponseError.g.cs @@ -14,5 +14,6 @@ public sealed partial class ResponseError /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ResponseFormat.g.cs b/src/libs/Together/Generated/Together.Models.ResponseFormat.g.cs index 5700083f..9f966da7 100644 --- a/src/libs/Together/Generated/Together.Models.ResponseFormat.g.cs +++ b/src/libs/Together/Generated/Together.Models.ResponseFormat.g.cs @@ -16,6 +16,11 @@ namespace Together /// public readonly partial struct ResponseFormat : global::System.IEquatable { + /// + /// + /// + public global::Together.ChatCompletionRequestResponseFormatDiscriminatorType? Type { get; } + /// /// Default response format. Used to generate text responses. /// @@ -33,6 +38,26 @@ namespace Together #endif public bool IsText => Text != null; + /// + /// + /// + public bool TryPickText( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Together.ResponseFormatText? value) + { + value = Text; + return IsText; + } + + /// + /// + /// + public global::Together.ResponseFormatText PickText() => IsText + ? Text! + : throw new global::System.InvalidOperationException($"Expected union variant 'Text' but the value was {ToString()}."); + /// /// JSON Schema response format. Used to generate structured JSON responses.
/// Learn more about [Structured Outputs](https://docs.together.ai/docs/json-mode). @@ -51,6 +76,26 @@ namespace Together #endif public bool IsJsonSchema => JsonSchema != null; + /// + /// + /// + public bool TryPickJsonSchema( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Together.ResponseFormatJsonSchema? value) + { + value = JsonSchema; + return IsJsonSchema; + } + + /// + /// + /// + public global::Together.ResponseFormatJsonSchema PickJsonSchema() => IsJsonSchema + ? JsonSchema! + : throw new global::System.InvalidOperationException($"Expected union variant 'JsonSchema' but the value was {ToString()}."); + /// /// JSON object response format. An older method of generating JSON responses.
/// Using `json_schema` is recommended for models that support it. Note that the
@@ -70,6 +115,26 @@ namespace Together [global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(JsonObject))] #endif public bool IsJsonObject => JsonObject != null; + + /// + /// + /// + public bool TryPickJsonObject( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Together.ResponseFormatJsonObject? value) + { + value = JsonObject; + return IsJsonObject; + } + + /// + /// + /// + public global::Together.ResponseFormatJsonObject PickJsonObject() => IsJsonObject + ? JsonObject! + : throw new global::System.InvalidOperationException($"Expected union variant 'JsonObject' but the value was {ToString()}."); /// /// /// @@ -88,6 +153,11 @@ public ResponseFormat(global::Together.ResponseFormatText? value) Text = value; } + /// + /// + /// + public static ResponseFormat FromText(global::Together.ResponseFormatText? value) => new ResponseFormat(value); + /// /// /// @@ -106,6 +176,11 @@ public ResponseFormat(global::Together.ResponseFormatJsonSchema? value) JsonSchema = value; } + /// + /// + /// + public static ResponseFormat FromJsonSchema(global::Together.ResponseFormatJsonSchema? value) => new ResponseFormat(value); + /// /// /// @@ -124,15 +199,23 @@ public ResponseFormat(global::Together.ResponseFormatJsonObject? value) JsonObject = value; } + /// + /// + /// + public static ResponseFormat FromJsonObject(global::Together.ResponseFormatJsonObject? value) => new ResponseFormat(value); + /// /// /// public ResponseFormat( + global::Together.ChatCompletionRequestResponseFormatDiscriminatorType? type, global::Together.ResponseFormatText? text, global::Together.ResponseFormatJsonSchema? jsonSchema, global::Together.ResponseFormatJsonObject? jsonObject ) { + Type = type; + Text = text; JsonSchema = jsonSchema; JsonObject = jsonObject; @@ -168,9 +251,9 @@ public bool Validate() /// ///
public TResult? Match( - global::System.Func? text = null, - global::System.Func? jsonSchema = null, - global::System.Func? jsonObject = null, + global::System.Func? text = null, + global::System.Func? jsonSchema = null, + global::System.Func? jsonObject = null, bool validate = true) { if (validate) @@ -198,9 +281,39 @@ public bool Validate() /// ///
public void Match( - global::System.Action? text = null, - global::System.Action? jsonSchema = null, - global::System.Action? jsonObject = null, + global::System.Action? text = null, + + global::System.Action? jsonSchema = null, + + global::System.Action? jsonObject = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (IsText) + { + text?.Invoke(Text!); + } + else if (IsJsonSchema) + { + jsonSchema?.Invoke(JsonSchema!); + } + else if (IsJsonObject) + { + jsonObject?.Invoke(JsonObject!); + } + } + + /// + /// + /// + public void Switch( + global::System.Action? text = null, + global::System.Action? jsonSchema = null, + global::System.Action? jsonObject = null, bool validate = true) { if (validate) diff --git a/src/libs/Together/Generated/Together.Models.ResponseFormatJsonObject.g.cs b/src/libs/Together/Generated/Together.Models.ResponseFormatJsonObject.g.cs index 5d0ab291..95efda93 100644 --- a/src/libs/Together/Generated/Together.Models.ResponseFormatJsonObject.g.cs +++ b/src/libs/Together/Generated/Together.Models.ResponseFormatJsonObject.g.cs @@ -45,5 +45,6 @@ public ResponseFormatJsonObject( public ResponseFormatJsonObject() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ResponseFormatJsonSchema.g.cs b/src/libs/Together/Generated/Together.Models.ResponseFormatJsonSchema.g.cs index 3d68b5e2..a096c924 100644 --- a/src/libs/Together/Generated/Together.Models.ResponseFormatJsonSchema.g.cs +++ b/src/libs/Together/Generated/Together.Models.ResponseFormatJsonSchema.g.cs @@ -55,5 +55,6 @@ public ResponseFormatJsonSchema( public ResponseFormatJsonSchema() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ResponseFormatJsonSchemaJsonSchema.g.cs b/src/libs/Together/Generated/Together.Models.ResponseFormatJsonSchemaJsonSchema.g.cs index 625ce247..6e10f8ee 100644 --- a/src/libs/Together/Generated/Together.Models.ResponseFormatJsonSchemaJsonSchema.g.cs +++ b/src/libs/Together/Generated/Together.Models.ResponseFormatJsonSchemaJsonSchema.g.cs @@ -79,5 +79,6 @@ public ResponseFormatJsonSchemaJsonSchema( public ResponseFormatJsonSchemaJsonSchema() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ResponseFormatJsonSchemaJsonSchemaStrict.g.cs b/src/libs/Together/Generated/Together.Models.ResponseFormatJsonSchemaJsonSchemaStrict.g.cs index 140871ad..8603c554 100644 --- a/src/libs/Together/Generated/Together.Models.ResponseFormatJsonSchemaJsonSchemaStrict.g.cs +++ b/src/libs/Together/Generated/Together.Models.ResponseFormatJsonSchemaJsonSchemaStrict.g.cs @@ -14,5 +14,6 @@ public sealed partial class ResponseFormatJsonSchemaJsonSchemaStrict /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ResponseFormatJsonSchemaSchema.g.cs b/src/libs/Together/Generated/Together.Models.ResponseFormatJsonSchemaSchema.g.cs index a7037d51..d6c713ba 100644 --- a/src/libs/Together/Generated/Together.Models.ResponseFormatJsonSchemaSchema.g.cs +++ b/src/libs/Together/Generated/Together.Models.ResponseFormatJsonSchemaSchema.g.cs @@ -15,5 +15,6 @@ public sealed partial class ResponseFormatJsonSchemaSchema /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ResponseFormatText.g.cs b/src/libs/Together/Generated/Together.Models.ResponseFormatText.g.cs index bbbb0107..24ba3c1f 100644 --- a/src/libs/Together/Generated/Together.Models.ResponseFormatText.g.cs +++ b/src/libs/Together/Generated/Together.Models.ResponseFormatText.g.cs @@ -42,5 +42,6 @@ public ResponseFormatText( public ResponseFormatText() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlAdamWOptimizerParams.g.cs b/src/libs/Together/Generated/Together.Models.RlAdamWOptimizerParams.g.cs index 65d41b62..0a6e374b 100644 --- a/src/libs/Together/Generated/Together.Models.RlAdamWOptimizerParams.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlAdamWOptimizerParams.g.cs @@ -94,5 +94,6 @@ public RlAdamWOptimizerParams( public RlAdamWOptimizerParams() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlCheckpointDownloadResponse.g.cs b/src/libs/Together/Generated/Together.Models.RlCheckpointDownloadResponse.g.cs index eb476c14..3febba60 100644 --- a/src/libs/Together/Generated/Together.Models.RlCheckpointDownloadResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlCheckpointDownloadResponse.g.cs @@ -42,5 +42,6 @@ public RlCheckpointDownloadResponse( public RlCheckpointDownloadResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlCheckpointFile.g.cs b/src/libs/Together/Generated/Together.Models.RlCheckpointFile.g.cs index 5c61d0a5..1c074d28 100644 --- a/src/libs/Together/Generated/Together.Models.RlCheckpointFile.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlCheckpointFile.g.cs @@ -32,8 +32,9 @@ public sealed partial class RlCheckpointFile /// /// 123456789 [global::System.Text.Json.Serialization.JsonPropertyName("size")] + [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Together.JsonConverters.OneOfJsonConverter))] [global::System.Text.Json.Serialization.JsonRequired] - public required string Size { get; set; } + public required global::Together.OneOf Size { get; set; } /// /// Additional properties that are not explicitly defined in the schema @@ -62,11 +63,11 @@ public sealed partial class RlCheckpointFile public RlCheckpointFile( string filename, string url, - string size) + global::Together.OneOf size) { this.Filename = filename ?? throw new global::System.ArgumentNullException(nameof(filename)); this.Url = url ?? throw new global::System.ArgumentNullException(nameof(url)); - this.Size = size ?? throw new global::System.ArgumentNullException(nameof(size)); + this.Size = size; } /// @@ -75,5 +76,6 @@ public RlCheckpointFile( public RlCheckpointFile() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlCrossEntropyLossParams.g.cs b/src/libs/Together/Generated/Together.Models.RlCrossEntropyLossParams.g.cs index 30f28412..d9dd3c96 100644 --- a/src/libs/Together/Generated/Together.Models.RlCrossEntropyLossParams.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlCrossEntropyLossParams.g.cs @@ -14,5 +14,6 @@ public sealed partial class RlCrossEntropyLossParams /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlEncodedText.g.cs b/src/libs/Together/Generated/Together.Models.RlEncodedText.g.cs index 23b6b70e..d8b055ed 100644 --- a/src/libs/Together/Generated/Together.Models.RlEncodedText.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlEncodedText.g.cs @@ -45,5 +45,6 @@ public RlEncodedText( public RlEncodedText() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlForwardBackwardBody.g.cs b/src/libs/Together/Generated/Together.Models.RlForwardBackwardBody.g.cs index b1a2f3ba..63af51b4 100644 --- a/src/libs/Together/Generated/Together.Models.RlForwardBackwardBody.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlForwardBackwardBody.g.cs @@ -54,5 +54,6 @@ public RlForwardBackwardBody( public RlForwardBackwardBody() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlForwardBackwardOperation.g.cs b/src/libs/Together/Generated/Together.Models.RlForwardBackwardOperation.g.cs index fbc3a41a..02ee82ae 100644 --- a/src/libs/Together/Generated/Together.Models.RlForwardBackwardOperation.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlForwardBackwardOperation.g.cs @@ -83,5 +83,6 @@ public RlForwardBackwardOperation( public RlForwardBackwardOperation() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlForwardBackwardResult.g.cs b/src/libs/Together/Generated/Together.Models.RlForwardBackwardResult.g.cs index 15074ebf..23ebfa90 100644 --- a/src/libs/Together/Generated/Together.Models.RlForwardBackwardResult.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlForwardBackwardResult.g.cs @@ -59,5 +59,6 @@ public RlForwardBackwardResult( public RlForwardBackwardResult() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlForwardBackwardResultMetrics.g.cs b/src/libs/Together/Generated/Together.Models.RlForwardBackwardResultMetrics.g.cs index 1a780671..fa1f44f2 100644 --- a/src/libs/Together/Generated/Together.Models.RlForwardBackwardResultMetrics.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlForwardBackwardResultMetrics.g.cs @@ -15,5 +15,6 @@ public sealed partial class RlForwardBackwardResultMetrics /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlGRPOLossInputs.g.cs b/src/libs/Together/Generated/Together.Models.RlGRPOLossInputs.g.cs index b5857c59..ab7ede0c 100644 --- a/src/libs/Together/Generated/Together.Models.RlGRPOLossInputs.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlGRPOLossInputs.g.cs @@ -65,5 +65,6 @@ public RlGRPOLossInputs( public RlGRPOLossInputs() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlGRPOLossParams.g.cs b/src/libs/Together/Generated/Together.Models.RlGRPOLossParams.g.cs index 3b066862..03ab8a1f 100644 --- a/src/libs/Together/Generated/Together.Models.RlGRPOLossParams.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlGRPOLossParams.g.cs @@ -92,5 +92,6 @@ public RlGRPOLossParams( public RlGRPOLossParams() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlInferenceCheckpoint.g.cs b/src/libs/Together/Generated/Together.Models.RlInferenceCheckpoint.g.cs index a6091c55..902eabf2 100644 --- a/src/libs/Together/Generated/Together.Models.RlInferenceCheckpoint.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlInferenceCheckpoint.g.cs @@ -23,8 +23,9 @@ public sealed partial class RlInferenceCheckpoint /// /// 42 [global::System.Text.Json.Serialization.JsonPropertyName("step")] + [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Together.JsonConverters.OneOfJsonConverter))] [global::System.Text.Json.Serialization.JsonRequired] - public required string Step { get; set; } + public required global::Together.OneOf Step { get; set; } /// /// Timestamp when the checkpoint was created
@@ -70,12 +71,12 @@ public sealed partial class RlInferenceCheckpoint #endif public RlInferenceCheckpoint( string id, - string step, + global::Together.OneOf step, global::System.DateTime createdAt, global::Together.RlInferenceCheckpointRegistration? registration) { this.Id = id ?? throw new global::System.ArgumentNullException(nameof(id)); - this.Step = step ?? throw new global::System.ArgumentNullException(nameof(step)); + this.Step = step; this.CreatedAt = createdAt; this.Registration = registration; } @@ -86,5 +87,6 @@ public RlInferenceCheckpoint( public RlInferenceCheckpoint() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlInferenceCheckpointOperation.g.cs b/src/libs/Together/Generated/Together.Models.RlInferenceCheckpointOperation.g.cs index 61101baa..53a17dc5 100644 --- a/src/libs/Together/Generated/Together.Models.RlInferenceCheckpointOperation.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlInferenceCheckpointOperation.g.cs @@ -83,5 +83,6 @@ public RlInferenceCheckpointOperation( public RlInferenceCheckpointOperation() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlInferenceCheckpointRegistration.g.cs b/src/libs/Together/Generated/Together.Models.RlInferenceCheckpointRegistration.g.cs index 5adf993e..7e06f96d 100644 --- a/src/libs/Together/Generated/Together.Models.RlInferenceCheckpointRegistration.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlInferenceCheckpointRegistration.g.cs @@ -60,5 +60,6 @@ public RlInferenceCheckpointRegistration( public RlInferenceCheckpointRegistration() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlInferenceCheckpointResult.g.cs b/src/libs/Together/Generated/Together.Models.RlInferenceCheckpointResult.g.cs index 68cee928..44326576 100644 --- a/src/libs/Together/Generated/Together.Models.RlInferenceCheckpointResult.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlInferenceCheckpointResult.g.cs @@ -45,5 +45,6 @@ public RlInferenceCheckpointResult( public RlInferenceCheckpointResult() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlInputChunk.g.cs b/src/libs/Together/Generated/Together.Models.RlInputChunk.g.cs index 52efe6c8..76671d43 100644 --- a/src/libs/Together/Generated/Together.Models.RlInputChunk.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlInputChunk.g.cs @@ -39,5 +39,6 @@ public RlInputChunk( public RlInputChunk() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlListMeta.g.cs b/src/libs/Together/Generated/Together.Models.RlListMeta.g.cs index ba940bb1..7e3b088d 100644 --- a/src/libs/Together/Generated/Together.Models.RlListMeta.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlListMeta.g.cs @@ -72,5 +72,6 @@ public RlListMeta( public RlListMeta() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlLoraConfig.g.cs b/src/libs/Together/Generated/Together.Models.RlLoraConfig.g.cs index 35fc12ee..6c801588 100644 --- a/src/libs/Together/Generated/Together.Models.RlLoraConfig.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlLoraConfig.g.cs @@ -35,6 +35,15 @@ public sealed partial class RlLoraConfig [global::System.Text.Json.Serialization.JsonPropertyName("dropout")] public float? Dropout { get; set; } + /// + /// Whether to enable LoRA fine-tuning. If false, full fine-tuning is used.
+ /// Default Value: true
+ /// Example: true + ///
+ /// true + [global::System.Text.Json.Serialization.JsonPropertyName("enable")] + public bool? Enable { get; set; } + /// /// Additional properties that are not explicitly defined in the schema /// @@ -59,17 +68,24 @@ public sealed partial class RlLoraConfig /// Default Value: 0.05
/// Example: 0.05 /// + /// + /// Whether to enable LoRA fine-tuning. If false, full fine-tuning is used.
+ /// Default Value: true
+ /// Example: true + /// #if NET7_0_OR_GREATER [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] #endif public RlLoraConfig( long? rank, long? alpha, - float? dropout) + float? dropout, + bool? enable) { this.Rank = rank; this.Alpha = alpha; this.Dropout = dropout; + this.Enable = enable; } /// @@ -78,5 +94,6 @@ public RlLoraConfig( public RlLoraConfig() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlLossAdvantages.g.cs b/src/libs/Together/Generated/Together.Models.RlLossAdvantages.g.cs index c6055aef..8294e6d9 100644 --- a/src/libs/Together/Generated/Together.Models.RlLossAdvantages.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlLossAdvantages.g.cs @@ -59,5 +59,6 @@ public RlLossAdvantages( public RlLossAdvantages() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlLossConfig.g.cs b/src/libs/Together/Generated/Together.Models.RlLossConfig.g.cs index 11b45328..ec88d968 100644 --- a/src/libs/Together/Generated/Together.Models.RlLossConfig.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlLossConfig.g.cs @@ -66,5 +66,6 @@ public RlLossConfig( public RlLossConfig() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlLossInputs.g.cs b/src/libs/Together/Generated/Together.Models.RlLossInputs.g.cs index 10af3dc9..3489d834 100644 --- a/src/libs/Together/Generated/Together.Models.RlLossInputs.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlLossInputs.g.cs @@ -62,5 +62,6 @@ public RlLossInputs( public RlLossInputs() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlLossLogprobs.g.cs b/src/libs/Together/Generated/Together.Models.RlLossLogprobs.g.cs index d653892b..8e98de67 100644 --- a/src/libs/Together/Generated/Together.Models.RlLossLogprobs.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlLossLogprobs.g.cs @@ -59,5 +59,6 @@ public RlLossLogprobs( public RlLossLogprobs() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlLossMask.g.cs b/src/libs/Together/Generated/Together.Models.RlLossMask.g.cs index 41e58c72..84da517a 100644 --- a/src/libs/Together/Generated/Together.Models.RlLossMask.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlLossMask.g.cs @@ -59,5 +59,6 @@ public RlLossMask( public RlLossMask() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlLossTargetTokens.g.cs b/src/libs/Together/Generated/Together.Models.RlLossTargetTokens.g.cs index bbb1ba94..f43e6dd9 100644 --- a/src/libs/Together/Generated/Together.Models.RlLossTargetTokens.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlLossTargetTokens.g.cs @@ -59,5 +59,6 @@ public RlLossTargetTokens( public RlLossTargetTokens() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlModelInput.g.cs b/src/libs/Together/Generated/Together.Models.RlModelInput.g.cs index d726c9e7..5335b1ff 100644 --- a/src/libs/Together/Generated/Together.Models.RlModelInput.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlModelInput.g.cs @@ -42,5 +42,6 @@ public RlModelInput( public RlModelInput() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlOptimStepBody.g.cs b/src/libs/Together/Generated/Together.Models.RlOptimStepBody.g.cs index 29320f98..a9938cc4 100644 --- a/src/libs/Together/Generated/Together.Models.RlOptimStepBody.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlOptimStepBody.g.cs @@ -57,5 +57,6 @@ public RlOptimStepBody( public RlOptimStepBody() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlOptimStepOperation.g.cs b/src/libs/Together/Generated/Together.Models.RlOptimStepOperation.g.cs index fff8618b..5bf44680 100644 --- a/src/libs/Together/Generated/Together.Models.RlOptimStepOperation.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlOptimStepOperation.g.cs @@ -83,5 +83,6 @@ public RlOptimStepOperation( public RlOptimStepOperation() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlOptimStepResult.g.cs b/src/libs/Together/Generated/Together.Models.RlOptimStepResult.g.cs index 897d0b17..4e3ec3e0 100644 --- a/src/libs/Together/Generated/Together.Models.RlOptimStepResult.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlOptimStepResult.g.cs @@ -14,8 +14,9 @@ public sealed partial class RlOptimStepResult /// /// 100 [global::System.Text.Json.Serialization.JsonPropertyName("step")] + [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Together.JsonConverters.OneOfJsonConverter))] [global::System.Text.Json.Serialization.JsonRequired] - public required string Step { get; set; } + public required global::Together.OneOf Step { get; set; } /// /// Additional properties that are not explicitly defined in the schema @@ -34,9 +35,9 @@ public sealed partial class RlOptimStepResult [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] #endif public RlOptimStepResult( - string step) + global::Together.OneOf step) { - this.Step = step ?? throw new global::System.ArgumentNullException(nameof(step)); + this.Step = step; } /// @@ -45,5 +46,6 @@ public RlOptimStepResult( public RlOptimStepResult() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlSampleBody.g.cs b/src/libs/Together/Generated/Together.Models.RlSampleBody.g.cs index a08b4541..4e05033d 100644 --- a/src/libs/Together/Generated/Together.Models.RlSampleBody.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlSampleBody.g.cs @@ -69,5 +69,6 @@ public RlSampleBody( public RlSampleBody() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlSampleOperation.g.cs b/src/libs/Together/Generated/Together.Models.RlSampleOperation.g.cs index e5b1c6b8..80e9e632 100644 --- a/src/libs/Together/Generated/Together.Models.RlSampleOperation.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlSampleOperation.g.cs @@ -83,5 +83,6 @@ public RlSampleOperation( public RlSampleOperation() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlSampleResult.g.cs b/src/libs/Together/Generated/Together.Models.RlSampleResult.g.cs index f8415f64..0fe56a8d 100644 --- a/src/libs/Together/Generated/Together.Models.RlSampleResult.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlSampleResult.g.cs @@ -42,5 +42,6 @@ public RlSampleResult( public RlSampleResult() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlSampleRollout.g.cs b/src/libs/Together/Generated/Together.Models.RlSampleRollout.g.cs index a24ba539..dbdfa5dc 100644 --- a/src/libs/Together/Generated/Together.Models.RlSampleRollout.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlSampleRollout.g.cs @@ -42,5 +42,6 @@ public RlSampleRollout( public RlSampleRollout() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlSampleSequence.g.cs b/src/libs/Together/Generated/Together.Models.RlSampleSequence.g.cs index 2d454d04..c6ed960d 100644 --- a/src/libs/Together/Generated/Together.Models.RlSampleSequence.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlSampleSequence.g.cs @@ -15,7 +15,7 @@ public sealed partial class RlSampleSequence /// [123, 456, 789] [global::System.Text.Json.Serialization.JsonPropertyName("tokens")] [global::System.Text.Json.Serialization.JsonRequired] - public required global::System.Collections.Generic.IList Tokens { get; set; } + public required global::System.Collections.Generic.IList> Tokens { get; set; } /// /// Log probabilities for each generated token
@@ -58,7 +58,7 @@ public sealed partial class RlSampleSequence [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] #endif public RlSampleSequence( - global::System.Collections.Generic.IList tokens, + global::System.Collections.Generic.IList> tokens, global::System.Collections.Generic.IList? logprobs, string? stopReason) { @@ -73,5 +73,6 @@ public RlSampleSequence( public RlSampleSequence() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlSamplingParams.g.cs b/src/libs/Together/Generated/Together.Models.RlSamplingParams.g.cs index 9ecb8a86..b95265fa 100644 --- a/src/libs/Together/Generated/Together.Models.RlSamplingParams.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlSamplingParams.g.cs @@ -58,7 +58,8 @@ public sealed partial class RlSamplingParams ///
/// 42 [global::System.Text.Json.Serialization.JsonPropertyName("seed")] - public string? Seed { get; set; } + [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Together.JsonConverters.OneOfJsonConverter))] + public global::Together.OneOf? Seed { get; set; } /// /// Additional properties that are not explicitly defined in the schema @@ -106,7 +107,7 @@ public RlSamplingParams( float? topP, int? topK, global::System.Collections.Generic.IList? stop, - string? seed) + global::Together.OneOf? seed) { this.MaxTokens = maxTokens; this.Temperature = temperature; @@ -122,5 +123,6 @@ public RlSamplingParams( public RlSamplingParams() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlSessionType.g.cs b/src/libs/Together/Generated/Together.Models.RlSessionType.g.cs new file mode 100644 index 00000000..14ccfb9a --- /dev/null +++ b/src/libs/Together/Generated/Together.Models.RlSessionType.g.cs @@ -0,0 +1,58 @@ + +#nullable enable + +namespace Together +{ + /// + /// Type of a training session. TRAINER_AND_GENERATOR provisions both trainer and generator; TRAINER_ONLY provisions only the trainer and rejects generator-dependent operations such as sample.
+ /// Default Value: SESSION_TYPE_UNSPECIFIED + ///
+ public enum RlSessionType + { + /// + /// + /// + SessionTypeTrainerAndGenerator, + /// + /// + /// + SessionTypeTrainerOnly, + /// + /// + /// + SessionTypeUnspecified, + } + + /// + /// Enum extensions to do fast conversions without the reflection. + /// + public static class RlSessionTypeExtensions + { + /// + /// Converts an enum to a string. + /// + public static string ToValueString(this RlSessionType value) + { + return value switch + { + RlSessionType.SessionTypeTrainerAndGenerator => "SESSION_TYPE_TRAINER_AND_GENERATOR", + RlSessionType.SessionTypeTrainerOnly => "SESSION_TYPE_TRAINER_ONLY", + RlSessionType.SessionTypeUnspecified => "SESSION_TYPE_UNSPECIFIED", + _ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null), + }; + } + /// + /// Converts an string to a enum. + /// + public static RlSessionType? ToEnum(string value) + { + return value switch + { + "SESSION_TYPE_TRAINER_AND_GENERATOR" => RlSessionType.SessionTypeTrainerAndGenerator, + "SESSION_TYPE_TRAINER_ONLY" => RlSessionType.SessionTypeTrainerOnly, + "SESSION_TYPE_UNSPECIFIED" => RlSessionType.SessionTypeUnspecified, + _ => null, + }; + } + } +} \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlStartTrainingSessionRequest.g.cs b/src/libs/Together/Generated/Together.Models.RlStartTrainingSessionRequest.g.cs index 030c9360..134e179b 100644 --- a/src/libs/Together/Generated/Together.Models.RlStartTrainingSessionRequest.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlStartTrainingSessionRequest.g.cs @@ -25,6 +25,14 @@ public sealed partial class RlStartTrainingSessionRequest [global::System.Text.Json.Serialization.JsonPropertyName("resume_from_checkpoint_id")] public string? ResumeFromCheckpointId { get; set; } + /// + /// Type of the training session. Defaults to TRAINER_AND_GENERATOR when unspecified. TRAINER_ONLY provisions only the trainer and rejects sample requests.
+ /// Default Value: SESSION_TYPE_TRAINER_AND_GENERATOR + ///
+ [global::System.Text.Json.Serialization.JsonPropertyName("type")] + [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Together.JsonConverters.RlSessionTypeJsonConverter))] + public global::Together.RlSessionType? Type { get; set; } + /// /// LoRA adapter configuration /// @@ -48,6 +56,10 @@ public sealed partial class RlStartTrainingSessionRequest /// Checkpoint ID to resume from
/// Example: 123e4567-e89b-12d3-a456-426614174000 /// + /// + /// Type of the training session. Defaults to TRAINER_AND_GENERATOR when unspecified. TRAINER_ONLY provisions only the trainer and rejects sample requests.
+ /// Default Value: SESSION_TYPE_TRAINER_AND_GENERATOR + /// /// /// LoRA adapter configuration /// @@ -57,10 +69,12 @@ public sealed partial class RlStartTrainingSessionRequest public RlStartTrainingSessionRequest( string baseModel, string? resumeFromCheckpointId, + global::Together.RlSessionType? type, global::Together.RlLoraConfig? loraConfig) { this.BaseModel = baseModel ?? throw new global::System.ArgumentNullException(nameof(baseModel)); this.ResumeFromCheckpointId = resumeFromCheckpointId; + this.Type = type; this.LoraConfig = loraConfig; } @@ -70,5 +84,6 @@ public RlStartTrainingSessionRequest( public RlStartTrainingSessionRequest() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlTrainingCheckpoint.g.cs b/src/libs/Together/Generated/Together.Models.RlTrainingCheckpoint.g.cs index af57c234..0330c70f 100644 --- a/src/libs/Together/Generated/Together.Models.RlTrainingCheckpoint.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlTrainingCheckpoint.g.cs @@ -23,8 +23,9 @@ public sealed partial class RlTrainingCheckpoint ///
/// 42 [global::System.Text.Json.Serialization.JsonPropertyName("step")] + [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Together.JsonConverters.OneOfJsonConverter))] [global::System.Text.Json.Serialization.JsonRequired] - public required string Step { get; set; } + public required global::Together.OneOf Step { get; set; } /// /// Timestamp when the checkpoint was created
@@ -61,11 +62,11 @@ public sealed partial class RlTrainingCheckpoint #endif public RlTrainingCheckpoint( string id, - string step, + global::Together.OneOf step, global::System.DateTime createdAt) { this.Id = id ?? throw new global::System.ArgumentNullException(nameof(id)); - this.Step = step ?? throw new global::System.ArgumentNullException(nameof(step)); + this.Step = step; this.CreatedAt = createdAt; } @@ -75,5 +76,6 @@ public RlTrainingCheckpoint( public RlTrainingCheckpoint() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlTrainingCheckpointOperation.g.cs b/src/libs/Together/Generated/Together.Models.RlTrainingCheckpointOperation.g.cs index 92a3e04a..9ffd1ee9 100644 --- a/src/libs/Together/Generated/Together.Models.RlTrainingCheckpointOperation.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlTrainingCheckpointOperation.g.cs @@ -83,5 +83,6 @@ public RlTrainingCheckpointOperation( public RlTrainingCheckpointOperation() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlTrainingCheckpointResult.g.cs b/src/libs/Together/Generated/Together.Models.RlTrainingCheckpointResult.g.cs index 5068f2be..a145eae4 100644 --- a/src/libs/Together/Generated/Together.Models.RlTrainingCheckpointResult.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlTrainingCheckpointResult.g.cs @@ -45,5 +45,6 @@ public RlTrainingCheckpointResult( public RlTrainingCheckpointResult() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlTrainingOperationError.g.cs b/src/libs/Together/Generated/Together.Models.RlTrainingOperationError.g.cs index 95239333..678e8648 100644 --- a/src/libs/Together/Generated/Together.Models.RlTrainingOperationError.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlTrainingOperationError.g.cs @@ -58,5 +58,6 @@ public RlTrainingOperationError( public RlTrainingOperationError() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlTrainingSample.g.cs b/src/libs/Together/Generated/Together.Models.RlTrainingSample.g.cs index 9ce41502..0f812b9d 100644 --- a/src/libs/Together/Generated/Together.Models.RlTrainingSample.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlTrainingSample.g.cs @@ -54,5 +54,6 @@ public RlTrainingSample( public RlTrainingSample() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlTrainingSession.g.cs b/src/libs/Together/Generated/Together.Models.RlTrainingSession.g.cs index c658a330..4aa387c9 100644 --- a/src/libs/Together/Generated/Together.Models.RlTrainingSession.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlTrainingSession.g.cs @@ -66,8 +66,9 @@ public sealed partial class RlTrainingSession /// "0" /// 100 [global::System.Text.Json.Serialization.JsonPropertyName("step")] + [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Together.JsonConverters.OneOfJsonConverter))] [global::System.Text.Json.Serialization.JsonRequired] - public required string Step { get; set; } = "0"; + public required global::Together.OneOf Step { get; set; } = "0"; /// /// Timestamp when the training session was created
@@ -94,6 +95,16 @@ public sealed partial class RlTrainingSession [global::System.Text.Json.Serialization.JsonRequired] public required global::Together.RlLoraConfig LoraConfig { get; set; } + /// + /// Type of the training session. TRAINER_AND_GENERATOR provisions both trainer and generator; TRAINER_ONLY provisions only the trainer and rejects generator-dependent operations such as sample.
+ /// Default Value: SESSION_TYPE_UNSPECIFIED + ///
+ /// global::Together.RlSessionType.SessionTypeUnspecified + [global::System.Text.Json.Serialization.JsonPropertyName("type")] + [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Together.JsonConverters.RlSessionTypeJsonConverter))] + [global::System.Text.Json.Serialization.JsonRequired] + public required global::Together.RlSessionType Type { get; set; } = global::Together.RlSessionType.SessionTypeUnspecified; + /// /// Additional properties that are not explicitly defined in the schema /// @@ -137,6 +148,10 @@ public sealed partial class RlTrainingSession /// /// LoRA adapter configuration /// + /// + /// Type of the training session. TRAINER_AND_GENERATOR provisions both trainer and generator; TRAINER_ONLY provisions only the trainer and rejects generator-dependent operations such as sample.
+ /// Default Value: SESSION_TYPE_UNSPECIFIED + /// /// /// Checkpoint ID this session was resumed from
/// Example: 123e4567-e89b-12d3-a456-426614174000 @@ -150,10 +165,11 @@ public RlTrainingSession( string baseModel, global::System.Collections.Generic.IList inferenceCheckpoints, global::System.Collections.Generic.IList trainingCheckpoints, - string step, + global::Together.OneOf step, global::System.DateTime createdAt, global::System.DateTime updatedAt, global::Together.RlLoraConfig loraConfig, + global::Together.RlSessionType type, string? resumeFromCheckpointId) { this.Id = id ?? throw new global::System.ArgumentNullException(nameof(id)); @@ -162,10 +178,11 @@ public RlTrainingSession( this.InferenceCheckpoints = inferenceCheckpoints ?? throw new global::System.ArgumentNullException(nameof(inferenceCheckpoints)); this.TrainingCheckpoints = trainingCheckpoints ?? throw new global::System.ArgumentNullException(nameof(trainingCheckpoints)); this.ResumeFromCheckpointId = resumeFromCheckpointId; - this.Step = step ?? throw new global::System.ArgumentNullException(nameof(step)); + this.Step = step; this.CreatedAt = createdAt; this.UpdatedAt = updatedAt; this.LoraConfig = loraConfig ?? throw new global::System.ArgumentNullException(nameof(loraConfig)); + this.Type = type; } /// @@ -174,5 +191,6 @@ public RlTrainingSession( public RlTrainingSession() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.RlTrainingSessionsListResponse.g.cs b/src/libs/Together/Generated/Together.Models.RlTrainingSessionsListResponse.g.cs index 98176d68..b3e3e04a 100644 --- a/src/libs/Together/Generated/Together.Models.RlTrainingSessionsListResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.RlTrainingSessionsListResponse.g.cs @@ -52,5 +52,6 @@ public RlTrainingSessionsListResponse( public RlTrainingSessionsListResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.SecretResponseItem.g.cs b/src/libs/Together/Generated/Together.Models.SecretResponseItem.g.cs index 9d5b6556..ccd458cc 100644 --- a/src/libs/Together/Generated/Together.Models.SecretResponseItem.g.cs +++ b/src/libs/Together/Generated/Together.Models.SecretResponseItem.g.cs @@ -15,7 +15,7 @@ public sealed partial class SecretResponseItem public string? CreatedAt { get; set; } /// - /// CreatedBy is the identifier of the user who created this secret + /// CreatedBy is the identifier of who created this secret. /// [global::System.Text.Json.Serialization.JsonPropertyName("created_by")] public string? CreatedBy { get; set; } @@ -33,7 +33,7 @@ public sealed partial class SecretResponseItem public string? Id { get; set; } /// - /// LastUpdatedBy is the identifier of the user who last updated this secret + /// LastUpdatedBy is the identifier of who last updated this secret. /// [global::System.Text.Json.Serialization.JsonPropertyName("last_updated_by")] public string? LastUpdatedBy { get; set; } @@ -69,7 +69,7 @@ public sealed partial class SecretResponseItem /// CreatedAt is the ISO8601 timestamp when this secret was created /// /// - /// CreatedBy is the identifier of the user who created this secret + /// CreatedBy is the identifier of who created this secret. /// /// /// Description is a human-readable description of the secret's purpose @@ -78,7 +78,7 @@ public sealed partial class SecretResponseItem /// ID is the unique identifier for this secret /// /// - /// LastUpdatedBy is the identifier of the user who last updated this secret + /// LastUpdatedBy is the identifier of who last updated this secret. /// /// /// Name is the name/key of the secret @@ -118,5 +118,6 @@ public SecretResponseItem( public SecretResponseItem() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.SecretResponseItemObject.g.cs b/src/libs/Together/Generated/Together.Models.SecretResponseItemObject.g.cs index 2c2eb387..3613736e 100644 --- a/src/libs/Together/Generated/Together.Models.SecretResponseItemObject.g.cs +++ b/src/libs/Together/Generated/Together.Models.SecretResponseItemObject.g.cs @@ -14,5 +14,6 @@ public sealed partial class SecretResponseItemObject /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.SessionListResponse.g.cs b/src/libs/Together/Generated/Together.Models.SessionListResponse.g.cs index 8664f561..39eabf4a 100644 --- a/src/libs/Together/Generated/Together.Models.SessionListResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.SessionListResponse.g.cs @@ -26,6 +26,26 @@ namespace Together #endif public bool IsResponse => Response != null; + /// + /// + /// + public bool TryPickResponse( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Together.SessionListResponseResponse? value) + { + value = Response; + return IsResponse; + } + + /// + /// + /// + public global::Together.SessionListResponseResponse PickResponse() => IsResponse + ? Response! + : throw new global::System.InvalidOperationException($"Expected union variant 'Response' but the value was {ToString()}."); + /// /// /// @@ -42,6 +62,26 @@ namespace Together [global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(SessionListResponseVariant2))] #endif public bool IsSessionListResponseVariant2 => SessionListResponseVariant2 != null; + + /// + /// + /// + public bool TryPickSessionListResponseVariant2( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Together.SessionListResponseVariant2? value) + { + value = SessionListResponseVariant2; + return IsSessionListResponseVariant2; + } + + /// + /// + /// + public global::Together.SessionListResponseVariant2 PickSessionListResponseVariant2() => IsSessionListResponseVariant2 + ? SessionListResponseVariant2! + : throw new global::System.InvalidOperationException($"Expected union variant 'SessionListResponseVariant2' but the value was {ToString()}."); /// /// /// @@ -60,6 +100,11 @@ public SessionListResponse(global::Together.SessionListResponseResponse? value) Response = value; } + /// + /// + /// + public static SessionListResponse FromResponse(global::Together.SessionListResponseResponse? value) => new SessionListResponse(value); + /// /// /// @@ -78,6 +123,11 @@ public SessionListResponse(global::Together.SessionListResponseVariant2? value) SessionListResponseVariant2 = value; } + /// + /// + /// + public static SessionListResponse FromSessionListResponseVariant2(global::Together.SessionListResponseVariant2? value) => new SessionListResponse(value); + /// /// /// @@ -118,8 +168,8 @@ public bool Validate() /// ///
public TResult? Match( - global::System.Func? response = null, - global::System.Func? sessionListResponseVariant2 = null, + global::System.Func? response = null, + global::System.Func? sessionListResponseVariant2 = null, bool validate = true) { if (validate) @@ -143,8 +193,32 @@ public bool Validate() /// ///
public void Match( - global::System.Action? response = null, - global::System.Action? sessionListResponseVariant2 = null, + global::System.Action? response = null, + + global::System.Action? sessionListResponseVariant2 = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (IsResponse) + { + response?.Invoke(Response!); + } + else if (IsSessionListResponseVariant2) + { + sessionListResponseVariant2?.Invoke(SessionListResponseVariant2!); + } + } + + /// + /// + /// + public void Switch( + global::System.Action? response = null, + global::System.Action? sessionListResponseVariant2 = null, bool validate = true) { if (validate) diff --git a/src/libs/Together/Generated/Together.Models.SessionListResponseResponse.g.cs b/src/libs/Together/Generated/Together.Models.SessionListResponseResponse.g.cs index 09d9b203..460576ca 100644 --- a/src/libs/Together/Generated/Together.Models.SessionListResponseResponse.g.cs +++ b/src/libs/Together/Generated/Together.Models.SessionListResponseResponse.g.cs @@ -39,5 +39,6 @@ public SessionListResponseResponse( public SessionListResponseResponse() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.SessionListResponseResponseError.g.cs b/src/libs/Together/Generated/Together.Models.SessionListResponseResponseError.g.cs index 6630beef..bbefdf8b 100644 --- a/src/libs/Together/Generated/Together.Models.SessionListResponseResponseError.g.cs +++ b/src/libs/Together/Generated/Together.Models.SessionListResponseResponseError.g.cs @@ -14,5 +14,6 @@ public sealed partial class SessionListResponseResponseError ///
[global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.SessionListResponseVariant2.g.cs b/src/libs/Together/Generated/Together.Models.SessionListResponseVariant2.g.cs index 4957e32a..f9b645e3 100644 --- a/src/libs/Together/Generated/Together.Models.SessionListResponseVariant2.g.cs +++ b/src/libs/Together/Generated/Together.Models.SessionListResponseVariant2.g.cs @@ -39,5 +39,6 @@ public SessionListResponseVariant2( public SessionListResponseVariant2() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.SessionListResponseVariant2Data.g.cs b/src/libs/Together/Generated/Together.Models.SessionListResponseVariant2Data.g.cs index 9cb208fa..77db01ea 100644 --- a/src/libs/Together/Generated/Together.Models.SessionListResponseVariant2Data.g.cs +++ b/src/libs/Together/Generated/Together.Models.SessionListResponseVariant2Data.g.cs @@ -40,5 +40,6 @@ public SessionListResponseVariant2Data( public SessionListResponseVariant2Data() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.SessionListResponseVariant2DataSession.g.cs b/src/libs/Together/Generated/Together.Models.SessionListResponseVariant2DataSession.g.cs index ec946564..f3dbcb17 100644 --- a/src/libs/Together/Generated/Together.Models.SessionListResponseVariant2DataSession.g.cs +++ b/src/libs/Together/Generated/Together.Models.SessionListResponseVariant2DataSession.g.cs @@ -85,5 +85,6 @@ public SessionListResponseVariant2DataSession( public SessionListResponseVariant2DataSession() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.StreamOutput.g.cs b/src/libs/Together/Generated/Together.Models.StreamOutput.g.cs index 2234155d..050af774 100644 --- a/src/libs/Together/Generated/Together.Models.StreamOutput.g.cs +++ b/src/libs/Together/Generated/Together.Models.StreamOutput.g.cs @@ -51,5 +51,6 @@ public StreamOutput( public StreamOutput() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.StreamSentinel.g.cs b/src/libs/Together/Generated/Together.Models.StreamSentinel.g.cs index aeab2646..6b0ca9be 100644 --- a/src/libs/Together/Generated/Together.Models.StreamSentinel.g.cs +++ b/src/libs/Together/Generated/Together.Models.StreamSentinel.g.cs @@ -40,5 +40,6 @@ public StreamSentinel( public StreamSentinel() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ToolChoice2.g.cs b/src/libs/Together/Generated/Together.Models.ToolChoice2.g.cs index dae06a4f..587c3043 100644 --- a/src/libs/Together/Generated/Together.Models.ToolChoice2.g.cs +++ b/src/libs/Together/Generated/Together.Models.ToolChoice2.g.cs @@ -70,5 +70,6 @@ public ToolChoice2( public ToolChoice2() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ToolChoiceFunction.g.cs b/src/libs/Together/Generated/Together.Models.ToolChoiceFunction.g.cs index 5e8164ba..1e8f57fe 100644 --- a/src/libs/Together/Generated/Together.Models.ToolChoiceFunction.g.cs +++ b/src/libs/Together/Generated/Together.Models.ToolChoiceFunction.g.cs @@ -53,5 +53,6 @@ public ToolChoiceFunction( public ToolChoiceFunction() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ToolsPart.g.cs b/src/libs/Together/Generated/Together.Models.ToolsPart.g.cs index 10ea0996..88e96459 100644 --- a/src/libs/Together/Generated/Together.Models.ToolsPart.g.cs +++ b/src/libs/Together/Generated/Together.Models.ToolsPart.g.cs @@ -51,5 +51,6 @@ public ToolsPart( public ToolsPart() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ToolsPartFunction.g.cs b/src/libs/Together/Generated/Together.Models.ToolsPartFunction.g.cs index 7225fc39..6af46214 100644 --- a/src/libs/Together/Generated/Together.Models.ToolsPartFunction.g.cs +++ b/src/libs/Together/Generated/Together.Models.ToolsPartFunction.g.cs @@ -65,5 +65,6 @@ public ToolsPartFunction( public ToolsPartFunction() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.ToolsPartFunctionParameters.g.cs b/src/libs/Together/Generated/Together.Models.ToolsPartFunctionParameters.g.cs index a23041ab..5b5dd2d5 100644 --- a/src/libs/Together/Generated/Together.Models.ToolsPartFunctionParameters.g.cs +++ b/src/libs/Together/Generated/Together.Models.ToolsPartFunctionParameters.g.cs @@ -14,5 +14,6 @@ public sealed partial class ToolsPartFunctionParameters ///
[global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.TopLogprobs.g.cs b/src/libs/Together/Generated/Together.Models.TopLogprobs.g.cs index 217a0b16..42dcd972 100644 --- a/src/libs/Together/Generated/Together.Models.TopLogprobs.g.cs +++ b/src/libs/Together/Generated/Together.Models.TopLogprobs.g.cs @@ -14,5 +14,6 @@ public sealed partial class TopLogprobs ///
[global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.TrainingMethodDPO.g.cs b/src/libs/Together/Generated/Together.Models.TrainingMethodDPO.g.cs index 813446a4..cb098567 100644 --- a/src/libs/Together/Generated/Together.Models.TrainingMethodDPO.g.cs +++ b/src/libs/Together/Generated/Together.Models.TrainingMethodDPO.g.cs @@ -95,5 +95,6 @@ public TrainingMethodDPO( public TrainingMethodDPO() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.TrainingMethodSFT.g.cs b/src/libs/Together/Generated/Together.Models.TrainingMethodSFT.g.cs index 2660ab7c..c0c08d79 100644 --- a/src/libs/Together/Generated/Together.Models.TrainingMethodSFT.g.cs +++ b/src/libs/Together/Generated/Together.Models.TrainingMethodSFT.g.cs @@ -16,7 +16,7 @@ public sealed partial class TrainingMethodSFT public global::Together.TrainingMethodSFTMethod Method { get; set; } /// - /// Whether to mask the user messages in conversational data or prompts in instruction data.
+ /// Whether to mask user messages in conversational data or prompts in instruction data.
/// Default Value: auto ///
/// global::Together.TrainingMethodSFTTrainOnInputs.Auto @@ -35,7 +35,7 @@ public sealed partial class TrainingMethodSFT /// Initializes a new instance of the class. /// /// - /// Whether to mask the user messages in conversational data or prompts in instruction data.
+ /// Whether to mask user messages in conversational data or prompts in instruction data.
/// Default Value: auto /// /// @@ -56,5 +56,6 @@ public TrainingMethodSFT( public TrainingMethodSFT() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.UpdateDeploymentRequest.g.cs b/src/libs/Together/Generated/Together.Models.UpdateDeploymentRequest.g.cs index 77959b74..6305d91b 100644 --- a/src/libs/Together/Generated/Together.Models.UpdateDeploymentRequest.g.cs +++ b/src/libs/Together/Generated/Together.Models.UpdateDeploymentRequest.g.cs @@ -40,7 +40,7 @@ public sealed partial class UpdateDeploymentRequest public string? Description { get; set; } /// - /// EnvironmentVariables is a list of environment variables to set in the container. This will replace all existing environment variables + /// EnvironmentVariables is a list of environment variables to set in the container. Replaces all existing environment variables. /// [global::System.Text.Json.Serialization.JsonPropertyName("environment_variables")] public global::System.Collections.Generic.IList? EnvironmentVariables { get; set; } @@ -113,7 +113,7 @@ public sealed partial class UpdateDeploymentRequest public int? TerminationGracePeriodSeconds { get; set; } /// - /// Volumes is a list of volume mounts to attach to the container. This will replace all existing volumes + /// Volumes is a list of volume mounts to attach to the container. Replaces all existing volumes. /// [global::System.Text.Json.Serialization.JsonPropertyName("volumes")] public global::System.Collections.Generic.IList? Volumes { get; set; } @@ -143,7 +143,7 @@ public sealed partial class UpdateDeploymentRequest /// Description is an optional human-readable description of your deployment /// /// - /// EnvironmentVariables is a list of environment variables to set in the container. This will replace all existing environment variables + /// EnvironmentVariables is a list of environment variables to set in the container. Replaces all existing environment variables. /// /// /// GPUCount is the number of GPUs to allocate per container instance @@ -179,7 +179,7 @@ public sealed partial class UpdateDeploymentRequest /// TerminationGracePeriodSeconds is the time in seconds to wait for graceful shutdown before forcefully terminating the replica /// /// - /// Volumes is a list of volume mounts to attach to the container. This will replace all existing volumes + /// Volumes is a list of volume mounts to attach to the container. Replaces all existing volumes. /// #if NET7_0_OR_GREATER [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] @@ -230,5 +230,6 @@ public UpdateDeploymentRequest( public UpdateDeploymentRequest() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.UpdateDeploymentRequestGpuType.g.cs b/src/libs/Together/Generated/Together.Models.UpdateDeploymentRequestGpuType.g.cs index 2d5d888e..44a9b16e 100644 --- a/src/libs/Together/Generated/Together.Models.UpdateDeploymentRequestGpuType.g.cs +++ b/src/libs/Together/Generated/Together.Models.UpdateDeploymentRequestGpuType.g.cs @@ -8,6 +8,14 @@ namespace Together /// public enum UpdateDeploymentRequestGpuType { + /// + /// + /// + B200192gb, + /// + /// + /// + H10040gbMig, /// /// /// @@ -26,6 +34,8 @@ public static string ToValueString(this UpdateDeploymentRequestGpuType value) { return value switch { + UpdateDeploymentRequestGpuType.B200192gb => "b200-192gb", + UpdateDeploymentRequestGpuType.H10040gbMig => "h100-40gb-mig", UpdateDeploymentRequestGpuType.H10080gb => "h100-80gb", _ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null), }; @@ -37,6 +47,8 @@ public static string ToValueString(this UpdateDeploymentRequestGpuType value) { return value switch { + "b200-192gb" => UpdateDeploymentRequestGpuType.B200192gb, + "h100-40gb-mig" => UpdateDeploymentRequestGpuType.H10040gbMig, "h100-80gb" => UpdateDeploymentRequestGpuType.H10080gb, _ => null, }; diff --git a/src/libs/Together/Generated/Together.Models.UpdateEndpointRequest.g.cs b/src/libs/Together/Generated/Together.Models.UpdateEndpointRequest.g.cs index 98025157..0a444dc0 100644 --- a/src/libs/Together/Generated/Together.Models.UpdateEndpointRequest.g.cs +++ b/src/libs/Together/Generated/Together.Models.UpdateEndpointRequest.g.cs @@ -32,7 +32,7 @@ public sealed partial class UpdateEndpointRequest public global::Together.Autoscaling? Autoscaling { get; set; } /// - /// The number of minutes of inactivity after which the endpoint will be automatically stopped. Set to 0 to disable automatic timeout.
+ /// The number of minutes of inactivity after which the endpoint stops automatically. Set to 0 to disable automatic timeout.
/// Example: 60 ///
/// 60 @@ -60,7 +60,7 @@ public sealed partial class UpdateEndpointRequest /// New autoscaling configuration for the endpoint /// /// - /// The number of minutes of inactivity after which the endpoint will be automatically stopped. Set to 0 to disable automatic timeout.
+ /// The number of minutes of inactivity after which the endpoint stops automatically. Set to 0 to disable automatic timeout.
/// Example: 60 /// #if NET7_0_OR_GREATER @@ -84,5 +84,6 @@ public UpdateEndpointRequest( public UpdateEndpointRequest() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.UpdateSecretRequest.g.cs b/src/libs/Together/Generated/Together.Models.UpdateSecretRequest.g.cs index 9c5394e8..a839424d 100644 --- a/src/libs/Together/Generated/Together.Models.UpdateSecretRequest.g.cs +++ b/src/libs/Together/Generated/Together.Models.UpdateSecretRequest.g.cs @@ -27,7 +27,7 @@ public sealed partial class UpdateSecretRequest public string? ProjectId { get; set; } /// - /// Value is the new sensitive data to store securely. Updating this will replace the existing secret value + /// Value is the new sensitive data to store securely. Updating this replaces the existing secret value. /// [global::System.Text.Json.Serialization.JsonPropertyName("value")] public string? Value { get; set; } @@ -51,7 +51,7 @@ public sealed partial class UpdateSecretRequest /// ProjectID is ignored - the project is automatically determined from your authentication /// /// - /// Value is the new sensitive data to store securely. Updating this will replace the existing secret value + /// Value is the new sensitive data to store securely. Updating this replaces the existing secret value. /// #if NET7_0_OR_GREATER [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] @@ -74,5 +74,6 @@ public UpdateSecretRequest( public UpdateSecretRequest() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.UpdateVolumeRequest.g.cs b/src/libs/Together/Generated/Together.Models.UpdateVolumeRequest.g.cs index 204fff83..a19a8bd9 100644 --- a/src/libs/Together/Generated/Together.Models.UpdateVolumeRequest.g.cs +++ b/src/libs/Together/Generated/Together.Models.UpdateVolumeRequest.g.cs @@ -9,7 +9,7 @@ namespace Together public sealed partial class UpdateVolumeRequest { /// - /// Content specifies the new content that will be preloaded to this volume + /// Content specifies the new content to preload to this volume. /// [global::System.Text.Json.Serialization.JsonPropertyName("content")] public global::Together.VolumeContentRequest? Content { get; set; } @@ -37,7 +37,7 @@ public sealed partial class UpdateVolumeRequest /// Initializes a new instance of the class. /// /// - /// Content specifies the new content that will be preloaded to this volume + /// Content specifies the new content to preload to this volume. /// /// /// Name is the new unique identifier for the volume within the project @@ -64,5 +64,6 @@ public UpdateVolumeRequest( public UpdateVolumeRequest() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.UsageData.g.cs b/src/libs/Together/Generated/Together.Models.UsageData.g.cs index 7b4fc567..0be2e92f 100644 --- a/src/libs/Together/Generated/Together.Models.UsageData.g.cs +++ b/src/libs/Together/Generated/Together.Models.UsageData.g.cs @@ -60,5 +60,6 @@ public UsageData( public UsageData() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.VersionHistoryItem.g.cs b/src/libs/Together/Generated/Together.Models.VersionHistoryItem.g.cs index 7947bf35..e0221b3e 100644 --- a/src/libs/Together/Generated/Together.Models.VersionHistoryItem.g.cs +++ b/src/libs/Together/Generated/Together.Models.VersionHistoryItem.g.cs @@ -9,7 +9,7 @@ namespace Together public sealed partial class VersionHistoryItem { /// - /// Content specifies the new content that will be preloaded to this volume + /// Content specifies the new content to preload to this volume. /// [global::System.Text.Json.Serialization.JsonPropertyName("content")] public global::Together.VolumeContentRequest? Content { get; set; } @@ -36,7 +36,7 @@ public sealed partial class VersionHistoryItem /// Initializes a new instance of the class. /// /// - /// Content specifies the new content that will be preloaded to this volume + /// Content specifies the new content to preload to this volume. /// /// /// @@ -59,5 +59,6 @@ public VersionHistoryItem( public VersionHistoryItem() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.VideoFrameImageInput.g.cs b/src/libs/Together/Generated/Together.Models.VideoFrameImageInput.g.cs index 6c49472c..16abab7c 100644 --- a/src/libs/Together/Generated/Together.Models.VideoFrameImageInput.g.cs +++ b/src/libs/Together/Generated/Together.Models.VideoFrameImageInput.g.cs @@ -60,5 +60,6 @@ public VideoFrameImageInput( public VideoFrameImageInput() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.VideoJob.g.cs b/src/libs/Together/Generated/Together.Models.VideoJob.g.cs index 7fd8a3a9..518c1c49 100644 --- a/src/libs/Together/Generated/Together.Models.VideoJob.g.cs +++ b/src/libs/Together/Generated/Together.Models.VideoJob.g.cs @@ -147,5 +147,6 @@ public VideoJob( public VideoJob() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.VideoJobError.g.cs b/src/libs/Together/Generated/Together.Models.VideoJobError.g.cs index 89b90c27..46eaf3cb 100644 --- a/src/libs/Together/Generated/Together.Models.VideoJobError.g.cs +++ b/src/libs/Together/Generated/Together.Models.VideoJobError.g.cs @@ -49,5 +49,6 @@ public VideoJobError( public VideoJobError() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.VideoJobObject.g.cs b/src/libs/Together/Generated/Together.Models.VideoJobObject.g.cs index 86dc9313..4e21118c 100644 --- a/src/libs/Together/Generated/Together.Models.VideoJobObject.g.cs +++ b/src/libs/Together/Generated/Together.Models.VideoJobObject.g.cs @@ -14,5 +14,6 @@ public sealed partial class VideoJobObject /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.VideoJobOutputs.g.cs b/src/libs/Together/Generated/Together.Models.VideoJobOutputs.g.cs index 35138f1d..17a2af5a 100644 --- a/src/libs/Together/Generated/Together.Models.VideoJobOutputs.g.cs +++ b/src/libs/Together/Generated/Together.Models.VideoJobOutputs.g.cs @@ -54,5 +54,6 @@ public VideoJobOutputs( public VideoJobOutputs() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.VideoMedia.g.cs b/src/libs/Together/Generated/Together.Models.VideoMedia.g.cs index d007e263..2335a0c9 100644 --- a/src/libs/Together/Generated/Together.Models.VideoMedia.g.cs +++ b/src/libs/Together/Generated/Together.Models.VideoMedia.g.cs @@ -97,5 +97,6 @@ public VideoMedia( public VideoMedia() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.VideoRef.g.cs b/src/libs/Together/Generated/Together.Models.VideoRef.g.cs index 270029e4..43ac0a21 100644 --- a/src/libs/Together/Generated/Together.Models.VideoRef.g.cs +++ b/src/libs/Together/Generated/Together.Models.VideoRef.g.cs @@ -42,5 +42,6 @@ public VideoRef( public VideoRef() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.VolumeContent.g.cs b/src/libs/Together/Generated/Together.Models.VolumeContent.g.cs index b1c95fc3..dde7387d 100644 --- a/src/libs/Together/Generated/Together.Models.VolumeContent.g.cs +++ b/src/libs/Together/Generated/Together.Models.VolumeContent.g.cs @@ -9,7 +9,7 @@ namespace Together public sealed partial class VolumeContent { /// - /// Files is the list of files that will be preloaded into the volume, if the volume content type is "files" + /// Files is the list of files to preload into the volume, if the volume content type is "files". /// [global::System.Text.Json.Serialization.JsonPropertyName("files")] public global::System.Collections.Generic.IList? Files { get; set; } @@ -41,7 +41,7 @@ public sealed partial class VolumeContent /// Initializes a new instance of the class. /// /// - /// Files is the list of files that will be preloaded into the volume, if the volume content type is "files" + /// Files is the list of files to preload into the volume, if the volume content type is "files". /// /// /// SourcePrefix is the file path prefix for the content to be preloaded into the volume
@@ -70,5 +70,6 @@ public VolumeContent( public VolumeContent() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.VolumeContentRequest.g.cs b/src/libs/Together/Generated/Together.Models.VolumeContentRequest.g.cs index 35b6e324..ea1f0dad 100644 --- a/src/libs/Together/Generated/Together.Models.VolumeContentRequest.g.cs +++ b/src/libs/Together/Generated/Together.Models.VolumeContentRequest.g.cs @@ -4,7 +4,7 @@ namespace Together { /// - /// Content specifies the new content that will be preloaded to this volume + /// Content specifies the new content to preload to this volume. /// public sealed partial class VolumeContentRequest { @@ -59,5 +59,6 @@ public VolumeContentRequest( public VolumeContentRequest() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.VolumeMount.g.cs b/src/libs/Together/Generated/Together.Models.VolumeMount.g.cs index 80675c74..5924c527 100644 --- a/src/libs/Together/Generated/Together.Models.VolumeMount.g.cs +++ b/src/libs/Together/Generated/Together.Models.VolumeMount.g.cs @@ -9,7 +9,7 @@ namespace Together public sealed partial class VolumeMount { /// - /// MountPath is the path in the container where the volume will be mounted (e.g., "/data") + /// MountPath is the path in the container where the volume mounts (e.g., "/data"). /// [global::System.Text.Json.Serialization.JsonPropertyName("mount_path")] [global::System.Text.Json.Serialization.JsonRequired] @@ -38,7 +38,7 @@ public sealed partial class VolumeMount /// Initializes a new instance of the class. /// /// - /// MountPath is the path in the container where the volume will be mounted (e.g., "/data") + /// MountPath is the path in the container where the volume mounts (e.g., "/data"). /// /// /// Name is the name of the volume to mount. Must reference an existing volume by name or ID @@ -65,5 +65,6 @@ public VolumeMount( public VolumeMount() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.VolumeResponseItem.g.cs b/src/libs/Together/Generated/Together.Models.VolumeResponseItem.g.cs index 1f5bd079..a67d6380 100644 --- a/src/libs/Together/Generated/Together.Models.VolumeResponseItem.g.cs +++ b/src/libs/Together/Generated/Together.Models.VolumeResponseItem.g.cs @@ -137,5 +137,6 @@ public VolumeResponseItem( public VolumeResponseItem() { } + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.Models.VolumeResponseItemVersionHistory.g.cs b/src/libs/Together/Generated/Together.Models.VolumeResponseItemVersionHistory.g.cs index 25e00353..359f354d 100644 --- a/src/libs/Together/Generated/Together.Models.VolumeResponseItemVersionHistory.g.cs +++ b/src/libs/Together/Generated/Together.Models.VolumeResponseItemVersionHistory.g.cs @@ -14,5 +14,6 @@ public sealed partial class VolumeResponseItemVersionHistory /// [global::System.Text.Json.Serialization.JsonExtensionData] public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.ModelsClient.Models.g.cs b/src/libs/Together/Generated/Together.ModelsClient.Models.g.cs index aa7e8589..16db4075 100644 --- a/src/libs/Together/Generated/Together.ModelsClient.Models.g.cs +++ b/src/libs/Together/Generated/Together.ModelsClient.Models.g.cs @@ -14,6 +14,7 @@ public partial class ModelsClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,6 +48,7 @@ partial void ProcessModelsResponseContent( /// /// Filter models to only return dedicated models /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -62,6 +64,41 @@ partial void ProcessModelsResponseContent( /// public async global::System.Threading.Tasks.Task> ModelsAsync( bool? dedicated = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await ModelsAsResponseAsync( + dedicated: dedicated, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// List all models
+ /// Lists all of Together's open-source models + ///
+ /// + /// Filter models to only return dedicated models + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// models = client.models.list()
+ /// for model in models:
+ /// print(model.id) + ///
+ public async global::System.Threading.Tasks.Task>> ModelsAsResponseAsync( + bool? dedicated = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -76,25 +113,47 @@ partial void ProcessModelsResponseContent( securityRequirements: s_ModelsSecurityRequirements, operationName: "ModelsAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/models", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("dedicated", dedicated?.ToString().ToLowerInvariant()) - ; - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/models", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("dedicated", dedicated?.ToString().ToLowerInvariant()) + ; + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -104,302 +163,487 @@ partial void ProcessModelsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareModelsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - dedicated: dedicated); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareModelsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + dedicated: dedicated); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessModelsResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // BadRequest - if ((int)__response.StatusCode == 400) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - global::Together.ErrorData? __value_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Models", + methodName: "ModelsAsync", + pathTemplate: "\"/models\"", + httpMethod: "GET", + 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 { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Models", + methodName: "ModelsAsync", + pathTemplate: "\"/models\"", + httpMethod: "GET", + 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; + } - __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } - throw new global::Together.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Unauthorized - if ((int)__response.StatusCode == 401) - { - string? __content_401 = null; - global::System.Exception? __exception_401 = null; - global::Together.ErrorData? __value_401 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Models", + methodName: "ModelsAsync", + pathTemplate: "\"/models\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_401 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_401, - statusCode: __response.StatusCode) - { - ResponseBody = __content_401, - ResponseObject = __value_401, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // NotFound - if ((int)__response.StatusCode == 404) - { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; - global::Together.ErrorData? __value_404 = null; - try + using (__response) { - if (ReadResponseAsString) - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); - } - else - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); - } + ProcessResponse( + client: HttpClient, + response: __response); + ProcessModelsResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Models", + methodName: "ModelsAsync", + pathTemplate: "\"/models\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - __exception_404 = __ex; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Models", + methodName: "ModelsAsync", + pathTemplate: "\"/models\"", + httpMethod: "GET", + 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); } + // BadRequest + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Together.ErrorData? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - throw new global::Together.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // RateLimit - if ((int)__response.StatusCode == 429) - { - string? __content_429 = null; - global::System.Exception? __exception_429 = null; - global::Together.ErrorData? __value_429 = null; - try - { - if (ReadResponseAsString) - { - __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_429 = global::Together.ErrorData.FromJson(__content_429, JsonSerializerContext); - } - else - { - __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } - __value_429 = global::Together.ErrorData.FromJson(__content_429, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_429 = __ex; - } + throw new global::Together.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unauthorized + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Together.ErrorData? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - throw new global::Together.ApiException( - message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_429, - statusCode: __response.StatusCode) - { - ResponseBody = __content_429, - ResponseObject = __value_429, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Timeout - if ((int)__response.StatusCode == 504) - { - string? __content_504 = null; - global::System.Exception? __exception_504 = null; - global::Together.ErrorData? __value_504 = null; - try - { - if (ReadResponseAsString) - { - __content_504 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_504 = global::Together.ErrorData.FromJson(__content_504, JsonSerializerContext); - } - else - { - __content_504 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } - __value_504 = global::Together.ErrorData.FromJson(__content_504, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_504 = __ex; - } + throw new global::Together.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseObject = __value_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // NotFound + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Together.ErrorData? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - throw new global::Together.ApiException( - message: __content_504 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_504, - statusCode: __response.StatusCode) - { - ResponseBody = __content_504, - ResponseObject = __value_504, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } + __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + throw new global::Together.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // RateLimit + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Together.ErrorData? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Together.ErrorData.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessModelsResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __value_429 = global::Together.ErrorData.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } - try - { - __response.EnsureSuccessStatusCode(); + throw new global::Together.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseObject = __value_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Timeout + if ((int)__response.StatusCode == 504) + { + string? __content_504 = null; + global::System.Exception? __exception_504 = null; + global::Together.ErrorData? __value_504 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_504 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_504 = global::Together.ErrorData.FromJson(__content_504, JsonSerializerContext); + } + else + { + __content_504 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - } - catch (global::System.Exception __ex) - { - throw new global::Together.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 - cancellationToken -#endif - ).ConfigureAwait(false); + __value_504 = global::Together.ErrorData.FromJson(__content_504, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_504 = __ex; + } - return - (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), 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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + throw new global::Together.ApiException( + message: __content_504 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_504, + statusCode: __response.StatusCode) + { + ResponseBody = __content_504, + ResponseObject = __value_504, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessModelsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse>( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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 = (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse>( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.ModelsClient.UploadModel.g.cs b/src/libs/Together/Generated/Together.ModelsClient.UploadModel.g.cs index ce7013af..a77cafb7 100644 --- a/src/libs/Together/Generated/Together.ModelsClient.UploadModel.g.cs +++ b/src/libs/Together/Generated/Together.ModelsClient.UploadModel.g.cs @@ -14,6 +14,7 @@ public partial class ModelsClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,6 +46,7 @@ partial void ProcessUploadModelResponseContent( /// Upload a custom model or adapter from Hugging Face or S3 /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -63,6 +65,43 @@ partial void ProcessUploadModelResponseContent( public async global::System.Threading.Tasks.Task UploadModelAsync( global::Together.ModelUploadRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await UploadModelAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Upload a custom model or adapter
+ /// Upload a custom model or adapter from Hugging Face or S3 + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.models.upload(
+ /// model_name="My-Fine-Tuned-Model",
+ /// model_source="https://ml-models.s3.us-west-2.amazonaws.com/models/my-fine-tuned-model.tar.gz",
+ /// )
+ /// print(response.data.job_id) + ///
+ public async global::System.Threading.Tasks.Task> UploadModelAsResponseAsync( + + global::Together.ModelUploadRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -79,22 +118,44 @@ partial void ProcessUploadModelResponseContent( securityRequirements: s_UploadModelSecurityRequirements, operationName: "UploadModelAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/models", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/models", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -104,118 +165,303 @@ partial void ProcessUploadModelResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareUploadModelRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareUploadModelRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUploadModelResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UploadModel", + methodName: "UploadModelAsync", + pathTemplate: "\"/models\"", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UploadModel", + methodName: "UploadModelAsync", + pathTemplate: "\"/models\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessUploadModelResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UploadModel", + methodName: "UploadModelAsync", + pathTemplate: "\"/models\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::Together.ModelUploadSuccessResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Together.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), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return - await global::Together.ModelUploadSuccessResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUploadModelResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UploadModel", + methodName: "UploadModelAsync", + pathTemplate: "\"/models\"", + 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); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UploadModel", + methodName: "UploadModelAsync", + pathTemplate: "\"/models\"", + 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); + ProcessUploadModelResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.ModelUploadSuccessResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.ModelUploadSuccessResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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(); + } } /// /// Upload a custom model or adapter
@@ -250,6 +496,7 @@ partial void ProcessUploadModelResponseContent( /// The lora pool to use for an adapter if setting it to run against, say, a dedicated pool. Only used for model_type `adapter`.
/// Example: my_username/Qwen2.5-72B-Instruct-lora /// + /// 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 UploadModelAsync( @@ -260,6 +507,7 @@ partial void ProcessUploadModelResponseContent( string? description = default, string? baseModel = default, string? loraModel = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.ModelUploadRequest @@ -275,6 +523,7 @@ partial void ProcessUploadModelResponseContent( return await UploadModelAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Together/Generated/Together.ModelsClient.g.cs b/src/libs/Together/Generated/Together.ModelsClient.g.cs index 9a11416d..35f5f429 100644 --- a/src/libs/Together/Generated/Together.ModelsClient.g.cs +++ b/src/libs/Together/Generated/Together.ModelsClient.g.cs @@ -12,7 +12,7 @@ public sealed partial class ModelsClient : global::Together.IModelsClient, globa /// /// /// - public const string DefaultBaseUrl = "https://api.together.xyz/v1"; + public const string DefaultBaseUrl = "https://api.together.ai/v1"; private bool _disposeHttpClient = true; @@ -30,6 +30,12 @@ public sealed partial class ModelsClient : global::Together.IModelsClient, globa #if DEBUG = true; #endif + + /// + public global::Together.AutoSDKClientOptions Options { get; } + + + internal global::Together.AutoSDKServerConfiguration AutoSDKServerConfiguration { get; set; } = new global::Together.AutoSDKServerConfiguration(); /// /// /// @@ -49,13 +55,62 @@ public ModelsClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the ModelsClient with explicit options but no base URL override. + /// Skips passing baseUri so the default base URL from the OpenAPI spec applies. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public ModelsClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, + bool disposeHttpClient = true) : this( + httpClient, + baseUri: null, + authorizations, + options, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the ModelsClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public ModelsClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Together.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; + AutoSDKServerConfiguration.ExplicitBaseUri = baseUri ?? httpClient?.BaseAddress; + Initialized(HttpClient); } diff --git a/src/libs/Together/Generated/Together.OneOf.2.g.cs b/src/libs/Together/Generated/Together.OneOf.2.g.cs index 6c6d526a..8a055209 100644 --- a/src/libs/Together/Generated/Together.OneOf.2.g.cs +++ b/src/libs/Together/Generated/Together.OneOf.2.g.cs @@ -25,6 +25,26 @@ namespace Together #endif public bool IsValue1 => Value1 != null; + /// + /// + /// + public bool TryPickValue1( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out T1? value) + { + value = Value1; + return IsValue1; + } + + /// + /// + /// + public T1 PickValue1() => IsValue1 + ? Value1! + : throw new global::System.InvalidOperationException($"Expected union variant 'Value1' but the value was {ToString()}."); + /// /// /// @@ -41,6 +61,26 @@ namespace Together [global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(Value2))] #endif public bool IsValue2 => Value2 != null; + + /// + /// + /// + public bool TryPickValue2( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out T2? value) + { + value = Value2; + return IsValue2; + } + + /// + /// + /// + public T2 PickValue2() => IsValue2 + ? Value2! + : throw new global::System.InvalidOperationException($"Expected union variant 'Value2' but the value was {ToString()}."); /// /// /// @@ -59,6 +99,11 @@ public OneOf(T1? value) Value1 = value; } + /// + /// + /// + public static OneOf FromValue1(T1? value) => new OneOf(value); + /// /// /// @@ -77,6 +122,11 @@ public OneOf(T2? value) Value2 = value; } + /// + /// + /// + public static OneOf FromValue2(T2? value) => new OneOf(value); + /// /// /// @@ -143,6 +193,30 @@ public bool Validate() ///
public void Match( global::System.Action? value1 = null, + + global::System.Action? value2 = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (IsValue1) + { + value1?.Invoke(Value1!); + } + else if (IsValue2) + { + value2?.Invoke(Value2!); + } + } + + /// + /// + /// + public void Switch( + global::System.Action? value1 = null, global::System.Action? value2 = null, bool validate = true) { diff --git a/src/libs/Together/Generated/Together.OneOf.3.g.cs b/src/libs/Together/Generated/Together.OneOf.3.g.cs index 6e860cfb..d8563329 100644 --- a/src/libs/Together/Generated/Together.OneOf.3.g.cs +++ b/src/libs/Together/Generated/Together.OneOf.3.g.cs @@ -25,6 +25,26 @@ namespace Together #endif public bool IsValue1 => Value1 != null; + /// + /// + /// + public bool TryPickValue1( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out T1? value) + { + value = Value1; + return IsValue1; + } + + /// + /// + /// + public T1 PickValue1() => IsValue1 + ? Value1! + : throw new global::System.InvalidOperationException($"Expected union variant 'Value1' but the value was {ToString()}."); + /// /// /// @@ -42,6 +62,26 @@ namespace Together #endif public bool IsValue2 => Value2 != null; + /// + /// + /// + public bool TryPickValue2( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out T2? value) + { + value = Value2; + return IsValue2; + } + + /// + /// + /// + public T2 PickValue2() => IsValue2 + ? Value2! + : throw new global::System.InvalidOperationException($"Expected union variant 'Value2' but the value was {ToString()}."); + /// /// /// @@ -58,6 +98,26 @@ namespace Together [global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(Value3))] #endif public bool IsValue3 => Value3 != null; + + /// + /// + /// + public bool TryPickValue3( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out T3? value) + { + value = Value3; + return IsValue3; + } + + /// + /// + /// + public T3 PickValue3() => IsValue3 + ? Value3! + : throw new global::System.InvalidOperationException($"Expected union variant 'Value3' but the value was {ToString()}."); /// /// /// @@ -76,6 +136,11 @@ public OneOf(T1? value) Value1 = value; } + /// + /// + /// + public static OneOf FromValue1(T1? value) => new OneOf(value); + /// /// /// @@ -94,6 +159,11 @@ public OneOf(T2? value) Value2 = value; } + /// + /// + /// + public static OneOf FromValue2(T2? value) => new OneOf(value); + /// /// /// @@ -112,6 +182,11 @@ public OneOf(T3? value) Value3 = value; } + /// + /// + /// + public static OneOf FromValue3(T3? value) => new OneOf(value); + /// /// /// @@ -187,6 +262,36 @@ public bool Validate() /// public void Match( global::System.Action? value1 = null, + + global::System.Action? value2 = null, + + global::System.Action? value3 = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (IsValue1) + { + value1?.Invoke(Value1!); + } + else if (IsValue2) + { + value2?.Invoke(Value2!); + } + else if (IsValue3) + { + value3?.Invoke(Value3!); + } + } + + /// + /// + /// + public void Switch( + global::System.Action? value1 = null, global::System.Action? value2 = null, global::System.Action? value3 = null, bool validate = true) diff --git a/src/libs/Together/Generated/Together.OneOf.4.g.cs b/src/libs/Together/Generated/Together.OneOf.4.g.cs index e98ef552..95bd0cd3 100644 --- a/src/libs/Together/Generated/Together.OneOf.4.g.cs +++ b/src/libs/Together/Generated/Together.OneOf.4.g.cs @@ -25,6 +25,26 @@ namespace Together #endif public bool IsValue1 => Value1 != null; + /// + /// + /// + public bool TryPickValue1( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out T1? value) + { + value = Value1; + return IsValue1; + } + + /// + /// + /// + public T1 PickValue1() => IsValue1 + ? Value1! + : throw new global::System.InvalidOperationException($"Expected union variant 'Value1' but the value was {ToString()}."); + /// /// /// @@ -42,6 +62,26 @@ namespace Together #endif public bool IsValue2 => Value2 != null; + /// + /// + /// + public bool TryPickValue2( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out T2? value) + { + value = Value2; + return IsValue2; + } + + /// + /// + /// + public T2 PickValue2() => IsValue2 + ? Value2! + : throw new global::System.InvalidOperationException($"Expected union variant 'Value2' but the value was {ToString()}."); + /// /// /// @@ -59,6 +99,26 @@ namespace Together #endif public bool IsValue3 => Value3 != null; + /// + /// + /// + public bool TryPickValue3( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out T3? value) + { + value = Value3; + return IsValue3; + } + + /// + /// + /// + public T3 PickValue3() => IsValue3 + ? Value3! + : throw new global::System.InvalidOperationException($"Expected union variant 'Value3' but the value was {ToString()}."); + /// /// /// @@ -75,6 +135,26 @@ namespace Together [global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(Value4))] #endif public bool IsValue4 => Value4 != null; + + /// + /// + /// + public bool TryPickValue4( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out T4? value) + { + value = Value4; + return IsValue4; + } + + /// + /// + /// + public T4 PickValue4() => IsValue4 + ? Value4! + : throw new global::System.InvalidOperationException($"Expected union variant 'Value4' but the value was {ToString()}."); /// /// /// @@ -93,6 +173,11 @@ public OneOf(T1? value) Value1 = value; } + /// + /// + /// + public static OneOf FromValue1(T1? value) => new OneOf(value); + /// /// /// @@ -111,6 +196,11 @@ public OneOf(T2? value) Value2 = value; } + /// + /// + /// + public static OneOf FromValue2(T2? value) => new OneOf(value); + /// /// /// @@ -129,6 +219,11 @@ public OneOf(T3? value) Value3 = value; } + /// + /// + /// + public static OneOf FromValue3(T3? value) => new OneOf(value); + /// /// /// @@ -147,6 +242,11 @@ public OneOf(T4? value) Value4 = value; } + /// + /// + /// + public static OneOf FromValue4(T4? value) => new OneOf(value); + /// /// /// @@ -231,6 +331,42 @@ public bool Validate() /// public void Match( global::System.Action? value1 = null, + + global::System.Action? value2 = null, + + global::System.Action? value3 = null, + + global::System.Action? value4 = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (IsValue1) + { + value1?.Invoke(Value1!); + } + else if (IsValue2) + { + value2?.Invoke(Value2!); + } + else if (IsValue3) + { + value3?.Invoke(Value3!); + } + else if (IsValue4) + { + value4?.Invoke(Value4!); + } + } + + /// + /// + /// + public void Switch( + global::System.Action? value1 = null, global::System.Action? value2 = null, global::System.Action? value3 = null, global::System.Action? value4 = null, diff --git a/src/libs/Together/Generated/Together.OneOf.5.g.cs b/src/libs/Together/Generated/Together.OneOf.5.g.cs index 76ceb721..6ac68c62 100644 --- a/src/libs/Together/Generated/Together.OneOf.5.g.cs +++ b/src/libs/Together/Generated/Together.OneOf.5.g.cs @@ -25,6 +25,26 @@ namespace Together #endif public bool IsValue1 => Value1 != null; + /// + /// + /// + public bool TryPickValue1( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out T1? value) + { + value = Value1; + return IsValue1; + } + + /// + /// + /// + public T1 PickValue1() => IsValue1 + ? Value1! + : throw new global::System.InvalidOperationException($"Expected union variant 'Value1' but the value was {ToString()}."); + /// /// /// @@ -42,6 +62,26 @@ namespace Together #endif public bool IsValue2 => Value2 != null; + /// + /// + /// + public bool TryPickValue2( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out T2? value) + { + value = Value2; + return IsValue2; + } + + /// + /// + /// + public T2 PickValue2() => IsValue2 + ? Value2! + : throw new global::System.InvalidOperationException($"Expected union variant 'Value2' but the value was {ToString()}."); + /// /// /// @@ -59,6 +99,26 @@ namespace Together #endif public bool IsValue3 => Value3 != null; + /// + /// + /// + public bool TryPickValue3( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out T3? value) + { + value = Value3; + return IsValue3; + } + + /// + /// + /// + public T3 PickValue3() => IsValue3 + ? Value3! + : throw new global::System.InvalidOperationException($"Expected union variant 'Value3' but the value was {ToString()}."); + /// /// /// @@ -76,6 +136,26 @@ namespace Together #endif public bool IsValue4 => Value4 != null; + /// + /// + /// + public bool TryPickValue4( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out T4? value) + { + value = Value4; + return IsValue4; + } + + /// + /// + /// + public T4 PickValue4() => IsValue4 + ? Value4! + : throw new global::System.InvalidOperationException($"Expected union variant 'Value4' but the value was {ToString()}."); + /// /// /// @@ -92,6 +172,26 @@ namespace Together [global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(Value5))] #endif public bool IsValue5 => Value5 != null; + + /// + /// + /// + public bool TryPickValue5( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out T5? value) + { + value = Value5; + return IsValue5; + } + + /// + /// + /// + public T5 PickValue5() => IsValue5 + ? Value5! + : throw new global::System.InvalidOperationException($"Expected union variant 'Value5' but the value was {ToString()}."); /// /// /// @@ -110,6 +210,11 @@ public OneOf(T1? value) Value1 = value; } + /// + /// + /// + public static OneOf FromValue1(T1? value) => new OneOf(value); + /// /// /// @@ -128,6 +233,11 @@ public OneOf(T2? value) Value2 = value; } + /// + /// + /// + public static OneOf FromValue2(T2? value) => new OneOf(value); + /// /// /// @@ -146,6 +256,11 @@ public OneOf(T3? value) Value3 = value; } + /// + /// + /// + public static OneOf FromValue3(T3? value) => new OneOf(value); + /// /// /// @@ -164,6 +279,11 @@ public OneOf(T4? value) Value4 = value; } + /// + /// + /// + public static OneOf FromValue4(T4? value) => new OneOf(value); + /// /// /// @@ -182,6 +302,11 @@ public OneOf(T5? value) Value5 = value; } + /// + /// + /// + public static OneOf FromValue5(T5? value) => new OneOf(value); + /// /// /// @@ -275,6 +400,48 @@ public bool Validate() /// public void Match( global::System.Action? value1 = null, + + global::System.Action? value2 = null, + + global::System.Action? value3 = null, + + global::System.Action? value4 = null, + + global::System.Action? value5 = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (IsValue1) + { + value1?.Invoke(Value1!); + } + else if (IsValue2) + { + value2?.Invoke(Value2!); + } + else if (IsValue3) + { + value3?.Invoke(Value3!); + } + else if (IsValue4) + { + value4?.Invoke(Value4!); + } + else if (IsValue5) + { + value5?.Invoke(Value5!); + } + } + + /// + /// + /// + public void Switch( + global::System.Action? value1 = null, global::System.Action? value2 = null, global::System.Action? value3 = null, global::System.Action? value4 = null, diff --git a/src/libs/Together/Generated/Together.OptionsSupport.g.cs b/src/libs/Together/Generated/Together.OptionsSupport.g.cs new file mode 100644 index 00000000..11cb030c --- /dev/null +++ b/src/libs/Together/Generated/Together.OptionsSupport.g.cs @@ -0,0 +1,937 @@ + +#nullable enable + +namespace Together +{ + /// + /// Global defaults applied to generated SDK requests. + /// + public sealed class AutoSDKClientOptions + { + /// + /// Additional headers applied to every request after generated headers are set. + /// Entries with the same key overwrite earlier header values. + /// + public global::System.Collections.Generic.Dictionary Headers { get; } = + new global::System.Collections.Generic.Dictionary(global::System.StringComparer.OrdinalIgnoreCase); + + /// + /// Additional query parameters appended to every request. + /// Request-level entries with the same key are appended after client defaults. + /// + public global::System.Collections.Generic.Dictionary QueryParameters { get; } = + new global::System.Collections.Generic.Dictionary(global::System.StringComparer.Ordinal); + + /// + /// Optional timeout applied to the full request execution. + /// + public global::System.TimeSpan? Timeout { get; set; } + + /// + /// Default retry behavior for generated HTTP requests. + /// + public global::Together.AutoSDKRetryOptions Retry { get; set; } = new global::Together.AutoSDKRetryOptions(); + + /// + /// Overrides the client-wide response buffering mode when set. + /// + public bool? ReadResponseAsString { get; set; } + + /// + /// Reusable hooks invoked for every generated SDK request. + /// + public global::System.Collections.Generic.List Hooks { get; } = + new global::System.Collections.Generic.List(); + + /// + /// Registers a hook for all requests issued by this client. + /// + /// + /// The current options instance. + public global::Together.AutoSDKClientOptions AddHook( + global::Together.IAutoSDKHook hook) + { + Hooks.Add(hook ?? throw new global::System.ArgumentNullException(nameof(hook))); + return this; + } + + /// + /// Optional per-request authorization provider invoked before each request is sent. + /// Set this when the client is registered as a singleton in DI but each call needs + /// a fresh credential resolved from a provider, secret-store, or session — instead + /// of mutating the shared Authorizations list at construction time. + /// + public global::Together.IAutoSDKAuthorizationProvider? AuthorizationProvider { get; set; } + + /// + /// Convenience helper that registers + /// using so request-level auth is resolved without + /// touching shared client state. + /// + /// + public global::Together.AutoSDKClientOptions UseAuthorizationProvider( + global::Together.IAutoSDKAuthorizationProvider provider) + { + AuthorizationProvider = provider ?? throw new global::System.ArgumentNullException(nameof(provider)); + if (Hooks.Find(static x => x is global::Together.AutoSDKAuthorizationProviderHook) == null) + { + Hooks.Add(new global::Together.AutoSDKAuthorizationProviderHook()); + } + + return this; + } + } + + /// + /// A request-level authorization value supplied by . + /// Mirrors the runtime fields the SDK applies for HTTP / OAuth2 / API-key auth without + /// requiring the consumer to construct the generated EndPointAuthorization type. + /// + public readonly struct AutoSDKAuthorizationValue + { + /// + /// Initializes a new . + /// + /// + /// + /// + /// + /// + public AutoSDKAuthorizationValue( + string value, + string scheme = "Bearer", + string? headerName = null, + string location = "Header", + string type = "Http") + { + Value = value ?? string.Empty; + Scheme = string.IsNullOrWhiteSpace(scheme) ? "Bearer" : scheme; + HeaderName = headerName ?? string.Empty; + Location = string.IsNullOrWhiteSpace(location) ? "Header" : location; + Type = string.IsNullOrWhiteSpace(type) ? "Http" : type; + } + + /// The credential value (token, API key, etc.). + public string Value { get; } + + /// The HTTP authorization scheme — typically Bearer, Basic, or Token. + public string Scheme { get; } + + /// The custom header name when is ApiKey; ignored for HTTP/OAuth2 auth. + public string HeaderName { get; } + + /// The credential location — Header, Query, or Cookie. + public string Location { get; } + + /// The auth type — Http, OAuth2, OpenIdConnect, or ApiKey. + public string Type { get; } + + /// Convenience factory for a Bearer token. + public static global::Together.AutoSDKAuthorizationValue Bearer(string token) => new(value: token, scheme: "Bearer"); + + /// Convenience factory for an API-key header. + public static global::Together.AutoSDKAuthorizationValue ApiKeyHeader(string name, string value) => + new(value: value, headerName: name, location: "Header", type: "ApiKey"); + } + + /// + /// Resolves request-level authorization values without mutating the shared client + /// authorization list. Implementations should be safe to invoke concurrently — + /// the hook calls them once per outgoing request. + /// + public interface IAutoSDKAuthorizationProvider + { + /// + /// Returns one or more values to apply to + /// the current request, or an empty list / null to leave the request as-is. + /// + /// + global::System.Threading.Tasks.Task?> ResolveAsync( + global::Together.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 + /// request and stamps the resolved values onto the . + /// + public sealed class AutoSDKAuthorizationProviderHook : global::Together.AutoSDKHook + { + /// + public override async global::System.Threading.Tasks.Task OnBeforeRequestAsync( + global::Together.AutoSDKHookContext context) + { + context = context ?? throw new global::System.ArgumentNullException(nameof(context)); + + if (context.Request == null) + { + return; + } + + var perRequest = context.RequestOptions?.Authorizations; + if (perRequest != null && perRequest.Count > 0) + { + for (var index = 0; index < perRequest.Count; index++) + { + ApplyAuthorization(context.Request, perRequest[index]); + } + + global::Together.AutoSDKHttpRequestOptions.StampAuthorizationOverride(context.Request); + return; + } + + var provider = context.ClientOptions?.AuthorizationProvider; + if (provider == null) + { + return; + } + + var resolved = await provider.ResolveAsync(context).ConfigureAwait(false); + if (resolved == null || resolved.Count == 0) + { + return; + } + + for (var index = 0; index < resolved.Count; index++) + { + ApplyAuthorization(context.Request, resolved[index]); + } + + global::Together.AutoSDKHttpRequestOptions.StampAuthorizationOverride(context.Request); + } + + private static void ApplyAuthorization( + global::System.Net.Http.HttpRequestMessage request, + global::Together.AutoSDKAuthorizationValue authorization) + { + switch (authorization.Type) + { + case "Http": + case "OAuth2": + case "OpenIdConnect": + request.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: authorization.Scheme, + parameter: authorization.Value); + break; + case "ApiKey": + if (string.Equals(authorization.Location, "Header", global::System.StringComparison.OrdinalIgnoreCase) && + !string.IsNullOrEmpty(authorization.HeaderName)) + { + request.Headers.Remove(authorization.HeaderName); + request.Headers.TryAddWithoutValidation(authorization.HeaderName, authorization.Value ?? string.Empty); + } + break; + } + } + } + + /// + /// Per-request overrides applied on top of . + /// + public sealed class AutoSDKRequestOptions + { + /// + /// Additional headers applied after generated and client-level headers. + /// + public global::System.Collections.Generic.Dictionary Headers { get; } = + new global::System.Collections.Generic.Dictionary(global::System.StringComparer.OrdinalIgnoreCase); + + /// + /// Additional query parameters appended after generated and client-level query parameters. + /// + public global::System.Collections.Generic.Dictionary QueryParameters { get; } = + new global::System.Collections.Generic.Dictionary(global::System.StringComparer.Ordinal); + + /// + /// Optional timeout override for this request. + /// + public global::System.TimeSpan? Timeout { get; set; } + + /// + /// Optional retry override for this request. + /// + public global::Together.AutoSDKRetryOptions? Retry { get; set; } + + /// + /// Overrides response buffering for this request when set. + /// + public bool? ReadResponseAsString { get; set; } + + /// + /// Optional per-request authorization values. When non-empty, the built-in + /// applies these instead of consulting + /// for this request only. + /// Useful for multi-tenant routing or "act-as" admin tooling that needs a different + /// credential per call without mutating shared client state. + /// + public global::System.Collections.Generic.IReadOnlyList? Authorizations { get; set; } + } + + /// + /// Retry settings for generated HTTP requests. + /// + public sealed class AutoSDKRetryOptions + { + /// + /// Total number of attempts, including the initial request. + /// Values less than 1 are normalized to 1. + /// + public int MaxAttempts { get; set; } = 1; + + /// + /// Optional fixed delay between retry attempts. When set, this takes precedence over exponential backoff. + /// + public global::System.TimeSpan? Delay { get; set; } + + /// + /// Initial exponential backoff delay used when is not set. + /// + public global::System.TimeSpan InitialDelay { get; set; } = global::System.TimeSpan.FromSeconds(1); + + /// + /// Maximum retry delay after applying retry headers, backoff, and jitter. + /// + public global::System.TimeSpan MaxDelay { get; set; } = global::System.TimeSpan.FromSeconds(30); + + /// + /// Multiplier applied to exponential backoff after each failed attempt. + /// Values below 1 are normalized to 1. + /// + public double BackoffMultiplier { get; set; } = 2D; + + /// + /// Randomizes computed backoff by plus or minus this ratio. Values are clamped to 0..1. + /// + public double JitterRatio { get; set; } = 0.2D; + + /// + /// Whether Retry-After response headers should control retry delay when present. + /// + public bool UseRetryAfterHeader { get; set; } = true; + + /// + /// Whether a rate-limit reset response header should control retry delay when present. + /// + public bool UseRateLimitResetHeader { get; set; } + + /// + /// Optional provider-specific rate-limit reset header name. Values may be Unix seconds or an HTTP date. + /// + public string? RateLimitResetHeaderName { get; set; } = "X-RateLimit-Reset"; + } + + + /// + /// Runtime hook interface for generated SDK lifecycle events. + /// + public interface IAutoSDKHook + { + /// + /// Runs before a request is sent. + /// + /// + global::System.Threading.Tasks.Task OnBeforeRequestAsync( + global::Together.AutoSDKHookContext context); + + /// + /// Runs after a successful HTTP response is received. + /// + /// + global::System.Threading.Tasks.Task OnAfterSuccessAsync( + global::Together.AutoSDKHookContext context); + + /// + /// Runs after an error response or transport failure is observed. + /// + /// + global::System.Threading.Tasks.Task OnAfterErrorAsync( + global::Together.AutoSDKHookContext context); + } + + /// + /// Convenience base type for request hooks with no-op defaults. + /// + public abstract class AutoSDKHook : global::Together.IAutoSDKHook + { + /// + public virtual global::System.Threading.Tasks.Task OnBeforeRequestAsync( + global::Together.AutoSDKHookContext context) + { + return global::System.Threading.Tasks.Task.CompletedTask; + } + + /// + public virtual global::System.Threading.Tasks.Task OnAfterSuccessAsync( + global::Together.AutoSDKHookContext context) + { + return global::System.Threading.Tasks.Task.CompletedTask; + } + + /// + public virtual global::System.Threading.Tasks.Task OnAfterErrorAsync( + global::Together.AutoSDKHookContext context) + { + return global::System.Threading.Tasks.Task.CompletedTask; + } + } + + /// + /// Runtime metadata passed to generated SDK hooks. + /// + public sealed class AutoSDKHookContext + { + /// + /// The source OpenAPI operation id or generated fallback id. + /// + public string OperationId { get; set; } = string.Empty; + + /// + /// The generated C# method name. + /// + public string MethodName { get; set; } = string.Empty; + + /// + /// The OpenAPI path template for the operation. + /// + public string PathTemplate { get; set; } = string.Empty; + + /// + /// The HTTP method used for the request. + /// + public string HttpMethod { get; set; } = string.Empty; + + /// + /// The client's resolved base URI. + /// + public global::System.Uri? BaseUri { get; set; } + + /// + /// The outgoing HTTP request for the current attempt. + /// + public global::System.Net.Http.HttpRequestMessage Request { get; set; } = null!; + + /// + /// The HTTP response when one was received. + /// + public global::System.Net.Http.HttpResponseMessage? Response { get; set; } + + /// + /// The transport or processing exception when one was observed. + /// + public global::System.Exception? Exception { get; set; } + + /// + /// The client-wide runtime options. + /// + public global::Together.AutoSDKClientOptions ClientOptions { get; set; } = null!; + + /// + /// The per-request runtime options. + /// + public global::Together.AutoSDKRequestOptions? RequestOptions { get; set; } + + /// + /// The current attempt number, starting at 1. + /// + public int Attempt { get; set; } + + /// + /// The total number of attempts allowed for this request. + /// + public int MaxAttempts { get; set; } + + /// + /// Indicates whether the generated client will retry after this hook invocation. + /// + public bool WillRetry { get; set; } + + /// + /// The computed retry delay when is true. + /// + public global::System.TimeSpan? RetryDelay { get; set; } + + /// + /// A short retry reason such as exception or status:429. + /// + public string RetryReason { get; set; } = string.Empty; + + /// + /// The effective cancellation token for the current request attempt. + /// + public global::System.Threading.CancellationToken CancellationToken { get; set; } + } + + + internal static class AutoSDKRequestOptionsSupport + { + internal static global::Together.AutoSDKHookContext CreateHookContext( + string operationId, + string methodName, + string pathTemplate, + string httpMethod, + global::System.Uri? baseUri, + global::System.Net.Http.HttpRequestMessage request, + global::System.Net.Http.HttpResponseMessage? response, + global::System.Exception? exception, + global::Together.AutoSDKClientOptions clientOptions, + global::Together.AutoSDKRequestOptions? requestOptions, + int attempt, + int maxAttempts, + bool willRetry, + global::System.TimeSpan? retryDelay, + string retryReason, + global::System.Threading.CancellationToken cancellationToken) + { + return new global::Together.AutoSDKHookContext + { + OperationId = operationId ?? string.Empty, + MethodName = methodName ?? string.Empty, + PathTemplate = pathTemplate ?? string.Empty, + HttpMethod = httpMethod ?? string.Empty, + BaseUri = baseUri, + Request = request, + Response = response, + Exception = exception, + ClientOptions = clientOptions, + RequestOptions = requestOptions, + Attempt = attempt, + MaxAttempts = maxAttempts, + WillRetry = willRetry, + RetryDelay = retryDelay, + RetryReason = retryReason ?? string.Empty, + CancellationToken = cancellationToken, + }; + } + + internal static global::System.Threading.Tasks.Task OnBeforeRequestAsync( + global::Together.AutoSDKClientOptions clientOptions, + global::Together.AutoSDKHookContext context) + { + return InvokeHooksAsync(clientOptions, static (hook, hookContext) => hook.OnBeforeRequestAsync(hookContext), context); + } + + internal static global::System.Threading.Tasks.Task OnAfterSuccessAsync( + global::Together.AutoSDKClientOptions clientOptions, + global::Together.AutoSDKHookContext context) + { + return InvokeHooksAsync(clientOptions, static (hook, hookContext) => hook.OnAfterSuccessAsync(hookContext), context); + } + + internal static global::System.Threading.Tasks.Task OnAfterErrorAsync( + global::Together.AutoSDKClientOptions clientOptions, + global::Together.AutoSDKHookContext context) + { + return InvokeHooksAsync(clientOptions, static (hook, hookContext) => hook.OnAfterErrorAsync(hookContext), context); + } + + internal static bool GetReadResponseAsString( + global::Together.AutoSDKClientOptions clientOptions, + global::Together.AutoSDKRequestOptions? requestOptions, + bool fallbackValue) + { + return requestOptions?.ReadResponseAsString ?? + clientOptions.ReadResponseAsString ?? + fallbackValue; + } + + internal static global::System.Threading.CancellationTokenSource? CreateTimeoutCancellationTokenSource( + global::Together.AutoSDKClientOptions clientOptions, + global::Together.AutoSDKRequestOptions? requestOptions, + global::System.Threading.CancellationToken cancellationToken) + { + var timeout = requestOptions?.Timeout ?? clientOptions.Timeout; + if (!timeout.HasValue || timeout.Value <= global::System.TimeSpan.Zero) + { + return null; + } + + var cancellationTokenSource = global::System.Threading.CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); + cancellationTokenSource.CancelAfter(timeout.Value); + return cancellationTokenSource; + } + + internal static int GetMaxAttempts( + global::Together.AutoSDKClientOptions clientOptions, + global::Together.AutoSDKRequestOptions? requestOptions, + bool supportsRetry) + { + if (!supportsRetry) + { + return 1; + } + + var maxAttempts = requestOptions?.Retry?.MaxAttempts ?? + clientOptions.Retry?.MaxAttempts ?? + 1; + return maxAttempts < 1 ? 1 : maxAttempts; + } + + internal static global::System.TimeSpan GetRetryDelay( + global::Together.AutoSDKClientOptions clientOptions, + global::Together.AutoSDKRequestOptions? requestOptions, + global::System.Net.Http.HttpResponseMessage? response, + int attempt) + { + var retryOptions = requestOptions?.Retry ?? clientOptions.Retry ?? new global::Together.AutoSDKRetryOptions(); + + if (retryOptions.UseRetryAfterHeader && + TryGetRetryAfterDelay(response, out var retryAfterDelay)) + { + return ClampRetryDelay(retryAfterDelay, retryOptions); + } + + if (retryOptions.UseRateLimitResetHeader && + TryGetRateLimitResetDelay(response, retryOptions.RateLimitResetHeaderName, out var rateLimitResetDelay)) + { + return ClampRetryDelay(rateLimitResetDelay, retryOptions); + } + + if (retryOptions.Delay.HasValue) + { + return ClampRetryDelay(retryOptions.Delay.Value, retryOptions); + } + + var initialDelay = retryOptions.InitialDelay; + if (initialDelay <= global::System.TimeSpan.Zero) + { + return global::System.TimeSpan.Zero; + } + + var multiplier = retryOptions.BackoffMultiplier < 1D ? 1D : retryOptions.BackoffMultiplier; + var exponent = attempt <= 1 ? 0 : attempt - 1; + var delayMilliseconds = initialDelay.TotalMilliseconds * global::System.Math.Pow(multiplier, exponent); + if (double.IsNaN(delayMilliseconds) || double.IsInfinity(delayMilliseconds) || delayMilliseconds < 0D) + { + delayMilliseconds = 0D; + } + + var delay = global::System.TimeSpan.FromMilliseconds(delayMilliseconds); + delay = ApplyJitter(delay, retryOptions.JitterRatio); + return ClampRetryDelay(delay, retryOptions); + } + + internal static async global::System.Threading.Tasks.Task DelayBeforeRetryAsync( + global::System.TimeSpan retryDelay, + global::System.Threading.CancellationToken cancellationToken) + { + if (retryDelay <= global::System.TimeSpan.Zero) + { + return; + } + + await global::System.Threading.Tasks.Task.Delay(retryDelay, cancellationToken).ConfigureAwait(false); + } + + private static bool TryGetRetryAfterDelay( + global::System.Net.Http.HttpResponseMessage? response, + out global::System.TimeSpan delay) + { + delay = global::System.TimeSpan.Zero; + var retryAfter = response?.Headers.RetryAfter; + if (retryAfter == null) + { + return false; + } + + if (retryAfter.Delta.HasValue) + { + delay = retryAfter.Delta.Value; + return delay > global::System.TimeSpan.Zero; + } + + if (retryAfter.Date.HasValue) + { + delay = retryAfter.Date.Value - global::System.DateTimeOffset.UtcNow; + return delay > global::System.TimeSpan.Zero; + } + + return false; + } + + private static bool TryGetRateLimitResetDelay( + global::System.Net.Http.HttpResponseMessage? response, + string? headerName, + out global::System.TimeSpan delay) + { + delay = global::System.TimeSpan.Zero; + if (response == null || string.IsNullOrWhiteSpace(headerName)) + { + return false; + } + + if (!response.Headers.TryGetValues(headerName, out var values) && + (response.Content?.Headers == null || !response.Content.Headers.TryGetValues(headerName, out values))) + { + return false; + } + + var value = global::System.Linq.Enumerable.FirstOrDefault(values); + if (string.IsNullOrWhiteSpace(value)) + { + return false; + } + + value = value.Trim(); + if (long.TryParse( + value, + global::System.Globalization.NumberStyles.Integer, + global::System.Globalization.CultureInfo.InvariantCulture, + out var unixSeconds)) + { + delay = global::System.DateTimeOffset.FromUnixTimeSeconds(unixSeconds) - global::System.DateTimeOffset.UtcNow; + return delay > global::System.TimeSpan.Zero; + } + + if (global::System.DateTimeOffset.TryParse( + value, + global::System.Globalization.CultureInfo.InvariantCulture, + global::System.Globalization.DateTimeStyles.AssumeUniversal | global::System.Globalization.DateTimeStyles.AdjustToUniversal, + out var resetAt)) + { + delay = resetAt - global::System.DateTimeOffset.UtcNow; + return delay > global::System.TimeSpan.Zero; + } + + return false; + } + + private static global::System.TimeSpan ApplyJitter( + global::System.TimeSpan delay, + double jitterRatio) + { + if (delay <= global::System.TimeSpan.Zero || jitterRatio <= 0D) + { + return delay; + } + + if (jitterRatio > 1D) + { + jitterRatio = 1D; + } + + var sample = NextJitterSample(); + var multiplier = 1D - jitterRatio + (sample * jitterRatio * 2D); + var milliseconds = delay.TotalMilliseconds * multiplier; + if (double.IsNaN(milliseconds) || double.IsInfinity(milliseconds) || milliseconds < 0D) + { + milliseconds = 0D; + } + + return global::System.TimeSpan.FromMilliseconds(milliseconds); + } + + private static double NextJitterSample() + { + var bytes = new byte[8]; + using (var randomNumberGenerator = global::System.Security.Cryptography.RandomNumberGenerator.Create()) + { + randomNumberGenerator.GetBytes(bytes); + } + + var value = global::System.BitConverter.ToUInt64(bytes, 0); + return value / (double)ulong.MaxValue; + } + + private static global::System.TimeSpan ClampRetryDelay( + global::System.TimeSpan delay, + global::Together.AutoSDKRetryOptions retryOptions) + { + if (delay <= global::System.TimeSpan.Zero) + { + return global::System.TimeSpan.Zero; + } + + var maxDelay = retryOptions.MaxDelay; + if (maxDelay > global::System.TimeSpan.Zero && delay > maxDelay) + { + return maxDelay; + } + + return delay; + } + + internal static bool ShouldRetryStatusCode( + global::System.Net.HttpStatusCode statusCode) + { + return (int)statusCode switch + { + 408 => true, + 429 => true, + 500 => true, + 502 => true, + 503 => true, + 504 => true, + _ => false, + }; + } + + internal static string AppendQueryParameters( + string path, + global::System.Collections.Generic.Dictionary clientParameters, + global::System.Collections.Generic.Dictionary? requestParameters) + { + var hasClientParameters = clientParameters != null && clientParameters.Count > 0; + var hasRequestParameters = requestParameters != null && requestParameters.Count > 0; + if (!hasClientParameters && !hasRequestParameters) + { + return path; + } + + var builder = new global::System.Text.StringBuilder(path ?? string.Empty); + var hasQuery = builder.ToString().IndexOf("?", global::System.StringComparison.Ordinal) >= 0; + AppendParameters(builder, clientParameters, ref hasQuery); + AppendParameters(builder, requestParameters, ref hasQuery); + return builder.ToString(); + } + + internal static void ApplyHeaders( + global::System.Net.Http.HttpRequestMessage request, + global::System.Collections.Generic.Dictionary clientHeaders, + global::System.Collections.Generic.Dictionary? requestHeaders) + { + ApplyHeadersCore(request, clientHeaders); + ApplyHeadersCore(request, requestHeaders); + } + + private static void AppendParameters( + global::System.Text.StringBuilder builder, + global::System.Collections.Generic.Dictionary? parameters, + ref bool hasQuery) + { + if (parameters == null || parameters.Count == 0) + { + return; + } + + foreach (var parameter in parameters) + { + builder.Append(hasQuery ? '&' : '?'); + builder.Append(global::System.Uri.EscapeDataString(parameter.Key)); + builder.Append('='); + builder.Append(global::System.Uri.EscapeDataString(parameter.Value ?? string.Empty)); + hasQuery = true; + } + } + + private static void ApplyHeadersCore( + global::System.Net.Http.HttpRequestMessage request, + global::System.Collections.Generic.Dictionary? headers) + { + if (headers == null || headers.Count == 0) + { + return; + } + + foreach (var header in headers) + { + request.Headers.Remove(header.Key); + request.Content?.Headers.Remove(header.Key); + + if (!request.Headers.TryAddWithoutValidation(header.Key, header.Value ?? string.Empty) && + request.Content != null) + { + request.Content.Headers.TryAddWithoutValidation(header.Key, header.Value ?? string.Empty); + } + } + } + + private static async global::System.Threading.Tasks.Task InvokeHooksAsync( + global::Together.AutoSDKClientOptions clientOptions, + global::System.Func callback, + global::Together.AutoSDKHookContext context) + { + if (clientOptions.Hooks == null || clientOptions.Hooks.Count == 0) + { + return; + } + + foreach (var hook in clientOptions.Hooks) + { + if (hook == null) + { + continue; + } + + await callback(hook, context).ConfigureAwait(false); + } + } + } +} \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.PathBuilder.g.cs b/src/libs/Together/Generated/Together.PathBuilder.g.cs index 39071444..411d590e 100644 --- a/src/libs/Together/Generated/Together.PathBuilder.g.cs +++ b/src/libs/Together/Generated/Together.PathBuilder.g.cs @@ -275,6 +275,11 @@ public class EndPointAuthorization /// public string Type { get; set; } = string.Empty; + /// + /// + /// + public string SchemeId { get; set; } = string.Empty; + /// /// /// diff --git a/src/libs/Together/Generated/Together.QueueClient.CancelQueueJob.g.cs b/src/libs/Together/Generated/Together.QueueClient.CancelQueueJob.g.cs index 64ceabe1..6f8fef52 100644 --- a/src/libs/Together/Generated/Together.QueueClient.CancelQueueJob.g.cs +++ b/src/libs/Together/Generated/Together.QueueClient.CancelQueueJob.g.cs @@ -14,6 +14,7 @@ public partial class QueueClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,11 +49,39 @@ partial void ProcessCancelQueueJobResponseContent( /// unchanged. /// /// + /// 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 CancelQueueJobAsync( global::Together.QueueCancelRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CancelQueueJobAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Cancel a queued job
+ /// Cancel a pending job. Only jobs in pending status can be canceled.
+ /// Running jobs cannot be stopped. Returns the job status after the
+ /// attempt. If the job is not pending, returns 409 with the current status
+ /// unchanged. + ///
+ /// + /// 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> CancelQueueJobAsResponseAsync( + + global::Together.QueueCancelRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -69,22 +98,44 @@ partial void ProcessCancelQueueJobResponseContent( securityRequirements: s_CancelQueueJobSecurityRequirements, operationName: "CancelQueueJobAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/queue/cancel", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/queue/cancel", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -94,270 +145,455 @@ partial void ProcessCancelQueueJobResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCancelQueueJobRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCancelQueueJobRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCancelQueueJobResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Invalid request - if ((int)__response.StatusCode == 400) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - global::Together.QueueError? __value_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CancelQueueJob", + methodName: "CancelQueueJobAsync", + pathTemplate: "\"/queue/cancel\"", + 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 { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = global::Together.QueueError.FromJson(__content_400, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CancelQueueJob", + methodName: "CancelQueueJobAsync", + pathTemplate: "\"/queue/cancel\"", + 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; + } - __value_400 = global::Together.QueueError.FromJson(__content_400, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } - throw new global::Together.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Request not found - if ((int)__response.StatusCode == 404) - { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; - global::Together.QueueError? __value_404 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = global::Together.QueueError.FromJson(__content_404, JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CancelQueueJob", + methodName: "CancelQueueJobAsync", + pathTemplate: "\"/queue/cancel\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = global::Together.QueueError.FromJson(__content_404, JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_404 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Job could not be canceled (already completed/failed) - if ((int)__response.StatusCode == 409) - { - string? __content_409 = null; - global::System.Exception? __exception_409 = null; - global::Together.QueueCancelResponse? __value_409 = null; - try + using (__response) { - if (ReadResponseAsString) - { - __content_409 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_409 = global::Together.QueueCancelResponse.FromJson(__content_409, JsonSerializerContext); - } - else - { - __content_409 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_409 = global::Together.QueueCancelResponse.FromJson(__content_409, JsonSerializerContext); - } + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCancelQueueJobResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CancelQueueJob", + methodName: "CancelQueueJobAsync", + pathTemplate: "\"/queue/cancel\"", + 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); } - catch (global::System.Exception __ex) + else { - __exception_409 = __ex; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CancelQueueJob", + methodName: "CancelQueueJobAsync", + pathTemplate: "\"/queue/cancel\"", + 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); } + // Invalid request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Together.QueueError? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Together.QueueError.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - throw new global::Together.ApiException( - message: __content_409 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_409, - statusCode: __response.StatusCode) - { - ResponseBody = __content_409, - ResponseObject = __value_409, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Internal server error - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - global::Together.QueueError? __value_500 = null; - try - { - if (ReadResponseAsString) - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.QueueError.FromJson(__content_500, JsonSerializerContext); - } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __value_400 = global::Together.QueueError.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } - __value_500 = global::Together.QueueError.FromJson(__content_500, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_500 = __ex; - } + throw new global::Together.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request not found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Together.QueueError? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Together.QueueError.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) - { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } + __value_404 = global::Together.QueueError.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + throw new global::Together.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Job could not be canceled (already completed/failed) + if ((int)__response.StatusCode == 409) + { + string? __content_409 = null; + global::System.Exception? __exception_409 = null; + global::Together.QueueCancelResponse? __value_409 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_409 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_409 = global::Together.QueueCancelResponse.FromJson(__content_409, JsonSerializerContext); + } + else + { + __content_409 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessCancelQueueJobResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __value_409 = global::Together.QueueCancelResponse.FromJson(__content_409, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_409 = __ex; + } - try - { - __response.EnsureSuccessStatusCode(); + throw new global::Together.ApiException( + message: __content_409 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_409, + statusCode: __response.StatusCode) + { + ResponseBody = __content_409, + ResponseObject = __value_409, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal server error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Together.QueueError? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Together.QueueError.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - global::Together.QueueCancelResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - } - catch (global::System.Exception __ex) - { - throw new global::Together.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 - cancellationToken -#endif - ).ConfigureAwait(false); + __value_500 = global::Together.QueueError.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } - return - await global::Together.QueueCancelResponse.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessCancelQueueJobResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.QueueCancelResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.QueueCancelResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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(); + } } /// /// Cancel a queued job
@@ -372,11 +608,13 @@ partial void ProcessCancelQueueJobResponseContent( /// /// The request ID returned from the submit endpoint /// + /// 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 CancelQueueJobAsync( string model, string requestId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.QueueCancelRequest @@ -387,6 +625,7 @@ partial void ProcessCancelQueueJobResponseContent( return await CancelQueueJobAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Together/Generated/Together.QueueClient.GetQueueJobStatus.g.cs b/src/libs/Together/Generated/Together.QueueClient.GetQueueJobStatus.g.cs index bca666c4..5fd9673f 100644 --- a/src/libs/Together/Generated/Together.QueueClient.GetQueueJobStatus.g.cs +++ b/src/libs/Together/Generated/Together.QueueClient.GetQueueJobStatus.g.cs @@ -14,6 +14,7 @@ public partial class QueueClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -52,11 +53,41 @@ partial void ProcessGetQueueJobStatusResponseContent( /// /// Model name the job was submitted to /// + /// 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 GetQueueJobStatusAsync( string requestId, string model, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetQueueJobStatusAsResponseAsync( + requestId: requestId, + model: model, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get job status
+ /// Poll the current status of a previously submitted job. Provide the request_id and model as query parameters. + ///
+ /// + /// Request ID returned from the submit endpoint + /// + /// + /// Model name the job was submitted to + /// + /// 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> GetQueueJobStatusAsResponseAsync( + string requestId, + string model, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -72,26 +103,48 @@ partial void ProcessGetQueueJobStatusResponseContent( securityRequirements: s_GetQueueJobStatusSecurityRequirements, operationName: "GetQueueJobStatusAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/queue/status", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddRequiredParameter("request_id", requestId) - .AddRequiredParameter("model", model) - ; - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/queue/status", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddRequiredParameter("request_id", requestId) + .AddRequiredParameter("model", model) + ; + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -101,265 +154,450 @@ partial void ProcessGetQueueJobStatusResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetQueueJobStatusRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - requestId: requestId, - model: model); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetQueueJobStatusRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + requestId: requestId!, + model: model!); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetQueueJobStatusResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Invalid request - if ((int)__response.StatusCode == 400) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - global::Together.QueueError? __value_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetQueueJobStatus", + methodName: "GetQueueJobStatusAsync", + pathTemplate: "\"/queue/status\"", + httpMethod: "GET", + 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 { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = global::Together.QueueError.FromJson(__content_400, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetQueueJobStatus", + methodName: "GetQueueJobStatusAsync", + pathTemplate: "\"/queue/status\"", + httpMethod: "GET", + 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; + } - __value_400 = global::Together.QueueError.FromJson(__content_400, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } - throw new global::Together.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Unauthorized - if ((int)__response.StatusCode == 401) - { - string? __content_401 = null; - global::System.Exception? __exception_401 = null; - global::Together.QueueError? __value_401 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_401 = global::Together.QueueError.FromJson(__content_401, JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetQueueJobStatus", + methodName: "GetQueueJobStatusAsync", + pathTemplate: "\"/queue/status\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_401 = global::Together.QueueError.FromJson(__content_401, JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_401 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_401, - statusCode: __response.StatusCode) - { - ResponseBody = __content_401, - ResponseObject = __value_401, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Request not found - if ((int)__response.StatusCode == 404) - { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; - global::Together.QueueError? __value_404 = null; - try + using (__response) { - if (ReadResponseAsString) - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = global::Together.QueueError.FromJson(__content_404, JsonSerializerContext); - } - else - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = global::Together.QueueError.FromJson(__content_404, JsonSerializerContext); - } + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetQueueJobStatusResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetQueueJobStatus", + methodName: "GetQueueJobStatusAsync", + pathTemplate: "\"/queue/status\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - __exception_404 = __ex; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetQueueJobStatus", + methodName: "GetQueueJobStatusAsync", + pathTemplate: "\"/queue/status\"", + httpMethod: "GET", + 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); } + // Invalid request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Together.QueueError? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Together.QueueError.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - throw new global::Together.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Internal server error - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - global::Together.QueueError? __value_500 = null; - try - { - if (ReadResponseAsString) - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.QueueError.FromJson(__content_500, JsonSerializerContext); - } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __value_400 = global::Together.QueueError.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } - __value_500 = global::Together.QueueError.FromJson(__content_500, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_500 = __ex; - } + throw new global::Together.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unauthorized + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Together.QueueError? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Together.QueueError.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) - { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } + __value_401 = global::Together.QueueError.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + throw new global::Together.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseObject = __value_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Request not found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Together.QueueError? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Together.QueueError.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessGetQueueJobStatusResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __value_404 = global::Together.QueueError.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } - try - { - __response.EnsureSuccessStatusCode(); + throw new global::Together.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal server error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Together.QueueError? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Together.QueueError.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - global::Together.QueueJobStatusResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - } - catch (global::System.Exception __ex) - { - throw new global::Together.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 - cancellationToken -#endif - ).ConfigureAwait(false); + __value_500 = global::Together.QueueError.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } - return - await global::Together.QueueJobStatusResponse.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessGetQueueJobStatusResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.QueueJobStatusResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.QueueJobStatusResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.QueueClient.GetQueueMetrics.g.cs b/src/libs/Together/Generated/Together.QueueClient.GetQueueMetrics.g.cs index ae5289a6..ab52a0f7 100644 --- a/src/libs/Together/Generated/Together.QueueClient.GetQueueMetrics.g.cs +++ b/src/libs/Together/Generated/Together.QueueClient.GetQueueMetrics.g.cs @@ -14,6 +14,7 @@ public partial class QueueClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,10 +48,35 @@ partial void ProcessGetQueueMetricsResponseContent( /// /// Model name to get metrics for /// + /// 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 GetQueueMetricsAsync( string model, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetQueueMetricsAsResponseAsync( + model: model, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get queue metrics
+ /// Get the current queue statistics for a model, including pending and running job counts. + ///
+ /// + /// Model name to get metrics for + /// + /// 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> GetQueueMetricsAsResponseAsync( + string model, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -65,25 +91,47 @@ partial void ProcessGetQueueMetricsResponseContent( securityRequirements: s_GetQueueMetricsSecurityRequirements, operationName: "GetQueueMetricsAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/queue/metrics", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddRequiredParameter("model", model) - ; - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/queue/metrics", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddRequiredParameter("model", model) + ; + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -93,226 +141,411 @@ partial void ProcessGetQueueMetricsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetQueueMetricsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - model: model); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetQueueMetricsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + model: model!); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetQueueMetricsResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Invalid request - if ((int)__response.StatusCode == 400) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - global::Together.QueueError? __value_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetQueueMetrics", + methodName: "GetQueueMetricsAsync", + pathTemplate: "\"/queue/metrics\"", + httpMethod: "GET", + 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 { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = global::Together.QueueError.FromJson(__content_400, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetQueueMetrics", + methodName: "GetQueueMetricsAsync", + pathTemplate: "\"/queue/metrics\"", + httpMethod: "GET", + 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; + } - __value_400 = global::Together.QueueError.FromJson(__content_400, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } - throw new global::Together.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Unauthorized - if ((int)__response.StatusCode == 401) - { - string? __content_401 = null; - global::System.Exception? __exception_401 = null; - global::Together.QueueError? __value_401 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_401 = global::Together.QueueError.FromJson(__content_401, JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetQueueMetrics", + methodName: "GetQueueMetricsAsync", + pathTemplate: "\"/queue/metrics\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_401 = global::Together.QueueError.FromJson(__content_401, JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_401 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_401, - statusCode: __response.StatusCode) - { - ResponseBody = __content_401, - ResponseObject = __value_401, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Internal server error - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - global::Together.QueueError? __value_500 = null; - try + using (__response) { - if (ReadResponseAsString) - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.QueueError.FromJson(__content_500, JsonSerializerContext); - } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.QueueError.FromJson(__content_500, JsonSerializerContext); - } + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetQueueMetricsResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetQueueMetrics", + methodName: "GetQueueMetricsAsync", + pathTemplate: "\"/queue/metrics\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - __exception_500 = __ex; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetQueueMetrics", + methodName: "GetQueueMetricsAsync", + pathTemplate: "\"/queue/metrics\"", + httpMethod: "GET", + 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); } + // Invalid request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Together.QueueError? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Together.QueueError.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) - { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } + __value_400 = global::Together.QueueError.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + throw new global::Together.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unauthorized + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Together.QueueError? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Together.QueueError.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessGetQueueMetricsResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __value_401 = global::Together.QueueError.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } - try - { - __response.EnsureSuccessStatusCode(); + throw new global::Together.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseObject = __value_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal server error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Together.QueueError? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Together.QueueError.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - global::Together.QueueMetricsResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - } - catch (global::System.Exception __ex) - { - throw new global::Together.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 - cancellationToken -#endif - ).ConfigureAwait(false); + __value_500 = global::Together.QueueError.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } - return - await global::Together.QueueMetricsResponse.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessGetQueueMetricsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.QueueMetricsResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.QueueMetricsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.QueueClient.SubmitQueueJob.g.cs b/src/libs/Together/Generated/Together.QueueClient.SubmitQueueJob.g.cs index 231a6639..c317e682 100644 --- a/src/libs/Together/Generated/Together.QueueClient.SubmitQueueJob.g.cs +++ b/src/libs/Together/Generated/Together.QueueClient.SubmitQueueJob.g.cs @@ -14,6 +14,7 @@ public partial class QueueClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -48,11 +49,39 @@ partial void ProcessSubmitQueueJobResponseContent( /// or cancel the job. ///
/// + /// 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 SubmitQueueJobAsync( global::Together.QueueJobRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await SubmitQueueJobAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Submit a queued job
+ /// Submit a new job to the queue for asynchronous processing. Jobs are
+ /// processed in strict priority order (higher priority first, FIFO within
+ /// the same priority). Returns a request ID that can be used to poll status
+ /// or cancel the job. + ///
+ /// + /// 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> SubmitQueueJobAsResponseAsync( + + global::Together.QueueJobRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -69,22 +98,44 @@ partial void ProcessSubmitQueueJobResponseContent( securityRequirements: s_SubmitQueueJobSecurityRequirements, operationName: "SubmitQueueJobAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/queue/submit", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/queue/submit", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -94,232 +145,417 @@ partial void ProcessSubmitQueueJobResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSubmitQueueJobRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareSubmitQueueJobRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessSubmitQueueJobResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Invalid request - if ((int)__response.StatusCode == 400) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - global::Together.QueueError? __value_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SubmitQueueJob", + methodName: "SubmitQueueJobAsync", + pathTemplate: "\"/queue/submit\"", + 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 { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = global::Together.QueueError.FromJson(__content_400, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SubmitQueueJob", + methodName: "SubmitQueueJobAsync", + pathTemplate: "\"/queue/submit\"", + 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; + } - __value_400 = global::Together.QueueError.FromJson(__content_400, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } - throw new global::Together.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Unauthorized - if ((int)__response.StatusCode == 401) - { - string? __content_401 = null; - global::System.Exception? __exception_401 = null; - global::Together.QueueError? __value_401 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_401 = global::Together.QueueError.FromJson(__content_401, JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SubmitQueueJob", + methodName: "SubmitQueueJobAsync", + pathTemplate: "\"/queue/submit\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_401 = global::Together.QueueError.FromJson(__content_401, JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_401 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_401, - statusCode: __response.StatusCode) - { - ResponseBody = __content_401, - ResponseObject = __value_401, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Internal server error - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - global::Together.QueueError? __value_500 = null; - try + using (__response) { - if (ReadResponseAsString) - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.QueueError.FromJson(__content_500, JsonSerializerContext); - } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Together.QueueError.FromJson(__content_500, JsonSerializerContext); - } + ProcessResponse( + client: HttpClient, + response: __response); + ProcessSubmitQueueJobResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SubmitQueueJob", + methodName: "SubmitQueueJobAsync", + pathTemplate: "\"/queue/submit\"", + 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); } - catch (global::System.Exception __ex) + else { - __exception_500 = __ex; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SubmitQueueJob", + methodName: "SubmitQueueJobAsync", + pathTemplate: "\"/queue/submit\"", + 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); } + // Invalid request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Together.QueueError? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Together.QueueError.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) - { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } + __value_400 = global::Together.QueueError.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + throw new global::Together.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unauthorized + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Together.QueueError? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Together.QueueError.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessSubmitQueueJobResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __value_401 = global::Together.QueueError.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } - try - { - __response.EnsureSuccessStatusCode(); + throw new global::Together.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseObject = __value_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal server error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Together.QueueError? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Together.QueueError.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - global::Together.QueueJobResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - } - catch (global::System.Exception __ex) - { - throw new global::Together.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 - cancellationToken -#endif - ).ConfigureAwait(false); + __value_500 = global::Together.QueueError.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } - return - await global::Together.QueueJobResponse.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessSubmitQueueJobResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.QueueJobResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.QueueJobResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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(); + } } /// /// Submit a queued job
@@ -345,6 +581,7 @@ partial void ProcessSubmitQueueJobResponseContent( /// order (FIFO).
/// Default Value: 0 /// + /// 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 SubmitQueueJobAsync( @@ -352,6 +589,7 @@ partial void ProcessSubmitQueueJobResponseContent( object payload, object? info = default, int? priority = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.QueueJobRequest @@ -364,6 +602,7 @@ partial void ProcessSubmitQueueJobResponseContent( return await SubmitQueueJobAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Together/Generated/Together.QueueClient.g.cs b/src/libs/Together/Generated/Together.QueueClient.g.cs index 199eff9e..b86c83cf 100644 --- a/src/libs/Together/Generated/Together.QueueClient.g.cs +++ b/src/libs/Together/Generated/Together.QueueClient.g.cs @@ -12,7 +12,7 @@ public sealed partial class QueueClient : global::Together.IQueueClient, global: /// /// /// - public const string DefaultBaseUrl = "https://api.together.xyz/v1"; + public const string DefaultBaseUrl = "https://api.together.ai/v1"; private bool _disposeHttpClient = true; @@ -30,6 +30,12 @@ public sealed partial class QueueClient : global::Together.IQueueClient, global: #if DEBUG = true; #endif + + /// + public global::Together.AutoSDKClientOptions Options { get; } + + + internal global::Together.AutoSDKServerConfiguration AutoSDKServerConfiguration { get; set; } = new global::Together.AutoSDKServerConfiguration(); /// /// /// @@ -49,13 +55,62 @@ public QueueClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the QueueClient with explicit options but no base URL override. + /// Skips passing baseUri so the default base URL from the OpenAPI spec applies. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public QueueClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, + bool disposeHttpClient = true) : this( + httpClient, + baseUri: null, + authorizations, + options, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the QueueClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public QueueClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Together.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; + AutoSDKServerConfiguration.ExplicitBaseUri = baseUri ?? httpClient?.BaseAddress; + Initialized(HttpClient); } diff --git a/src/libs/Together/Generated/Together.RegionServiceClient.RegionServiceList.g.cs b/src/libs/Together/Generated/Together.RegionServiceClient.RegionServiceList.g.cs index fc912c19..7045cb97 100644 --- a/src/libs/Together/Generated/Together.RegionServiceClient.RegionServiceList.g.cs +++ b/src/libs/Together/Generated/Together.RegionServiceClient.RegionServiceList.g.cs @@ -14,6 +14,7 @@ public partial class RegionServiceClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -41,6 +42,7 @@ partial void ProcessRegionServiceListResponseContent( /// /// List regions and corresponding supported driver versions /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -50,6 +52,30 @@ partial void ProcessRegionServiceListResponseContent( /// print(regions) /// public async global::System.Threading.Tasks.Task RegionServiceListAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await RegionServiceListAsResponseAsync( + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// List regions and corresponding supported driver versions + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// regions = client.beta.clusters.list_regions()
+ /// print(regions) + ///
+ public async global::System.Threading.Tasks.Task> RegionServiceListAsResponseAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -63,22 +89,44 @@ partial void ProcessRegionServiceListResponseContent( securityRequirements: s_RegionServiceListSecurityRequirements, operationName: "RegionServiceListAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/compute/regions", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/compute/regions", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -88,111 +136,296 @@ partial void ProcessRegionServiceListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareRegionServiceListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareRegionServiceListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessRegionServiceListResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RegionServiceList", + methodName: "RegionServiceListAsync", + pathTemplate: "\"/compute/regions\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RegionServiceList", + methodName: "RegionServiceListAsync", + pathTemplate: "\"/compute/regions\"", + httpMethod: "GET", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessRegionServiceListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RegionServiceList", + methodName: "RegionServiceListAsync", + pathTemplate: "\"/compute/regions\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::Together.RegionListResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Together.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), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return - await global::Together.RegionListResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessRegionServiceListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RegionServiceList", + methodName: "RegionServiceListAsync", + pathTemplate: "\"/compute/regions\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RegionServiceList", + methodName: "RegionServiceListAsync", + pathTemplate: "\"/compute/regions\"", + httpMethod: "GET", + 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); + ProcessRegionServiceListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.RegionListResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.RegionListResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.RegionServiceClient.g.cs b/src/libs/Together/Generated/Together.RegionServiceClient.g.cs index b7c8a0da..8ec26453 100644 --- a/src/libs/Together/Generated/Together.RegionServiceClient.g.cs +++ b/src/libs/Together/Generated/Together.RegionServiceClient.g.cs @@ -12,7 +12,7 @@ public sealed partial class RegionServiceClient : global::Together.IRegionServic /// /// /// - public const string DefaultBaseUrl = "https://api.together.xyz/v1"; + public const string DefaultBaseUrl = "https://api.together.ai/v1"; private bool _disposeHttpClient = true; @@ -30,6 +30,12 @@ public sealed partial class RegionServiceClient : global::Together.IRegionServic #if DEBUG = true; #endif + + /// + public global::Together.AutoSDKClientOptions Options { get; } + + + internal global::Together.AutoSDKServerConfiguration AutoSDKServerConfiguration { get; set; } = new global::Together.AutoSDKServerConfiguration(); /// /// /// @@ -49,13 +55,62 @@ public RegionServiceClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the RegionServiceClient with explicit options but no base URL override. + /// Skips passing baseUri so the default base URL from the OpenAPI spec applies. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public RegionServiceClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, + bool disposeHttpClient = true) : this( + httpClient, + baseUri: null, + authorizations, + options, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the RegionServiceClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public RegionServiceClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Together.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; + AutoSDKServerConfiguration.ExplicitBaseUri = baseUri ?? httpClient?.BaseAddress; + Initialized(HttpClient); } diff --git a/src/libs/Together/Generated/Together.RerankClient.Rerank.g.cs b/src/libs/Together/Generated/Together.RerankClient.Rerank.g.cs index 6336e274..3577c6e0 100644 --- a/src/libs/Together/Generated/Together.RerankClient.Rerank.g.cs +++ b/src/libs/Together/Generated/Together.RerankClient.Rerank.g.cs @@ -14,6 +14,7 @@ public partial class RerankClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,6 +46,7 @@ partial void ProcessRerankResponseContent( /// Rerank a list of documents by relevance to a query. Returns a relevance score and ordering index for each document. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -85,6 +87,65 @@ partial void ProcessRerankResponseContent( public async global::System.Threading.Tasks.Task RerankAsync( global::Together.RerankRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await RerankAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Create a rerank request
+ /// Rerank a list of documents by relevance to a query. Returns a relevance score and ordering index for each document. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// documents = [
+ /// {
+ /// "title": "Llama",
+ /// "text": "The llama is a domesticated South American camelid, widely used as a meat and pack animal by Andean cultures since the pre-Columbian era."
+ /// },
+ /// {
+ /// "title": "Panda",
+ /// "text": "The giant panda (Ailuropoda melanoleuca), also known as the panda bear or simply panda, is a bear species endemic to China."
+ /// },
+ /// {
+ /// "title": "Guanaco",
+ /// "text": "The guanaco is a camelid native to South America, closely related to the llama. Guanacos are one of two wild South American camelids; the other species is the vicuña, which lives at higher elevations."
+ /// },
+ /// {
+ /// "title": "Wild Bactrian camel",
+ /// "text": "The wild Bactrian camel (Camelus ferus) is an endangered species of camel endemic to Northwest China and southwestern Mongolia."
+ /// }
+ /// ]
+ /// response = client.rerank.create(
+ /// model="Salesforce/Llama-Rank-v1",
+ /// query="What animals can I find near Peru?",
+ /// documents=documents,
+ /// )
+ /// for result in response.results:
+ /// print(f"Rank: {result.index + 1}")
+ /// print(f"Title: {documents[result.index]['title']}")
+ /// print(f"Text: {documents[result.index]['text']}") + ///
+ public async global::System.Threading.Tasks.Task> RerankAsResponseAsync( + + global::Together.RerankRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -101,22 +162,44 @@ partial void ProcessRerankResponseContent( securityRequirements: s_RerankSecurityRequirements, operationName: "RerankAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/rerank", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/rerank", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -126,346 +209,531 @@ partial void ProcessRerankResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } - } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareRerankRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); - - ProcessResponse( - client: HttpClient, - response: __response); - ProcessRerankResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // BadRequest - if ((int)__response.StatusCode == 400) - { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - global::Together.ErrorData? __value_400 = null; - try - { - if (ReadResponseAsString) - { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); - } - else - { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - - __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } - - throw new global::Together.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + } } - // Unauthorized - if ((int)__response.StatusCode == 401) - { - string? __content_401 = null; - global::System.Exception? __exception_401 = null; - global::Together.ErrorData? __value_401 = null; - try - { - if (ReadResponseAsString) - { - __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); - } - else - { - __content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - - __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_401 = __ex; - } + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareRerankRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - throw new global::Together.ApiException( - message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_401, - statusCode: __response.StatusCode) - { - ResponseBody = __content_401, - ResponseObject = __value_401, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + return __httpRequest; } - // NotFound - if ((int)__response.StatusCode == 404) - { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; - global::Together.ErrorData? __value_404 = null; - try - { - if (ReadResponseAsString) - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); - } - else - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_404 = __ex; - } - - throw new global::Together.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // RateLimit - if ((int)__response.StatusCode == 429) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_429 = null; - global::System.Exception? __exception_429 = null; - global::Together.ErrorData? __value_429 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Rerank", + methodName: "RerankAsync", + pathTemplate: "\"/rerank\"", + 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 { - __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_429 = global::Together.ErrorData.FromJson(__content_429, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_429 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - - __value_429 = global::Together.ErrorData.FromJson(__content_429, JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Rerank", + methodName: "RerankAsync", + pathTemplate: "\"/rerank\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_429 = __ex; - } - throw new global::Together.ApiException( - message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_429, - statusCode: __response.StatusCode) - { - ResponseBody = __content_429, - ResponseObject = __value_429, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Overloaded - if ((int)__response.StatusCode == 503) - { - string? __content_503 = null; - global::System.Exception? __exception_503 = null; - global::Together.ErrorData? __value_503 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_503 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_503 = global::Together.ErrorData.FromJson(__content_503, JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Rerank", + methodName: "RerankAsync", + pathTemplate: "\"/rerank\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_503 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_503 = global::Together.ErrorData.FromJson(__content_503, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_503 = __ex; + break; } - throw new global::Together.ApiException( - message: __content_503 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_503, - statusCode: __response.StatusCode) - { - ResponseBody = __content_503, - ResponseObject = __value_503, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Timeout - if ((int)__response.StatusCode == 504) - { - string? __content_504 = null; - global::System.Exception? __exception_504 = null; - global::Together.ErrorData? __value_504 = null; - try - { - if (ReadResponseAsString) - { - __content_504 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_504 = global::Together.ErrorData.FromJson(__content_504, JsonSerializerContext); - } - else - { - __content_504 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - - __value_504 = global::Together.ErrorData.FromJson(__content_504, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) + if (__response == null) { - __exception_504 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_504 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_504, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_504, - ResponseObject = __value_504, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessRerankResponseContent( + response: __response); + ProcessRerankResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.RerankResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Rerank", + methodName: "RerankAsync", + pathTemplate: "\"/rerank\"", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Rerank", + methodName: "RerankAsync", + pathTemplate: "\"/rerank\"", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - - return - await global::Together.RerankResponse.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + // BadRequest + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Together.ErrorData? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Together.ErrorData.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Together.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Unauthorized + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Together.ErrorData? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Together.ErrorData.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Together.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseObject = __value_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // NotFound + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Together.ErrorData? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::Together.ErrorData.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Together.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // RateLimit + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Together.ErrorData? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Together.ErrorData.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Together.ErrorData.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Together.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseObject = __value_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Overloaded + if ((int)__response.StatusCode == 503) + { + string? __content_503 = null; + global::System.Exception? __exception_503 = null; + global::Together.ErrorData? __value_503 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_503 = global::Together.ErrorData.FromJson(__content_503, JsonSerializerContext); + } + else + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_503 = global::Together.ErrorData.FromJson(__content_503, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_503 = __ex; + } + + throw new global::Together.ApiException( + message: __content_503 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_503, + statusCode: __response.StatusCode) + { + ResponseBody = __content_503, + ResponseObject = __value_503, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Timeout + if ((int)__response.StatusCode == 504) + { + string? __content_504 = null; + global::System.Exception? __exception_504 = null; + global::Together.ErrorData? __value_504 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_504 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_504 = global::Together.ErrorData.FromJson(__content_504, JsonSerializerContext); + } + else + { + __content_504 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_504 = global::Together.ErrorData.FromJson(__content_504, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_504 = __ex; + } + + throw new global::Together.ApiException( + message: __content_504 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_504, + statusCode: __response.StatusCode) + { + ResponseBody = __content_504, + ResponseObject = __value_504, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessRerankResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.RerankResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.RerankResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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 a rerank request
@@ -495,6 +763,7 @@ partial void ProcessRerankResponseContent( /// List of keys in the JSON Object document to rank by. Defaults to use all supplied keys for ranking.
/// Example: [title, text] /// + /// 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 RerankAsync( @@ -504,6 +773,7 @@ partial void ProcessRerankResponseContent( int? topN = default, bool? returnDocuments = default, global::System.Collections.Generic.IList? rankFields = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.RerankRequest @@ -518,6 +788,7 @@ partial void ProcessRerankResponseContent( return await RerankAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Together/Generated/Together.RerankClient.g.cs b/src/libs/Together/Generated/Together.RerankClient.g.cs index 1dcbd010..ea0fd0cc 100644 --- a/src/libs/Together/Generated/Together.RerankClient.g.cs +++ b/src/libs/Together/Generated/Together.RerankClient.g.cs @@ -12,7 +12,7 @@ public sealed partial class RerankClient : global::Together.IRerankClient, globa /// /// /// - public const string DefaultBaseUrl = "https://api.together.xyz/v1"; + public const string DefaultBaseUrl = "https://api.together.ai/v1"; private bool _disposeHttpClient = true; @@ -30,6 +30,12 @@ public sealed partial class RerankClient : global::Together.IRerankClient, globa #if DEBUG = true; #endif + + /// + public global::Together.AutoSDKClientOptions Options { get; } + + + internal global::Together.AutoSDKServerConfiguration AutoSDKServerConfiguration { get; set; } = new global::Together.AutoSDKServerConfiguration(); /// /// /// @@ -49,13 +55,62 @@ public RerankClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the RerankClient with explicit options but no base URL override. + /// Skips passing baseUri so the default base URL from the OpenAPI spec applies. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public RerankClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, + bool disposeHttpClient = true) : this( + httpClient, + baseUri: null, + authorizations, + options, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the RerankClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public RerankClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Together.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; + AutoSDKServerConfiguration.ExplicitBaseUri = baseUri ?? httpClient?.BaseAddress; + Initialized(HttpClient); } diff --git a/src/libs/Together/Generated/Together.ResponseStream.g.cs b/src/libs/Together/Generated/Together.ResponseStream.g.cs new file mode 100644 index 00000000..92977270 --- /dev/null +++ b/src/libs/Together/Generated/Together.ResponseStream.g.cs @@ -0,0 +1,117 @@ + +#nullable enable + +namespace Together +{ + internal sealed class ResponseStream : global::System.IO.Stream + { + private readonly global::System.Net.Http.HttpResponseMessage _response; + private readonly global::System.IO.Stream _stream; + private bool _disposed; + + public ResponseStream( + global::System.Net.Http.HttpResponseMessage response, + global::System.IO.Stream stream) + { + _response = response ?? throw new global::System.ArgumentNullException(nameof(response)); + _stream = stream ?? throw new global::System.ArgumentNullException(nameof(stream)); + } + + public override bool CanRead => _stream.CanRead; + public override bool CanSeek => _stream.CanSeek; + public override bool CanWrite => _stream.CanWrite; + public override bool CanTimeout => _stream.CanTimeout; + public override long Length => _stream.Length; + + public override long Position + { + get => _stream.Position; + set => _stream.Position = value; + } + + public override int ReadTimeout + { + get => _stream.ReadTimeout; + set => _stream.ReadTimeout = value; + } + + public override int WriteTimeout + { + get => _stream.WriteTimeout; + set => _stream.WriteTimeout = value; + } + + public override void Flush() => _stream.Flush(); + + public override global::System.Threading.Tasks.Task FlushAsync( + global::System.Threading.CancellationToken cancellationToken) => + _stream.FlushAsync(cancellationToken); + + public override int Read(byte[] buffer, int offset, int count) => + _stream.Read(buffer, offset, count); + + public override global::System.Threading.Tasks.Task ReadAsync( + byte[] buffer, + int offset, + int count, + global::System.Threading.CancellationToken cancellationToken) => + _stream.ReadAsync(buffer, offset, count, cancellationToken); + +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_0_OR_GREATER || NET5_0_OR_GREATER + public override global::System.Threading.Tasks.ValueTask ReadAsync( + global::System.Memory buffer, + global::System.Threading.CancellationToken cancellationToken = default) => + _stream.ReadAsync(buffer, cancellationToken); +#endif + + public override long Seek(long offset, global::System.IO.SeekOrigin origin) => + _stream.Seek(offset, origin); + + public override void SetLength(long value) => + _stream.SetLength(value); + + public override void Write(byte[] buffer, int offset, int count) => + _stream.Write(buffer, offset, count); + + public override global::System.Threading.Tasks.Task WriteAsync( + byte[] buffer, + int offset, + int count, + global::System.Threading.CancellationToken cancellationToken) => + _stream.WriteAsync(buffer, offset, count, cancellationToken); + +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_0_OR_GREATER || NET5_0_OR_GREATER + public override global::System.Threading.Tasks.ValueTask WriteAsync( + global::System.ReadOnlyMemory buffer, + global::System.Threading.CancellationToken cancellationToken = default) => + _stream.WriteAsync(buffer, cancellationToken); +#endif + + protected override void Dispose(bool disposing) + { + if (!_disposed && disposing) + { + _disposed = true; + _stream.Dispose(); + _response.Dispose(); + } + + base.Dispose(disposing); + } + +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_0_OR_GREATER || NET5_0_OR_GREATER + public override async global::System.Threading.Tasks.ValueTask DisposeAsync() + { + if (_disposed) + { + return; + } + + _disposed = true; + await _stream.DisposeAsync().ConfigureAwait(false); + _response.Dispose(); + await base.DisposeAsync().ConfigureAwait(false); + } +#endif + } +} \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.RlClient.CreateInferenceCheckpoint.g.cs b/src/libs/Together/Generated/Together.RlClient.CreateInferenceCheckpoint.g.cs index 6f886670..da672b69 100644 --- a/src/libs/Together/Generated/Together.RlClient.CreateInferenceCheckpoint.g.cs +++ b/src/libs/Together/Generated/Together.RlClient.CreateInferenceCheckpoint.g.cs @@ -14,6 +14,7 @@ public partial class RlClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,10 +48,35 @@ partial void ProcessCreateInferenceCheckpointResponseContent( /// /// Training session ID /// + /// 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 CreateInferenceCheckpointAsync( string sessionId, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreateInferenceCheckpointAsResponseAsync( + sessionId: sessionId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Create inference checkpoint
+ /// Submits an operation that will asynchronously save the current LoRA adapter as an inference checkpoint and upload it to object storage. + ///
+ /// + /// Training session ID + /// + /// 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> CreateInferenceCheckpointAsResponseAsync( + string sessionId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -65,22 +91,44 @@ partial void ProcessCreateInferenceCheckpointResponseContent( securityRequirements: s_CreateInferenceCheckpointSecurityRequirements, operationName: "CreateInferenceCheckpointAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/rl/training-sessions/{sessionId}/operations/inference-checkpoint", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/rl/training-sessions/{sessionId}/operations/inference-checkpoint", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -90,150 +138,335 @@ partial void ProcessCreateInferenceCheckpointResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateInferenceCheckpointRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - sessionId: sessionId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateInferenceCheckpointRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + sessionId: sessionId!); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateInferenceCheckpointResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // An unexpected error response. - if (!__response.IsSuccessStatusCode) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_default = null; - global::System.Exception? __exception_default = null; - global::Together.ErrorData? __value_default = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateInferenceCheckpoint", + methodName: "CreateInferenceCheckpointAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/inference-checkpoint\"", + 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 { - __content_default = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_default = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateInferenceCheckpoint", + methodName: "CreateInferenceCheckpointAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/inference-checkpoint\"", + 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; + } - __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateInferenceCheckpoint", + methodName: "CreateInferenceCheckpointAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/inference-checkpoint\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_default = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_default ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_default, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_default, - ResponseObject = __value_default, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessCreateInferenceCheckpointResponseContent( + response: __response); + ProcessCreateInferenceCheckpointResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.RlInferenceCheckpointOperation.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateInferenceCheckpoint", + methodName: "CreateInferenceCheckpointAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/inference-checkpoint\"", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateInferenceCheckpoint", + methodName: "CreateInferenceCheckpointAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/inference-checkpoint\"", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // An unexpected error response. + if (!__response.IsSuccessStatusCode) + { + string? __content_default = null; + global::System.Exception? __exception_default = null; + global::Together.ErrorData? __value_default = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + } + else + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.RlInferenceCheckpointOperation.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_default = __ex; + } + + throw new global::Together.ApiException( + message: __content_default ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_default, + statusCode: __response.StatusCode) + { + ResponseBody = __content_default, + ResponseObject = __value_default, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessCreateInferenceCheckpointResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.RlInferenceCheckpointOperation.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.RlInferenceCheckpointOperation.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.RlClient.CreateTrainingCheckpoint.g.cs b/src/libs/Together/Generated/Together.RlClient.CreateTrainingCheckpoint.g.cs index ec4e5d1c..e85f0da9 100644 --- a/src/libs/Together/Generated/Together.RlClient.CreateTrainingCheckpoint.g.cs +++ b/src/libs/Together/Generated/Together.RlClient.CreateTrainingCheckpoint.g.cs @@ -14,6 +14,7 @@ public partial class RlClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,10 +48,35 @@ partial void ProcessCreateTrainingCheckpointResponseContent( /// /// Training session ID /// + /// 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 CreateTrainingCheckpointAsync( string sessionId, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreateTrainingCheckpointAsResponseAsync( + sessionId: sessionId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Save training checkpoint
+ /// Submits an operation that will asynchronously save the full training state (adapter + optimizer + step). + ///
+ /// + /// Training session ID + /// + /// 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> CreateTrainingCheckpointAsResponseAsync( + string sessionId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -65,22 +91,44 @@ partial void ProcessCreateTrainingCheckpointResponseContent( securityRequirements: s_CreateTrainingCheckpointSecurityRequirements, operationName: "CreateTrainingCheckpointAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/rl/training-sessions/{sessionId}/operations/training-checkpoint", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/rl/training-sessions/{sessionId}/operations/training-checkpoint", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -90,150 +138,335 @@ partial void ProcessCreateTrainingCheckpointResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateTrainingCheckpointRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - sessionId: sessionId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateTrainingCheckpointRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + sessionId: sessionId!); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateTrainingCheckpointResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // An unexpected error response. - if (!__response.IsSuccessStatusCode) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_default = null; - global::System.Exception? __exception_default = null; - global::Together.ErrorData? __value_default = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateTrainingCheckpoint", + methodName: "CreateTrainingCheckpointAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/training-checkpoint\"", + 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 { - __content_default = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_default = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateTrainingCheckpoint", + methodName: "CreateTrainingCheckpointAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/training-checkpoint\"", + 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; + } - __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateTrainingCheckpoint", + methodName: "CreateTrainingCheckpointAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/training-checkpoint\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_default = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_default ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_default, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_default, - ResponseObject = __value_default, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessCreateTrainingCheckpointResponseContent( + response: __response); + ProcessCreateTrainingCheckpointResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.RlTrainingCheckpointOperation.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateTrainingCheckpoint", + methodName: "CreateTrainingCheckpointAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/training-checkpoint\"", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateTrainingCheckpoint", + methodName: "CreateTrainingCheckpointAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/training-checkpoint\"", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // An unexpected error response. + if (!__response.IsSuccessStatusCode) + { + string? __content_default = null; + global::System.Exception? __exception_default = null; + global::Together.ErrorData? __value_default = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + } + else + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.RlTrainingCheckpointOperation.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_default = __ex; + } + + throw new global::Together.ApiException( + message: __content_default ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_default, + statusCode: __response.StatusCode) + { + ResponseBody = __content_default, + ResponseObject = __value_default, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessCreateTrainingCheckpointResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.RlTrainingCheckpointOperation.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.RlTrainingCheckpointOperation.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.RlClient.DownloadCheckpoint.g.cs b/src/libs/Together/Generated/Together.RlClient.DownloadCheckpoint.g.cs index bcd9488c..1acc8707 100644 --- a/src/libs/Together/Generated/Together.RlClient.DownloadCheckpoint.g.cs +++ b/src/libs/Together/Generated/Together.RlClient.DownloadCheckpoint.g.cs @@ -14,6 +14,7 @@ public partial class RlClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -53,11 +54,42 @@ partial void ProcessDownloadCheckpointResponseContent( /// Checkpoint variant to download: merged (full model) or adapter (LoRA weights only)
/// Default Value: CHECKPOINT_VARIANT_UNSPECIFIED /// + /// 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 DownloadCheckpointAsync( string id, global::Together.RlCheckpointVariant variant = global::Together.RlCheckpointVariant.CheckpointVariantUnspecified, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await DownloadCheckpointAsResponseAsync( + id: id, + variant: variant, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Download checkpoint
+ /// Returns presigned URLs for downloading a checkpoint's model files. Only inference checkpoints support downloading. + ///
+ /// + /// ID of the checkpoint + /// + /// + /// Checkpoint variant to download: merged (full model) or adapter (LoRA weights only)
+ /// Default Value: CHECKPOINT_VARIANT_UNSPECIFIED + /// + /// 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> DownloadCheckpointAsResponseAsync( + string id, + global::Together.RlCheckpointVariant variant = global::Together.RlCheckpointVariant.CheckpointVariantUnspecified, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -73,25 +105,47 @@ partial void ProcessDownloadCheckpointResponseContent( securityRequirements: s_DownloadCheckpointSecurityRequirements, operationName: "DownloadCheckpointAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/rl/checkpoints/{id}/download", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddRequiredParameter("variant", variant.ToValueString()) - ; - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/rl/checkpoints/{id}/download", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddRequiredParameter("variant", variant.ToValueString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -101,151 +155,336 @@ partial void ProcessDownloadCheckpointResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDownloadCheckpointRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - variant: variant); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDownloadCheckpointRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id!, + variant: variant!); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDownloadCheckpointResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // An unexpected error response. - if (!__response.IsSuccessStatusCode) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_default = null; - global::System.Exception? __exception_default = null; - global::Together.ErrorData? __value_default = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DownloadCheckpoint", + methodName: "DownloadCheckpointAsync", + pathTemplate: "$\"/rl/checkpoints/{id}/download\"", + httpMethod: "GET", + 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 { - __content_default = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_default = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DownloadCheckpoint", + methodName: "DownloadCheckpointAsync", + pathTemplate: "$\"/rl/checkpoints/{id}/download\"", + httpMethod: "GET", + 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; + } - __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DownloadCheckpoint", + methodName: "DownloadCheckpointAsync", + pathTemplate: "$\"/rl/checkpoints/{id}/download\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_default = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_default ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_default, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_default, - ResponseObject = __value_default, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessDownloadCheckpointResponseContent( + response: __response); + ProcessDownloadCheckpointResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.RlCheckpointDownloadResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DownloadCheckpoint", + methodName: "DownloadCheckpointAsync", + pathTemplate: "$\"/rl/checkpoints/{id}/download\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DownloadCheckpoint", + methodName: "DownloadCheckpointAsync", + pathTemplate: "$\"/rl/checkpoints/{id}/download\"", + httpMethod: "GET", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // An unexpected error response. + if (!__response.IsSuccessStatusCode) + { + string? __content_default = null; + global::System.Exception? __exception_default = null; + global::Together.ErrorData? __value_default = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + } + else + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.RlCheckpointDownloadResponse.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_default = __ex; + } + + throw new global::Together.ApiException( + message: __content_default ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_default, + statusCode: __response.StatusCode) + { + ResponseBody = __content_default, + ResponseObject = __value_default, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessDownloadCheckpointResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.RlCheckpointDownloadResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.RlCheckpointDownloadResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.RlClient.ForwardBackward.g.cs b/src/libs/Together/Generated/Together.RlClient.ForwardBackward.g.cs index f5fa9aba..21e4cd6b 100644 --- a/src/libs/Together/Generated/Together.RlClient.ForwardBackward.g.cs +++ b/src/libs/Together/Generated/Together.RlClient.ForwardBackward.g.cs @@ -14,6 +14,7 @@ public partial class RlClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -50,12 +51,42 @@ partial void ProcessForwardBackwardResponseContent( /// Training session ID /// /// + /// 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 ForwardBackwardAsync( string sessionId, global::Together.RlForwardBackwardBody request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await ForwardBackwardAsResponseAsync( + sessionId: sessionId, + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Forward-backward pass
+ /// Submits a forward-backward pass operation that will asynchronously compute gradients via backpropagation. + ///
+ /// + /// Training session ID + /// + /// + /// 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> ForwardBackwardAsResponseAsync( + string sessionId, + + global::Together.RlForwardBackwardBody request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -73,22 +104,44 @@ partial void ProcessForwardBackwardResponseContent( securityRequirements: s_ForwardBackwardSecurityRequirements, operationName: "ForwardBackwardAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/rl/training-sessions/{sessionId}/operations/forward-backward", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/rl/training-sessions/{sessionId}/operations/forward-backward", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -98,157 +151,342 @@ partial void ProcessForwardBackwardResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareForwardBackwardRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - sessionId: sessionId, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareForwardBackwardRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + sessionId: sessionId!, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessForwardBackwardResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // An unexpected error response. - if (!__response.IsSuccessStatusCode) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_default = null; - global::System.Exception? __exception_default = null; - global::Together.ErrorData? __value_default = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ForwardBackward", + methodName: "ForwardBackwardAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/forward-backward\"", + 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 { - __content_default = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_default = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ForwardBackward", + methodName: "ForwardBackwardAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/forward-backward\"", + 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; + } - __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ForwardBackward", + methodName: "ForwardBackwardAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/forward-backward\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_default = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_default ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_default, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_default, - ResponseObject = __value_default, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessForwardBackwardResponseContent( + response: __response); + ProcessForwardBackwardResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.RlForwardBackwardOperation.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ForwardBackward", + methodName: "ForwardBackwardAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/forward-backward\"", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ForwardBackward", + methodName: "ForwardBackwardAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/forward-backward\"", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // An unexpected error response. + if (!__response.IsSuccessStatusCode) + { + string? __content_default = null; + global::System.Exception? __exception_default = null; + global::Together.ErrorData? __value_default = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + } + else + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.RlForwardBackwardOperation.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_default = __ex; + } + + throw new global::Together.ApiException( + message: __content_default ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_default, + statusCode: __response.StatusCode) + { + ResponseBody = __content_default, + ResponseObject = __value_default, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessForwardBackwardResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.RlForwardBackwardOperation.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.RlForwardBackwardOperation.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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(); + } } /// /// Forward-backward pass
@@ -263,12 +501,14 @@ partial void ProcessForwardBackwardResponseContent( /// /// Loss function configuration /// + /// 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 ForwardBackwardAsync( string sessionId, global::System.Collections.Generic.IList samples, global::Together.RlLossConfig loss, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.RlForwardBackwardBody @@ -280,6 +520,7 @@ partial void ProcessForwardBackwardResponseContent( return await ForwardBackwardAsync( sessionId: sessionId, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Together/Generated/Together.RlClient.GetForwardBackwardOperation.g.cs b/src/libs/Together/Generated/Together.RlClient.GetForwardBackwardOperation.g.cs index c6ffec66..77721454 100644 --- a/src/libs/Together/Generated/Together.RlClient.GetForwardBackwardOperation.g.cs +++ b/src/libs/Together/Generated/Together.RlClient.GetForwardBackwardOperation.g.cs @@ -14,6 +14,7 @@ public partial class RlClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -52,11 +53,41 @@ partial void ProcessGetForwardBackwardOperationResponseContent( /// /// Operation ID /// + /// 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 GetForwardBackwardOperationAsync( string sessionId, string operationId, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetForwardBackwardOperationAsResponseAsync( + sessionId: sessionId, + operationId: operationId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get forward-backward operation
+ /// Retrieves the current status and result of a forward-backward operation. + ///
+ /// + /// Training session ID + /// + /// + /// Operation ID + /// + /// 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> GetForwardBackwardOperationAsResponseAsync( + string sessionId, + string operationId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -72,22 +103,44 @@ partial void ProcessGetForwardBackwardOperationResponseContent( securityRequirements: s_GetForwardBackwardOperationSecurityRequirements, operationName: "GetForwardBackwardOperationAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/rl/training-sessions/{sessionId}/operations/forward-backward/{operationId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/rl/training-sessions/{sessionId}/operations/forward-backward/{operationId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -97,151 +150,336 @@ partial void ProcessGetForwardBackwardOperationResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetForwardBackwardOperationRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - sessionId: sessionId, - operationId: operationId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetForwardBackwardOperationRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + sessionId: sessionId!, + operationId: operationId!); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetForwardBackwardOperationResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // An unexpected error response. - if (!__response.IsSuccessStatusCode) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_default = null; - global::System.Exception? __exception_default = null; - global::Together.ErrorData? __value_default = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetForwardBackwardOperation", + methodName: "GetForwardBackwardOperationAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/forward-backward/{operationId}\"", + httpMethod: "GET", + 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 { - __content_default = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_default = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetForwardBackwardOperation", + methodName: "GetForwardBackwardOperationAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/forward-backward/{operationId}\"", + httpMethod: "GET", + 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; + } - __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetForwardBackwardOperation", + methodName: "GetForwardBackwardOperationAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/forward-backward/{operationId}\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_default = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_default ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_default, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_default, - ResponseObject = __value_default, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessGetForwardBackwardOperationResponseContent( + response: __response); + ProcessGetForwardBackwardOperationResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.RlForwardBackwardOperation.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetForwardBackwardOperation", + methodName: "GetForwardBackwardOperationAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/forward-backward/{operationId}\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetForwardBackwardOperation", + methodName: "GetForwardBackwardOperationAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/forward-backward/{operationId}\"", + httpMethod: "GET", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // An unexpected error response. + if (!__response.IsSuccessStatusCode) + { + string? __content_default = null; + global::System.Exception? __exception_default = null; + global::Together.ErrorData? __value_default = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + } + else + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.RlForwardBackwardOperation.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_default = __ex; + } + + throw new global::Together.ApiException( + message: __content_default ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_default, + statusCode: __response.StatusCode) + { + ResponseBody = __content_default, + ResponseObject = __value_default, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessGetForwardBackwardOperationResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.RlForwardBackwardOperation.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.RlForwardBackwardOperation.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.RlClient.GetInferenceCheckpointOperation.g.cs b/src/libs/Together/Generated/Together.RlClient.GetInferenceCheckpointOperation.g.cs index ffd4d5b1..bf96a287 100644 --- a/src/libs/Together/Generated/Together.RlClient.GetInferenceCheckpointOperation.g.cs +++ b/src/libs/Together/Generated/Together.RlClient.GetInferenceCheckpointOperation.g.cs @@ -14,6 +14,7 @@ public partial class RlClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -52,11 +53,41 @@ partial void ProcessGetInferenceCheckpointOperationResponseContent( /// /// Operation ID /// + /// 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 GetInferenceCheckpointOperationAsync( string sessionId, string operationId, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetInferenceCheckpointOperationAsResponseAsync( + sessionId: sessionId, + operationId: operationId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get inference checkpoint operation
+ /// Retrieves the current status and result of an inference checkpoint operation. + ///
+ /// + /// Training session ID + /// + /// + /// Operation ID + /// + /// 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> GetInferenceCheckpointOperationAsResponseAsync( + string sessionId, + string operationId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -72,22 +103,44 @@ partial void ProcessGetInferenceCheckpointOperationResponseContent( securityRequirements: s_GetInferenceCheckpointOperationSecurityRequirements, operationName: "GetInferenceCheckpointOperationAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/rl/training-sessions/{sessionId}/operations/inference-checkpoint/{operationId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/rl/training-sessions/{sessionId}/operations/inference-checkpoint/{operationId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -97,151 +150,336 @@ partial void ProcessGetInferenceCheckpointOperationResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetInferenceCheckpointOperationRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - sessionId: sessionId, - operationId: operationId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetInferenceCheckpointOperationRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + sessionId: sessionId!, + operationId: operationId!); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetInferenceCheckpointOperationResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // An unexpected error response. - if (!__response.IsSuccessStatusCode) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_default = null; - global::System.Exception? __exception_default = null; - global::Together.ErrorData? __value_default = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetInferenceCheckpointOperation", + methodName: "GetInferenceCheckpointOperationAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/inference-checkpoint/{operationId}\"", + httpMethod: "GET", + 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 { - __content_default = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_default = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetInferenceCheckpointOperation", + methodName: "GetInferenceCheckpointOperationAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/inference-checkpoint/{operationId}\"", + httpMethod: "GET", + 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; + } - __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetInferenceCheckpointOperation", + methodName: "GetInferenceCheckpointOperationAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/inference-checkpoint/{operationId}\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_default = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_default ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_default, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_default, - ResponseObject = __value_default, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessGetInferenceCheckpointOperationResponseContent( + response: __response); + ProcessGetInferenceCheckpointOperationResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.RlInferenceCheckpointOperation.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetInferenceCheckpointOperation", + methodName: "GetInferenceCheckpointOperationAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/inference-checkpoint/{operationId}\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetInferenceCheckpointOperation", + methodName: "GetInferenceCheckpointOperationAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/inference-checkpoint/{operationId}\"", + httpMethod: "GET", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // An unexpected error response. + if (!__response.IsSuccessStatusCode) + { + string? __content_default = null; + global::System.Exception? __exception_default = null; + global::Together.ErrorData? __value_default = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + } + else + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.RlInferenceCheckpointOperation.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_default = __ex; + } + + throw new global::Together.ApiException( + message: __content_default ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_default, + statusCode: __response.StatusCode) + { + ResponseBody = __content_default, + ResponseObject = __value_default, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessGetInferenceCheckpointOperationResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.RlInferenceCheckpointOperation.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.RlInferenceCheckpointOperation.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.RlClient.GetOptimStepOperation.g.cs b/src/libs/Together/Generated/Together.RlClient.GetOptimStepOperation.g.cs index c64e2151..4c119130 100644 --- a/src/libs/Together/Generated/Together.RlClient.GetOptimStepOperation.g.cs +++ b/src/libs/Together/Generated/Together.RlClient.GetOptimStepOperation.g.cs @@ -14,6 +14,7 @@ public partial class RlClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -52,11 +53,41 @@ partial void ProcessGetOptimStepOperationResponseContent( /// /// Operation ID /// + /// 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 GetOptimStepOperationAsync( string sessionId, string operationId, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetOptimStepOperationAsResponseAsync( + sessionId: sessionId, + operationId: operationId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get optim-step operation
+ /// Retrieves the current status and result of an optim-step operation. + ///
+ /// + /// Training session ID + /// + /// + /// Operation ID + /// + /// 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> GetOptimStepOperationAsResponseAsync( + string sessionId, + string operationId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -72,22 +103,44 @@ partial void ProcessGetOptimStepOperationResponseContent( securityRequirements: s_GetOptimStepOperationSecurityRequirements, operationName: "GetOptimStepOperationAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/rl/training-sessions/{sessionId}/operations/optim-step/{operationId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/rl/training-sessions/{sessionId}/operations/optim-step/{operationId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -97,151 +150,336 @@ partial void ProcessGetOptimStepOperationResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetOptimStepOperationRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - sessionId: sessionId, - operationId: operationId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetOptimStepOperationRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + sessionId: sessionId!, + operationId: operationId!); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetOptimStepOperationResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // An unexpected error response. - if (!__response.IsSuccessStatusCode) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_default = null; - global::System.Exception? __exception_default = null; - global::Together.ErrorData? __value_default = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetOptimStepOperation", + methodName: "GetOptimStepOperationAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/optim-step/{operationId}\"", + httpMethod: "GET", + 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 { - __content_default = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_default = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetOptimStepOperation", + methodName: "GetOptimStepOperationAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/optim-step/{operationId}\"", + httpMethod: "GET", + 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; + } - __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetOptimStepOperation", + methodName: "GetOptimStepOperationAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/optim-step/{operationId}\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_default = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_default ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_default, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_default, - ResponseObject = __value_default, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessGetOptimStepOperationResponseContent( + response: __response); + ProcessGetOptimStepOperationResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.RlOptimStepOperation.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetOptimStepOperation", + methodName: "GetOptimStepOperationAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/optim-step/{operationId}\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetOptimStepOperation", + methodName: "GetOptimStepOperationAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/optim-step/{operationId}\"", + httpMethod: "GET", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // An unexpected error response. + if (!__response.IsSuccessStatusCode) + { + string? __content_default = null; + global::System.Exception? __exception_default = null; + global::Together.ErrorData? __value_default = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + } + else + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.RlOptimStepOperation.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_default = __ex; + } + + throw new global::Together.ApiException( + message: __content_default ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_default, + statusCode: __response.StatusCode) + { + ResponseBody = __content_default, + ResponseObject = __value_default, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessGetOptimStepOperationResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.RlOptimStepOperation.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.RlOptimStepOperation.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.RlClient.GetSample.g.cs b/src/libs/Together/Generated/Together.RlClient.GetSample.g.cs index 7c4630ce..f6572813 100644 --- a/src/libs/Together/Generated/Together.RlClient.GetSample.g.cs +++ b/src/libs/Together/Generated/Together.RlClient.GetSample.g.cs @@ -14,6 +14,7 @@ public partial class RlClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -52,11 +53,41 @@ partial void ProcessGetSampleResponseContent( /// /// Operation ID /// + /// 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 GetSampleAsync( string sessionId, string operationId, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetSampleAsResponseAsync( + sessionId: sessionId, + operationId: operationId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get sample operation
+ /// Retrieves the current status and result of a sample operation. + ///
+ /// + /// Training session ID + /// + /// + /// Operation ID + /// + /// 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> GetSampleAsResponseAsync( + string sessionId, + string operationId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -72,22 +103,44 @@ partial void ProcessGetSampleResponseContent( securityRequirements: s_GetSampleSecurityRequirements, operationName: "GetSampleAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/rl/training-sessions/{sessionId}/operations/sample/{operationId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/rl/training-sessions/{sessionId}/operations/sample/{operationId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -97,151 +150,336 @@ partial void ProcessGetSampleResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetSampleRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - sessionId: sessionId, - operationId: operationId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetSampleRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + sessionId: sessionId!, + operationId: operationId!); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetSampleResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // An unexpected error response. - if (!__response.IsSuccessStatusCode) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_default = null; - global::System.Exception? __exception_default = null; - global::Together.ErrorData? __value_default = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetSample", + methodName: "GetSampleAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/sample/{operationId}\"", + httpMethod: "GET", + 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 { - __content_default = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_default = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetSample", + methodName: "GetSampleAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/sample/{operationId}\"", + httpMethod: "GET", + 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; + } - __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetSample", + methodName: "GetSampleAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/sample/{operationId}\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_default = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_default ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_default, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_default, - ResponseObject = __value_default, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessGetSampleResponseContent( + response: __response); + ProcessGetSampleResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.RlSampleOperation.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetSample", + methodName: "GetSampleAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/sample/{operationId}\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetSample", + methodName: "GetSampleAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/sample/{operationId}\"", + httpMethod: "GET", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // An unexpected error response. + if (!__response.IsSuccessStatusCode) + { + string? __content_default = null; + global::System.Exception? __exception_default = null; + global::Together.ErrorData? __value_default = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + } + else + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.RlSampleOperation.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_default = __ex; + } + + throw new global::Together.ApiException( + message: __content_default ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_default, + statusCode: __response.StatusCode) + { + ResponseBody = __content_default, + ResponseObject = __value_default, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessGetSampleResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.RlSampleOperation.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.RlSampleOperation.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.RlClient.GetTrainingCheckpointOperation.g.cs b/src/libs/Together/Generated/Together.RlClient.GetTrainingCheckpointOperation.g.cs index 0d116f62..c3809df8 100644 --- a/src/libs/Together/Generated/Together.RlClient.GetTrainingCheckpointOperation.g.cs +++ b/src/libs/Together/Generated/Together.RlClient.GetTrainingCheckpointOperation.g.cs @@ -14,6 +14,7 @@ public partial class RlClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -52,11 +53,41 @@ partial void ProcessGetTrainingCheckpointOperationResponseContent( /// /// Operation ID /// + /// 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 GetTrainingCheckpointOperationAsync( string sessionId, string operationId, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetTrainingCheckpointOperationAsResponseAsync( + sessionId: sessionId, + operationId: operationId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get save training checkpoint operation
+ /// Retrieves the current status and result of a save training checkpoint operation. + ///
+ /// + /// Training session ID + /// + /// + /// Operation ID + /// + /// 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> GetTrainingCheckpointOperationAsResponseAsync( + string sessionId, + string operationId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -72,22 +103,44 @@ partial void ProcessGetTrainingCheckpointOperationResponseContent( securityRequirements: s_GetTrainingCheckpointOperationSecurityRequirements, operationName: "GetTrainingCheckpointOperationAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/rl/training-sessions/{sessionId}/operations/training-checkpoint/{operationId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/rl/training-sessions/{sessionId}/operations/training-checkpoint/{operationId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -97,151 +150,336 @@ partial void ProcessGetTrainingCheckpointOperationResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetTrainingCheckpointOperationRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - sessionId: sessionId, - operationId: operationId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetTrainingCheckpointOperationRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + sessionId: sessionId!, + operationId: operationId!); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetTrainingCheckpointOperationResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // An unexpected error response. - if (!__response.IsSuccessStatusCode) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_default = null; - global::System.Exception? __exception_default = null; - global::Together.ErrorData? __value_default = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetTrainingCheckpointOperation", + methodName: "GetTrainingCheckpointOperationAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/training-checkpoint/{operationId}\"", + httpMethod: "GET", + 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 { - __content_default = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_default = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetTrainingCheckpointOperation", + methodName: "GetTrainingCheckpointOperationAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/training-checkpoint/{operationId}\"", + httpMethod: "GET", + 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; + } - __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetTrainingCheckpointOperation", + methodName: "GetTrainingCheckpointOperationAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/training-checkpoint/{operationId}\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_default = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_default ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_default, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_default, - ResponseObject = __value_default, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessGetTrainingCheckpointOperationResponseContent( + response: __response); + ProcessGetTrainingCheckpointOperationResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.RlTrainingCheckpointOperation.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetTrainingCheckpointOperation", + methodName: "GetTrainingCheckpointOperationAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/training-checkpoint/{operationId}\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetTrainingCheckpointOperation", + methodName: "GetTrainingCheckpointOperationAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/training-checkpoint/{operationId}\"", + httpMethod: "GET", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // An unexpected error response. + if (!__response.IsSuccessStatusCode) + { + string? __content_default = null; + global::System.Exception? __exception_default = null; + global::Together.ErrorData? __value_default = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + } + else + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.RlTrainingCheckpointOperation.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_default = __ex; + } + + throw new global::Together.ApiException( + message: __content_default ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_default, + statusCode: __response.StatusCode) + { + ResponseBody = __content_default, + ResponseObject = __value_default, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessGetTrainingCheckpointOperationResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.RlTrainingCheckpointOperation.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.RlTrainingCheckpointOperation.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.RlClient.GetTrainingSession.g.cs b/src/libs/Together/Generated/Together.RlClient.GetTrainingSession.g.cs index 2037288f..2638820e 100644 --- a/src/libs/Together/Generated/Together.RlClient.GetTrainingSession.g.cs +++ b/src/libs/Together/Generated/Together.RlClient.GetTrainingSession.g.cs @@ -14,6 +14,7 @@ public partial class RlClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,10 +48,35 @@ partial void ProcessGetTrainingSessionResponseContent( /// /// ID of the training session /// + /// 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 GetTrainingSessionAsync( string sessionId, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetTrainingSessionAsResponseAsync( + sessionId: sessionId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get training session
+ /// Gets a training session by its ID and returns its details. + ///
+ /// + /// ID of the training session + /// + /// 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> GetTrainingSessionAsResponseAsync( + string sessionId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -65,22 +91,44 @@ partial void ProcessGetTrainingSessionResponseContent( securityRequirements: s_GetTrainingSessionSecurityRequirements, operationName: "GetTrainingSessionAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/rl/training-sessions/{sessionId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/rl/training-sessions/{sessionId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -90,150 +138,335 @@ partial void ProcessGetTrainingSessionResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetTrainingSessionRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - sessionId: sessionId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetTrainingSessionRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + sessionId: sessionId!); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetTrainingSessionResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // An unexpected error response. - if (!__response.IsSuccessStatusCode) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_default = null; - global::System.Exception? __exception_default = null; - global::Together.ErrorData? __value_default = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetTrainingSession", + methodName: "GetTrainingSessionAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}\"", + httpMethod: "GET", + 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 { - __content_default = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_default = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetTrainingSession", + methodName: "GetTrainingSessionAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}\"", + httpMethod: "GET", + 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; + } - __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetTrainingSession", + methodName: "GetTrainingSessionAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_default = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_default ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_default, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_default, - ResponseObject = __value_default, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessGetTrainingSessionResponseContent( + response: __response); + ProcessGetTrainingSessionResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.RlTrainingSession.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetTrainingSession", + methodName: "GetTrainingSessionAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetTrainingSession", + methodName: "GetTrainingSessionAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}\"", + httpMethod: "GET", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // An unexpected error response. + if (!__response.IsSuccessStatusCode) + { + string? __content_default = null; + global::System.Exception? __exception_default = null; + global::Together.ErrorData? __value_default = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + } + else + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.RlTrainingSession.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_default = __ex; + } + + throw new global::Together.ApiException( + message: __content_default ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_default, + statusCode: __response.StatusCode) + { + ResponseBody = __content_default, + ResponseObject = __value_default, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessGetTrainingSessionResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.RlTrainingSession.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.RlTrainingSession.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.RlClient.ListTrainingSessions.g.cs b/src/libs/Together/Generated/Together.RlClient.ListTrainingSessions.g.cs index 634782fc..df86cb24 100644 --- a/src/libs/Together/Generated/Together.RlClient.ListTrainingSessions.g.cs +++ b/src/libs/Together/Generated/Together.RlClient.ListTrainingSessions.g.cs @@ -14,6 +14,7 @@ public partial class RlClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -59,12 +60,49 @@ partial void ProcessListTrainingSessionsResponseContent( /// /// Cursor for pagination (ID of the last session from the previous page) /// + /// 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 ListTrainingSessionsAsync( global::Together.RlTrainingSessionStatus? status = default, int? limit = default, string? after = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await ListTrainingSessionsAsResponseAsync( + status: status, + limit: limit, + after: after, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// List training sessions
+ /// Lists all training sessions. + ///
+ /// + /// Status of the training sessions to list
+ /// Default Value: TRAINING_SESSION_STATUS_UNSPECIFIED + /// + /// + /// Maximum number of sessions to return (1-100)
+ /// Default Value: 20 + /// + /// + /// Cursor for pagination (ID of the last session from the previous page) + /// + /// 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> ListTrainingSessionsAsResponseAsync( + global::Together.RlTrainingSessionStatus? status = default, + int? limit = default, + string? after = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -81,27 +119,49 @@ partial void ProcessListTrainingSessionsResponseContent( securityRequirements: s_ListTrainingSessionsSecurityRequirements, operationName: "ListTrainingSessionsAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/rl/training-sessions", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("status", status?.ToValueString()) - .AddOptionalParameter("limit", limit?.ToString()) - .AddOptionalParameter("after", after) - ; - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/rl/training-sessions", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("status", status?.ToValueString()) + .AddOptionalParameter("limit", limit?.ToString()) + .AddOptionalParameter("after", after) + ; + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -111,152 +171,337 @@ partial void ProcessListTrainingSessionsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListTrainingSessionsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - status: status, - limit: limit, - after: after); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListTrainingSessionsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + status: status, + limit: limit, + after: after); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListTrainingSessionsResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // An unexpected error response. - if (!__response.IsSuccessStatusCode) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_default = null; - global::System.Exception? __exception_default = null; - global::Together.ErrorData? __value_default = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListTrainingSessions", + methodName: "ListTrainingSessionsAsync", + pathTemplate: "\"/rl/training-sessions\"", + httpMethod: "GET", + 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 { - __content_default = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_default = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListTrainingSessions", + methodName: "ListTrainingSessionsAsync", + pathTemplate: "\"/rl/training-sessions\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListTrainingSessions", + methodName: "ListTrainingSessionsAsync", + pathTemplate: "\"/rl/training-sessions\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_default = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_default ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_default, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_default, - ResponseObject = __value_default, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessListTrainingSessionsResponseContent( + response: __response); + ProcessListTrainingSessionsResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.RlTrainingSessionsListResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListTrainingSessions", + methodName: "ListTrainingSessionsAsync", + pathTemplate: "\"/rl/training-sessions\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListTrainingSessions", + methodName: "ListTrainingSessionsAsync", + pathTemplate: "\"/rl/training-sessions\"", + httpMethod: "GET", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // An unexpected error response. + if (!__response.IsSuccessStatusCode) + { + string? __content_default = null; + global::System.Exception? __exception_default = null; + global::Together.ErrorData? __value_default = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + } + else + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.RlTrainingSessionsListResponse.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_default = __ex; + } + + throw new global::Together.ApiException( + message: __content_default ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_default, + statusCode: __response.StatusCode) + { + ResponseBody = __content_default, + ResponseObject = __value_default, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessListTrainingSessionsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.RlTrainingSessionsListResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.RlTrainingSessionsListResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.RlClient.OptimStep.g.cs b/src/libs/Together/Generated/Together.RlClient.OptimStep.g.cs index ab1d888e..7db2cb3d 100644 --- a/src/libs/Together/Generated/Together.RlClient.OptimStep.g.cs +++ b/src/libs/Together/Generated/Together.RlClient.OptimStep.g.cs @@ -14,6 +14,7 @@ public partial class RlClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -50,12 +51,42 @@ partial void ProcessOptimStepResponseContent( /// Training session ID /// /// + /// 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 OptimStepAsync( string sessionId, global::Together.RlOptimStepBody request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await OptimStepAsResponseAsync( + sessionId: sessionId, + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Optimizer step
+ /// Submits an optimizer step operation that will asynchronously apply accumulated gradients to update model parameters. + ///
+ /// + /// Training session ID + /// + /// + /// 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> OptimStepAsResponseAsync( + string sessionId, + + global::Together.RlOptimStepBody request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -73,22 +104,44 @@ partial void ProcessOptimStepResponseContent( securityRequirements: s_OptimStepSecurityRequirements, operationName: "OptimStepAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/rl/training-sessions/{sessionId}/operations/optim-step", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/rl/training-sessions/{sessionId}/operations/optim-step", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -98,157 +151,342 @@ partial void ProcessOptimStepResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareOptimStepRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - sessionId: sessionId, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareOptimStepRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + sessionId: sessionId!, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessOptimStepResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // An unexpected error response. - if (!__response.IsSuccessStatusCode) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_default = null; - global::System.Exception? __exception_default = null; - global::Together.ErrorData? __value_default = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "OptimStep", + methodName: "OptimStepAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/optim-step\"", + 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 { - __content_default = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_default = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "OptimStep", + methodName: "OptimStepAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/optim-step\"", + 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; + } - __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "OptimStep", + methodName: "OptimStepAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/optim-step\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_default = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_default ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_default, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_default, - ResponseObject = __value_default, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessOptimStepResponseContent( + response: __response); + ProcessOptimStepResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.RlOptimStepOperation.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "OptimStep", + methodName: "OptimStepAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/optim-step\"", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "OptimStep", + methodName: "OptimStepAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/optim-step\"", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // An unexpected error response. + if (!__response.IsSuccessStatusCode) + { + string? __content_default = null; + global::System.Exception? __exception_default = null; + global::Together.ErrorData? __value_default = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + } + else + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.RlOptimStepOperation.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_default = __ex; + } + + throw new global::Together.ApiException( + message: __content_default ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_default, + statusCode: __response.StatusCode) + { + ResponseBody = __content_default, + ResponseObject = __value_default, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessOptimStepResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.RlOptimStepOperation.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.RlOptimStepOperation.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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(); + } } /// /// Optimizer step
@@ -265,12 +503,14 @@ partial void ProcessOptimStepResponseContent( /// /// AdamW optimizer parameters /// + /// 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 OptimStepAsync( string sessionId, float? learningRate = default, global::Together.RlAdamWOptimizerParams? adamwParams = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.RlOptimStepBody @@ -282,6 +522,7 @@ partial void ProcessOptimStepResponseContent( return await OptimStepAsync( sessionId: sessionId, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Together/Generated/Together.RlClient.Sample.g.cs b/src/libs/Together/Generated/Together.RlClient.Sample.g.cs index 84e43e0b..11acf2da 100644 --- a/src/libs/Together/Generated/Together.RlClient.Sample.g.cs +++ b/src/libs/Together/Generated/Together.RlClient.Sample.g.cs @@ -14,6 +14,7 @@ public partial class RlClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -50,12 +51,42 @@ partial void ProcessSampleResponseContent( /// Training session ID /// /// + /// 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 SampleAsync( string sessionId, global::Together.RlSampleBody request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await SampleAsResponseAsync( + sessionId: sessionId, + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Sample
+ /// Submits a sample operation that will asynchronously generate text completions with logprobs. + ///
+ /// + /// Training session ID + /// + /// + /// 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> SampleAsResponseAsync( + string sessionId, + + global::Together.RlSampleBody request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -73,22 +104,44 @@ partial void ProcessSampleResponseContent( securityRequirements: s_SampleSecurityRequirements, operationName: "SampleAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/rl/training-sessions/{sessionId}/operations/sample", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/rl/training-sessions/{sessionId}/operations/sample", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -98,157 +151,342 @@ partial void ProcessSampleResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSampleRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - sessionId: sessionId, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareSampleRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + sessionId: sessionId!, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessSampleResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // An unexpected error response. - if (!__response.IsSuccessStatusCode) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_default = null; - global::System.Exception? __exception_default = null; - global::Together.ErrorData? __value_default = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sample", + methodName: "SampleAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/sample\"", + 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 { - __content_default = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_default = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sample", + methodName: "SampleAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/sample\"", + 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; + } - __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sample", + methodName: "SampleAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/sample\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_default = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_default ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_default, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_default, - ResponseObject = __value_default, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessSampleResponseContent( + response: __response); + ProcessSampleResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.RlSampleOperation.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sample", + methodName: "SampleAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/sample\"", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Sample", + methodName: "SampleAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/operations/sample\"", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // An unexpected error response. + if (!__response.IsSuccessStatusCode) + { + string? __content_default = null; + global::System.Exception? __exception_default = null; + global::Together.ErrorData? __value_default = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + } + else + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.RlSampleOperation.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_default = __ex; + } + + throw new global::Together.ApiException( + message: __content_default ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_default, + statusCode: __response.StatusCode) + { + ResponseBody = __content_default, + ResponseObject = __value_default, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessSampleResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.RlSampleOperation.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.RlSampleOperation.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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(); + } } /// /// Sample
@@ -268,6 +506,7 @@ partial void ProcessSampleResponseContent( /// Default Value: 1
/// Example: 1 /// + /// 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 SampleAsync( @@ -275,6 +514,7 @@ partial void ProcessSampleResponseContent( global::System.Collections.Generic.IList prompts, global::Together.RlSamplingParams? samplingParams = default, long? numSamples = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.RlSampleBody @@ -287,6 +527,7 @@ partial void ProcessSampleResponseContent( return await SampleAsync( sessionId: sessionId, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Together/Generated/Together.RlClient.StartTrainingSession.g.cs b/src/libs/Together/Generated/Together.RlClient.StartTrainingSession.g.cs index ed04dd89..f15b5164 100644 --- a/src/libs/Together/Generated/Together.RlClient.StartTrainingSession.g.cs +++ b/src/libs/Together/Generated/Together.RlClient.StartTrainingSession.g.cs @@ -14,6 +14,7 @@ public partial class RlClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,36 @@ partial void ProcessStartTrainingSessionResponseContent( /// Creates a training session and returns its details. ///
/// + /// 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 StartTrainingSessionAsync( global::Together.RlStartTrainingSessionRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await StartTrainingSessionAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Create training session
+ /// Creates a training session and returns its details. + ///
+ /// + /// 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> StartTrainingSessionAsResponseAsync( + + global::Together.RlStartTrainingSessionRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +92,44 @@ partial void ProcessStartTrainingSessionResponseContent( securityRequirements: s_StartTrainingSessionSecurityRequirements, operationName: "StartTrainingSessionAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/rl/training-sessions", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/rl/training-sessions", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -91,156 +139,341 @@ partial void ProcessStartTrainingSessionResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareStartTrainingSessionRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareStartTrainingSessionRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessStartTrainingSessionResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // An unexpected error response. - if (!__response.IsSuccessStatusCode) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_default = null; - global::System.Exception? __exception_default = null; - global::Together.ErrorData? __value_default = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "StartTrainingSession", + methodName: "StartTrainingSessionAsync", + pathTemplate: "\"/rl/training-sessions\"", + 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 { - __content_default = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_default = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "StartTrainingSession", + methodName: "StartTrainingSessionAsync", + pathTemplate: "\"/rl/training-sessions\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "StartTrainingSession", + methodName: "StartTrainingSessionAsync", + pathTemplate: "\"/rl/training-sessions\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_default = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_default ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_default, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_default, - ResponseObject = __value_default, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessStartTrainingSessionResponseContent( + response: __response); + ProcessStartTrainingSessionResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.RlTrainingSession.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "StartTrainingSession", + methodName: "StartTrainingSessionAsync", + pathTemplate: "\"/rl/training-sessions\"", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "StartTrainingSession", + methodName: "StartTrainingSessionAsync", + pathTemplate: "\"/rl/training-sessions\"", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // An unexpected error response. + if (!__response.IsSuccessStatusCode) + { + string? __content_default = null; + global::System.Exception? __exception_default = null; + global::Together.ErrorData? __value_default = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + } + else + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.RlTrainingSession.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_default = __ex; + } + + throw new global::Together.ApiException( + message: __content_default ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_default, + statusCode: __response.StatusCode) + { + ResponseBody = __content_default, + ResponseObject = __value_default, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessStartTrainingSessionResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.RlTrainingSession.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.RlTrainingSession.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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 training session
@@ -254,26 +487,35 @@ partial void ProcessStartTrainingSessionResponseContent( /// Checkpoint ID to resume from
/// Example: 123e4567-e89b-12d3-a456-426614174000 /// + /// + /// Type of the training session. Defaults to TRAINER_AND_GENERATOR when unspecified. TRAINER_ONLY provisions only the trainer and rejects sample requests.
+ /// Default Value: SESSION_TYPE_TRAINER_AND_GENERATOR + /// /// /// LoRA adapter configuration /// + /// 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 StartTrainingSessionAsync( string baseModel, string? resumeFromCheckpointId = default, + global::Together.RlSessionType? type = default, global::Together.RlLoraConfig? loraConfig = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.RlStartTrainingSessionRequest { BaseModel = baseModel, ResumeFromCheckpointId = resumeFromCheckpointId, + Type = type, LoraConfig = loraConfig, }; return await StartTrainingSessionAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Together/Generated/Together.RlClient.StopTrainingSession.g.cs b/src/libs/Together/Generated/Together.RlClient.StopTrainingSession.g.cs index a5be2de8..3b2eb815 100644 --- a/src/libs/Together/Generated/Together.RlClient.StopTrainingSession.g.cs +++ b/src/libs/Together/Generated/Together.RlClient.StopTrainingSession.g.cs @@ -14,6 +14,7 @@ public partial class RlClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,10 +48,35 @@ partial void ProcessStopTrainingSessionResponseContent( /// /// ID of the training session /// + /// 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 StopTrainingSessionAsync( string sessionId, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await StopTrainingSessionAsResponseAsync( + sessionId: sessionId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Stop training session
+ /// Stops a training session. + ///
+ /// + /// ID of the training session + /// + /// 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> StopTrainingSessionAsResponseAsync( + string sessionId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -65,22 +91,44 @@ partial void ProcessStopTrainingSessionResponseContent( securityRequirements: s_StopTrainingSessionSecurityRequirements, operationName: "StopTrainingSessionAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/rl/training-sessions/{sessionId}/stop", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/rl/training-sessions/{sessionId}/stop", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -90,150 +138,335 @@ partial void ProcessStopTrainingSessionResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareStopTrainingSessionRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - sessionId: sessionId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareStopTrainingSessionRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + sessionId: sessionId!); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessStopTrainingSessionResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // An unexpected error response. - if (!__response.IsSuccessStatusCode) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_default = null; - global::System.Exception? __exception_default = null; - global::Together.ErrorData? __value_default = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "StopTrainingSession", + methodName: "StopTrainingSessionAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/stop\"", + 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 { - __content_default = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_default = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "StopTrainingSession", + methodName: "StopTrainingSessionAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/stop\"", + 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; + } - __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "StopTrainingSession", + methodName: "StopTrainingSessionAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/stop\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_default = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_default ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_default, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_default, - ResponseObject = __value_default, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessStopTrainingSessionResponseContent( + response: __response); + ProcessStopTrainingSessionResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.RlTrainingSession.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "StopTrainingSession", + methodName: "StopTrainingSessionAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/stop\"", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "StopTrainingSession", + methodName: "StopTrainingSessionAsync", + pathTemplate: "$\"/rl/training-sessions/{sessionId}/stop\"", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // An unexpected error response. + if (!__response.IsSuccessStatusCode) + { + string? __content_default = null; + global::System.Exception? __exception_default = null; + global::Together.ErrorData? __value_default = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + } + else + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.RlTrainingSession.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_default = global::Together.ErrorData.FromJson(__content_default, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_default = __ex; + } + + throw new global::Together.ApiException( + message: __content_default ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_default, + statusCode: __response.StatusCode) + { + ResponseBody = __content_default, + ResponseObject = __value_default, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessStopTrainingSessionResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.RlTrainingSession.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.RlTrainingSession.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.RlClient.g.cs b/src/libs/Together/Generated/Together.RlClient.g.cs index 7fcccebf..c4303325 100644 --- a/src/libs/Together/Generated/Together.RlClient.g.cs +++ b/src/libs/Together/Generated/Together.RlClient.g.cs @@ -12,7 +12,7 @@ public sealed partial class RlClient : global::Together.IRlClient, global::Syste /// /// /// - public const string DefaultBaseUrl = "https://api.together.xyz/v1"; + public const string DefaultBaseUrl = "https://api.together.ai/v1"; private bool _disposeHttpClient = true; @@ -30,6 +30,12 @@ public sealed partial class RlClient : global::Together.IRlClient, global::Syste #if DEBUG = true; #endif + + /// + public global::Together.AutoSDKClientOptions Options { get; } + + + internal global::Together.AutoSDKServerConfiguration AutoSDKServerConfiguration { get; set; } = new global::Together.AutoSDKServerConfiguration(); /// /// /// @@ -49,13 +55,62 @@ public RlClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the RlClient with explicit options but no base URL override. + /// Skips passing baseUri so the default base URL from the OpenAPI spec applies. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public RlClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, + bool disposeHttpClient = true) : this( + httpClient, + baseUri: null, + authorizations, + options, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the RlClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public RlClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Together.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; + AutoSDKServerConfiguration.ExplicitBaseUri = baseUri ?? httpClient?.BaseAddress; + Initialized(HttpClient); } diff --git a/src/libs/Together/Generated/Together.SecretsClient.CreateDeploymentsSecrets.g.cs b/src/libs/Together/Generated/Together.SecretsClient.CreateDeploymentsSecrets.g.cs index 2292bb8e..83bfe99d 100644 --- a/src/libs/Together/Generated/Together.SecretsClient.CreateDeploymentsSecrets.g.cs +++ b/src/libs/Together/Generated/Together.SecretsClient.CreateDeploymentsSecrets.g.cs @@ -14,6 +14,7 @@ public partial class SecretsClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,6 +46,7 @@ partial void ProcessCreateDeploymentsSecretsResponseContent( /// Create a new secret to store sensitive configuration values ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -55,6 +57,35 @@ partial void ProcessCreateDeploymentsSecretsResponseContent( public async global::System.Threading.Tasks.Task CreateDeploymentsSecretsAsync( global::Together.CreateSecretRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreateDeploymentsSecretsAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Create a new secret
+ /// Create a new secret to store sensitive configuration values + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// client.beta.jig.secrets.create(name="my-secret", value="my-value") + ///
+ public async global::System.Threading.Tasks.Task> CreateDeploymentsSecretsAsResponseAsync( + + global::Together.CreateSecretRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +102,44 @@ partial void ProcessCreateDeploymentsSecretsResponseContent( securityRequirements: s_CreateDeploymentsSecretsSecurityRequirements, operationName: "CreateDeploymentsSecretsAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/deployments/secrets", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/deployments/secrets", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -96,194 +149,379 @@ partial void ProcessCreateDeploymentsSecretsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateDeploymentsSecretsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateDeploymentsSecretsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateDeploymentsSecretsResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Invalid request - if ((int)__response.StatusCode == 400) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - string? __value_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createDeploymentsSecrets", + methodName: "CreateDeploymentsSecretsAsync", + pathTemplate: "\"/deployments/secrets\"", + 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 { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createDeploymentsSecrets", + methodName: "CreateDeploymentsSecretsAsync", + pathTemplate: "\"/deployments/secrets\"", + 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; + } - __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } - throw new global::Together.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Internal server error - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - string? __value_500 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createDeploymentsSecrets", + methodName: "CreateDeploymentsSecretsAsync", + pathTemplate: "\"/deployments/secrets\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_500 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessCreateDeploymentsSecretsResponseContent( + response: __response); + ProcessCreateDeploymentsSecretsResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.SecretResponseItem.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createDeploymentsSecrets", + methodName: "CreateDeploymentsSecretsAsync", + pathTemplate: "\"/deployments/secrets\"", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createDeploymentsSecrets", + methodName: "CreateDeploymentsSecretsAsync", + pathTemplate: "\"/deployments/secrets\"", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Invalid request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + string? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.SecretResponseItem.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Together.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal server error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + string? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessCreateDeploymentsSecretsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.SecretResponseItem.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.SecretResponseItem.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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 a new secret
@@ -299,8 +537,9 @@ partial void ProcessCreateDeploymentsSecretsResponseContent( /// ProjectID is ignored - the project is automatically determined from your authentication /// /// - /// Value is the sensitive data to store securely (e.g., API keys, passwords, tokens). This value will be encrypted at rest + /// Value is the sensitive data to store securely (e.g., API keys, passwords, tokens). Encrypted at rest. /// + /// 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 CreateDeploymentsSecretsAsync( @@ -308,6 +547,7 @@ partial void ProcessCreateDeploymentsSecretsResponseContent( string value, string? description = default, string? projectId = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.CreateSecretRequest @@ -320,6 +560,7 @@ partial void ProcessCreateDeploymentsSecretsResponseContent( return await CreateDeploymentsSecretsAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Together/Generated/Together.SecretsClient.DeleteDeploymentsSecretsById.g.cs b/src/libs/Together/Generated/Together.SecretsClient.DeleteDeploymentsSecretsById.g.cs index e8ebdc53..0c387644 100644 --- a/src/libs/Together/Generated/Together.SecretsClient.DeleteDeploymentsSecretsById.g.cs +++ b/src/libs/Together/Generated/Together.SecretsClient.DeleteDeploymentsSecretsById.g.cs @@ -14,6 +14,7 @@ public partial class SecretsClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,6 +48,7 @@ partial void ProcessDeleteDeploymentsSecretsByIdResponseContent( /// /// Secret ID or name /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -56,6 +58,35 @@ partial void ProcessDeleteDeploymentsSecretsByIdResponseContent( /// public async global::System.Threading.Tasks.Task DeleteDeploymentsSecretsByIdAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await DeleteDeploymentsSecretsByIdAsResponseAsync( + id: id, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Delete a secret
+ /// Delete an existing secret + ///
+ /// + /// Secret ID or name + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// client.beta.jig.secrets.delete("my-secret") + ///
+ public async global::System.Threading.Tasks.Task> DeleteDeploymentsSecretsByIdAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -70,22 +101,44 @@ partial void ProcessDeleteDeploymentsSecretsByIdResponseContent( securityRequirements: s_DeleteDeploymentsSecretsByIdSecurityRequirements, operationName: "DeleteDeploymentsSecretsByIdAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/deployments/secrets/{id}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Delete, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/deployments/secrets/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Delete, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -95,184 +148,369 @@ partial void ProcessDeleteDeploymentsSecretsByIdResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteDeploymentsSecretsByIdRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteDeploymentsSecretsByIdRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id!); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteDeploymentsSecretsByIdResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Secret not found - if ((int)__response.StatusCode == 404) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; - string? __value_404 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "deleteDeploymentsSecretsById", + methodName: "DeleteDeploymentsSecretsByIdAsync", + pathTemplate: "$\"/deployments/secrets/{id}\"", + httpMethod: "DELETE", + 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 { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "deleteDeploymentsSecretsById", + methodName: "DeleteDeploymentsSecretsByIdAsync", + pathTemplate: "$\"/deployments/secrets/{id}\"", + httpMethod: "DELETE", + 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; + } - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_404 = __ex; - } - throw new global::Together.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Internal server error - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - string? __value_500 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "deleteDeploymentsSecretsById", + methodName: "DeleteDeploymentsSecretsByIdAsync", + pathTemplate: "$\"/deployments/secrets/{id}\"", + httpMethod: "DELETE", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_500 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessDeleteDeploymentsSecretsByIdResponseContent( + response: __response); + ProcessDeleteDeploymentsSecretsByIdResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return __content; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "deleteDeploymentsSecretsById", + methodName: "DeleteDeploymentsSecretsByIdAsync", + pathTemplate: "$\"/deployments/secrets/{id}\"", + httpMethod: "DELETE", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "deleteDeploymentsSecretsById", + methodName: "DeleteDeploymentsSecretsByIdAsync", + pathTemplate: "$\"/deployments/secrets/{id}\"", + httpMethod: "DELETE", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Secret not found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + string? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return __content; - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Together.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal server error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + string? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessDeleteDeploymentsSecretsByIdResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __content); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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(); + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __content); + } + 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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.SecretsClient.EditDeploymentsSecretsById.g.cs b/src/libs/Together/Generated/Together.SecretsClient.EditDeploymentsSecretsById.g.cs index 802e0b15..a89f8c6c 100644 --- a/src/libs/Together/Generated/Together.SecretsClient.EditDeploymentsSecretsById.g.cs +++ b/src/libs/Together/Generated/Together.SecretsClient.EditDeploymentsSecretsById.g.cs @@ -14,6 +14,7 @@ public partial class SecretsClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -50,6 +51,7 @@ partial void ProcessEditDeploymentsSecretsByIdResponseContent( /// Secret ID or name /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -61,6 +63,40 @@ partial void ProcessEditDeploymentsSecretsByIdResponseContent( string id, global::Together.UpdateSecretRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await EditDeploymentsSecretsByIdAsResponseAsync( + id: id, + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Update a secret
+ /// Update an existing secret's value or metadata + ///
+ /// + /// Secret ID or name + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// client.beta.jig.secrets.update("my-secret", value="my-new-value") + ///
+ public async global::System.Threading.Tasks.Task> EditDeploymentsSecretsByIdAsResponseAsync( + string id, + + global::Together.UpdateSecretRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -78,22 +114,44 @@ partial void ProcessEditDeploymentsSecretsByIdResponseContent( securityRequirements: s_EditDeploymentsSecretsByIdSecurityRequirements, operationName: "EditDeploymentsSecretsByIdAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/deployments/secrets/{id}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: new global::System.Net.Http.HttpMethod("PATCH"), - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/deployments/secrets/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: new global::System.Net.Http.HttpMethod("PATCH"), + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -103,233 +161,418 @@ partial void ProcessEditDeploymentsSecretsByIdResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareEditDeploymentsSecretsByIdRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareEditDeploymentsSecretsByIdRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id!, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessEditDeploymentsSecretsByIdResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Invalid request - if ((int)__response.StatusCode == 400) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - string? __value_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "editDeploymentsSecretsById", + methodName: "EditDeploymentsSecretsByIdAsync", + pathTemplate: "$\"/deployments/secrets/{id}\"", + httpMethod: "PATCH", + 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 { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "editDeploymentsSecretsById", + methodName: "EditDeploymentsSecretsByIdAsync", + pathTemplate: "$\"/deployments/secrets/{id}\"", + httpMethod: "PATCH", + 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; + } - __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } - throw new global::Together.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Secret not found - if ((int)__response.StatusCode == 404) - { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; - string? __value_404 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "editDeploymentsSecretsById", + methodName: "EditDeploymentsSecretsByIdAsync", + pathTemplate: "$\"/deployments/secrets/{id}\"", + httpMethod: "PATCH", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_404 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Internal server error - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - string? __value_500 = null; - try + using (__response) { - if (ReadResponseAsString) - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); - } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); - } + ProcessResponse( + client: HttpClient, + response: __response); + ProcessEditDeploymentsSecretsByIdResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "editDeploymentsSecretsById", + methodName: "EditDeploymentsSecretsByIdAsync", + pathTemplate: "$\"/deployments/secrets/{id}\"", + httpMethod: "PATCH", + 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); } - catch (global::System.Exception __ex) + else { - __exception_500 = __ex; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "editDeploymentsSecretsById", + methodName: "EditDeploymentsSecretsByIdAsync", + pathTemplate: "$\"/deployments/secrets/{id}\"", + httpMethod: "PATCH", + 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); } + // Invalid request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + string? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) - { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } + __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + throw new global::Together.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Secret not found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + string? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessEditDeploymentsSecretsByIdResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } - try - { - __response.EnsureSuccessStatusCode(); + throw new global::Together.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal server error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + string? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - global::Together.SecretResponseItem.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - } - catch (global::System.Exception __ex) - { - throw new global::Together.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 - cancellationToken -#endif - ).ConfigureAwait(false); + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } - return - await global::Together.SecretResponseItem.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessEditDeploymentsSecretsByIdResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.SecretResponseItem.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.SecretResponseItem.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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(); + } } /// /// Update a secret
@@ -348,8 +591,9 @@ partial void ProcessEditDeploymentsSecretsByIdResponseContent( /// ProjectID is ignored - the project is automatically determined from your authentication /// /// - /// Value is the new sensitive data to store securely. Updating this will replace the existing secret value + /// Value is the new sensitive data to store securely. Updating this replaces the existing secret value. /// + /// 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 EditDeploymentsSecretsByIdAsync( @@ -358,6 +602,7 @@ partial void ProcessEditDeploymentsSecretsByIdResponseContent( string? name = default, string? projectId = default, string? value = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.UpdateSecretRequest @@ -371,6 +616,7 @@ partial void ProcessEditDeploymentsSecretsByIdResponseContent( return await EditDeploymentsSecretsByIdAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Together/Generated/Together.SecretsClient.GetDeploymentsSecrets.g.cs b/src/libs/Together/Generated/Together.SecretsClient.GetDeploymentsSecrets.g.cs index 57c92d19..4210646e 100644 --- a/src/libs/Together/Generated/Together.SecretsClient.GetDeploymentsSecrets.g.cs +++ b/src/libs/Together/Generated/Together.SecretsClient.GetDeploymentsSecrets.g.cs @@ -14,6 +14,7 @@ public partial class SecretsClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -42,6 +43,7 @@ partial void ProcessGetDeploymentsSecretsResponseContent( /// Get the list of project secrets
/// Retrieve all secrets in your project ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -51,6 +53,31 @@ partial void ProcessGetDeploymentsSecretsResponseContent( /// print(secrets) /// public async global::System.Threading.Tasks.Task GetDeploymentsSecretsAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetDeploymentsSecretsAsResponseAsync( + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get the list of project secrets
+ /// Retrieve all secrets in your project + ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// secrets = client.beta.jig.secrets.list()
+ /// print(secrets) + ///
+ public async global::System.Threading.Tasks.Task> GetDeploymentsSecretsAsResponseAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -64,22 +91,44 @@ partial void ProcessGetDeploymentsSecretsResponseContent( securityRequirements: s_GetDeploymentsSecretsSecurityRequirements, operationName: "GetDeploymentsSecretsAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/deployments/secrets", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/deployments/secrets", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -89,149 +138,334 @@ partial void ProcessGetDeploymentsSecretsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetDeploymentsSecretsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetDeploymentsSecretsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); - - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetDeploymentsSecretsResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Internal server error - if ((int)__response.StatusCode == 500) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - string? __value_500 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsSecrets", + methodName: "GetDeploymentsSecretsAsync", + pathTemplate: "\"/deployments/secrets\"", + httpMethod: "GET", + 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 { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsSecrets", + methodName: "GetDeploymentsSecretsAsync", + pathTemplate: "\"/deployments/secrets\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsSecrets", + methodName: "GetDeploymentsSecretsAsync", + pathTemplate: "\"/deployments/secrets\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_500 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessGetDeploymentsSecretsResponseContent( + response: __response); + ProcessGetDeploymentsSecretsResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.ListSecretsResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsSecrets", + methodName: "GetDeploymentsSecretsAsync", + pathTemplate: "\"/deployments/secrets\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsSecrets", + methodName: "GetDeploymentsSecretsAsync", + pathTemplate: "\"/deployments/secrets\"", + httpMethod: "GET", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Internal server error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + string? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.ListSecretsResponse.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessGetDeploymentsSecretsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.ListSecretsResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.ListSecretsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.SecretsClient.GetDeploymentsSecretsById.g.cs b/src/libs/Together/Generated/Together.SecretsClient.GetDeploymentsSecretsById.g.cs index e6b17da9..7cc047ba 100644 --- a/src/libs/Together/Generated/Together.SecretsClient.GetDeploymentsSecretsById.g.cs +++ b/src/libs/Together/Generated/Together.SecretsClient.GetDeploymentsSecretsById.g.cs @@ -14,6 +14,7 @@ public partial class SecretsClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,6 +48,7 @@ partial void ProcessGetDeploymentsSecretsByIdResponseContent( /// /// Secret ID or name /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -57,6 +59,36 @@ partial void ProcessGetDeploymentsSecretsByIdResponseContent( /// public async global::System.Threading.Tasks.Task GetDeploymentsSecretsByIdAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetDeploymentsSecretsByIdAsResponseAsync( + id: id, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get a secret by ID or name
+ /// Retrieve details of a specific secret by its ID or name + ///
+ /// + /// Secret ID or name + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// secret = client.beta.jig.secrets.retrieve("my-secret")
+ /// print(secret) + ///
+ public async global::System.Threading.Tasks.Task> GetDeploymentsSecretsByIdAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -71,22 +103,44 @@ partial void ProcessGetDeploymentsSecretsByIdResponseContent( securityRequirements: s_GetDeploymentsSecretsByIdSecurityRequirements, operationName: "GetDeploymentsSecretsByIdAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/deployments/secrets/{id}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/deployments/secrets/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -96,188 +150,373 @@ partial void ProcessGetDeploymentsSecretsByIdResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetDeploymentsSecretsByIdRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetDeploymentsSecretsByIdRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id!); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetDeploymentsSecretsByIdResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Secret not found - if ((int)__response.StatusCode == 404) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; - string? __value_404 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsSecretsById", + methodName: "GetDeploymentsSecretsByIdAsync", + pathTemplate: "$\"/deployments/secrets/{id}\"", + httpMethod: "GET", + 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 { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsSecretsById", + methodName: "GetDeploymentsSecretsByIdAsync", + pathTemplate: "$\"/deployments/secrets/{id}\"", + httpMethod: "GET", + 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; + } - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_404 = __ex; - } - throw new global::Together.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Internal server error - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - string? __value_500 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsSecretsById", + methodName: "GetDeploymentsSecretsByIdAsync", + pathTemplate: "$\"/deployments/secrets/{id}\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_500 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessGetDeploymentsSecretsByIdResponseContent( + response: __response); + ProcessGetDeploymentsSecretsByIdResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.SecretResponseItem.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsSecretsById", + methodName: "GetDeploymentsSecretsByIdAsync", + pathTemplate: "$\"/deployments/secrets/{id}\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsSecretsById", + methodName: "GetDeploymentsSecretsByIdAsync", + pathTemplate: "$\"/deployments/secrets/{id}\"", + httpMethod: "GET", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Secret not found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + string? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.SecretResponseItem.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Together.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal server error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + string? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessGetDeploymentsSecretsByIdResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.SecretResponseItem.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.SecretResponseItem.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.SecretsClient.g.cs b/src/libs/Together/Generated/Together.SecretsClient.g.cs index dfca3b62..a5c10f1b 100644 --- a/src/libs/Together/Generated/Together.SecretsClient.g.cs +++ b/src/libs/Together/Generated/Together.SecretsClient.g.cs @@ -12,7 +12,7 @@ public sealed partial class SecretsClient : global::Together.ISecretsClient, glo /// /// /// - public const string DefaultBaseUrl = "https://api.together.xyz/v1"; + public const string DefaultBaseUrl = "https://api.together.ai/v1"; private bool _disposeHttpClient = true; @@ -30,6 +30,12 @@ public sealed partial class SecretsClient : global::Together.ISecretsClient, glo #if DEBUG = true; #endif + + /// + public global::Together.AutoSDKClientOptions Options { get; } + + + internal global::Together.AutoSDKServerConfiguration AutoSDKServerConfiguration { get; set; } = new global::Together.AutoSDKServerConfiguration(); /// /// /// @@ -49,13 +55,62 @@ public SecretsClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the SecretsClient with explicit options but no base URL override. + /// Skips passing baseUri so the default base URL from the OpenAPI spec applies. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public SecretsClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, + bool disposeHttpClient = true) : this( + httpClient, + baseUri: null, + authorizations, + options, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the SecretsClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public SecretsClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Together.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; + AutoSDKServerConfiguration.ExplicitBaseUri = baseUri ?? httpClient?.BaseAddress; + Initialized(HttpClient); } diff --git a/src/libs/Together/Generated/Together.Security.g.cs b/src/libs/Together/Generated/Together.Security.g.cs index b4486061..ab4f6ccb 100644 --- a/src/libs/Together/Generated/Together.Security.g.cs +++ b/src/libs/Together/Generated/Together.Security.g.cs @@ -6,6 +6,8 @@ internal sealed class EndPointAuthorizationRequirement { internal string Type { get; set; } = string.Empty; + internal string SchemeId { get; set; } = string.Empty; + internal string Location { get; set; } = string.Empty; internal string Name { get; set; } = string.Empty; @@ -97,7 +99,18 @@ private static bool Matches( return requiredAuthorization.Type switch { - "OAuth2" => true, + "OAuth2" => string.Equals( + availableAuthorization.SchemeId, + requiredAuthorization.SchemeId, + global::System.StringComparison.Ordinal), + "OpenIdConnect" => string.Equals( + availableAuthorization.SchemeId, + requiredAuthorization.SchemeId, + global::System.StringComparison.Ordinal), + "MutualTLS" => string.Equals( + availableAuthorization.SchemeId, + requiredAuthorization.SchemeId, + global::System.StringComparison.Ordinal), "Http" => string.Equals( availableAuthorization.Name, requiredAuthorization.Name, diff --git a/src/libs/Together/Generated/Together.ServerSelection.g.cs b/src/libs/Together/Generated/Together.ServerSelection.g.cs new file mode 100644 index 00000000..8c1593b4 --- /dev/null +++ b/src/libs/Together/Generated/Together.ServerSelection.g.cs @@ -0,0 +1,57 @@ +#nullable enable + +namespace Together +{ + /// + /// Represents a concrete OpenAPI server option. + /// + public sealed class AutoSDKServer + { + /// + /// Initializes a new instance of the class. + /// + /// The stable identifier for this server option. + /// The display name for this server option. + /// The server URL. + /// The server description. + public AutoSDKServer( + string id, + string name, + string url, + string description) + { + Id = id ?? throw new global::System.ArgumentNullException(nameof(id)); + Name = name ?? string.Empty; + Url = url ?? throw new global::System.ArgumentNullException(nameof(url)); + Description = description ?? string.Empty; + Uri = new global::System.Uri(url, global::System.UriKind.RelativeOrAbsolute); + } + + /// + /// Gets the stable identifier for this server option. + /// + public string Id { get; } + /// + /// Gets the display name for this server option. + /// + public string Name { get; } + /// + /// Gets the server URL. + /// + public string Url { get; } + /// + /// Gets the server description. + /// + public string Description { get; } + /// + /// Gets the parsed server URI. + /// + public global::System.Uri Uri { get; } + } + + internal sealed class AutoSDKServerConfiguration + { + public global::System.Uri? ExplicitBaseUri { get; set; } + public global::Together.AutoSDKServer? SelectedServer { get; set; } + } +} \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.SharedVolumeServiceClient.SharedVolumeServiceCreate.g.cs b/src/libs/Together/Generated/Together.SharedVolumeServiceClient.SharedVolumeServiceCreate.g.cs index 29298f71..fb01bdb2 100644 --- a/src/libs/Together/Generated/Together.SharedVolumeServiceClient.SharedVolumeServiceCreate.g.cs +++ b/src/libs/Together/Generated/Together.SharedVolumeServiceClient.SharedVolumeServiceCreate.g.cs @@ -14,6 +14,7 @@ public partial class SharedVolumeServiceClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -41,12 +42,13 @@ partial void ProcessSharedVolumeServiceCreateResponseContent( ref string content); /// - /// Create a shared volume.
+ /// Create a shared volume
/// Instant Clusters supports long-lived, resizable in-DC shared storage with user data persistence.
/// You can dynamically create and attach volumes to your cluster at cluster creation time, and resize as your data grows.
/// All shared storage is backed by multi-NIC bare metal paths, ensuring high-throughput and low-latency performance for shared storage. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -61,6 +63,41 @@ partial void ProcessSharedVolumeServiceCreateResponseContent( public async global::System.Threading.Tasks.Task SharedVolumeServiceCreateAsync( global::Together.GPUClustersSharedVolumeCreateRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await SharedVolumeServiceCreateAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Create a shared volume
+ /// Instant Clusters supports long-lived, resizable in-DC shared storage with user data persistence.
+ /// You can dynamically create and attach volumes to your cluster at cluster creation time, and resize as your data grows.
+ /// All shared storage is backed by multi-NIC bare metal paths, ensuring high-throughput and low-latency performance for shared storage. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// volume = client.beta.clusters.storage.create(
+ /// volume_name="my-shared-volume",
+ /// size_tib=2,
+ /// region="us-west-2"
+ /// ) + ///
+ public async global::System.Threading.Tasks.Task> SharedVolumeServiceCreateAsResponseAsync( + + global::Together.GPUClustersSharedVolumeCreateRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -77,22 +114,44 @@ partial void ProcessSharedVolumeServiceCreateResponseContent( securityRequirements: s_SharedVolumeServiceCreateSecurityRequirements, operationName: "SharedVolumeServiceCreateAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/compute/clusters/storage/volumes", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/compute/clusters/storage/volumes", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -102,121 +161,306 @@ partial void ProcessSharedVolumeServiceCreateResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSharedVolumeServiceCreateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareSharedVolumeServiceCreateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessSharedVolumeServiceCreateResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SharedVolumeServiceCreate", + methodName: "SharedVolumeServiceCreateAsync", + pathTemplate: "\"/compute/clusters/storage/volumes\"", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SharedVolumeServiceCreate", + methodName: "SharedVolumeServiceCreateAsync", + pathTemplate: "\"/compute/clusters/storage/volumes\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessSharedVolumeServiceCreateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SharedVolumeServiceCreate", + methodName: "SharedVolumeServiceCreateAsync", + pathTemplate: "\"/compute/clusters/storage/volumes\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::Together.GPUClustersSharedVolume.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Together.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), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return - await global::Together.GPUClustersSharedVolume.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessSharedVolumeServiceCreateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SharedVolumeServiceCreate", + methodName: "SharedVolumeServiceCreateAsync", + pathTemplate: "\"/compute/clusters/storage/volumes\"", + 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); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SharedVolumeServiceCreate", + methodName: "SharedVolumeServiceCreateAsync", + pathTemplate: "\"/compute/clusters/storage/volumes\"", + 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); + ProcessSharedVolumeServiceCreateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.GPUClustersSharedVolume.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.GPUClustersSharedVolume.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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 a shared volume.
+ /// Create a shared volume
/// Instant Clusters supports long-lived, resizable in-DC shared storage with user data persistence.
/// You can dynamically create and attach volumes to your cluster at cluster creation time, and resize as your data grows.
/// All shared storage is backed by multi-NIC bare metal paths, ensuring high-throughput and low-latency performance for shared storage. @@ -230,12 +474,14 @@ partial void ProcessSharedVolumeServiceCreateResponseContent( /// /// Region name. Usable regions can be found from `client.clusters.list_regions()` /// + /// 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 SharedVolumeServiceCreateAsync( string volumeName, long sizeTib, string region, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.GPUClustersSharedVolumeCreateRequest @@ -247,6 +493,7 @@ partial void ProcessSharedVolumeServiceCreateResponseContent( return await SharedVolumeServiceCreateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Together/Generated/Together.SharedVolumeServiceClient.SharedVolumeServiceDelete.g.cs b/src/libs/Together/Generated/Together.SharedVolumeServiceClient.SharedVolumeServiceDelete.g.cs index ef82726a..4539c594 100644 --- a/src/libs/Together/Generated/Together.SharedVolumeServiceClient.SharedVolumeServiceDelete.g.cs +++ b/src/libs/Together/Generated/Together.SharedVolumeServiceClient.SharedVolumeServiceDelete.g.cs @@ -14,6 +14,7 @@ public partial class SharedVolumeServiceClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -41,12 +42,13 @@ partial void ProcessSharedVolumeServiceDeleteResponseContent( ref string content); /// - /// Delete shared volume by volume id.
+ /// Delete a shared volume by ID
/// Delete a shared volume. Note that if this volume is attached to a cluster, deleting will fail. ///
/// /// The ID of the volume to delete /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -57,6 +59,36 @@ partial void ProcessSharedVolumeServiceDeleteResponseContent( /// public async global::System.Threading.Tasks.Task SharedVolumeServiceDeleteAsync( string volumeId, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await SharedVolumeServiceDeleteAsResponseAsync( + volumeId: volumeId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Delete a shared volume by ID
+ /// Delete a shared volume. Note that if this volume is attached to a cluster, deleting will fail. + ///
+ /// + /// The ID of the volume to delete + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// volume = client.beta.clusters.storage.delete("volume_id")
+ /// print(volume) + ///
+ public async global::System.Threading.Tasks.Task> SharedVolumeServiceDeleteAsResponseAsync( + string volumeId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -71,22 +103,44 @@ partial void ProcessSharedVolumeServiceDeleteResponseContent( securityRequirements: s_SharedVolumeServiceDeleteSecurityRequirements, operationName: "SharedVolumeServiceDeleteAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/compute/clusters/storage/volumes/{volumeId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Delete, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/compute/clusters/storage/volumes/{volumeId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Delete, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -96,112 +150,297 @@ partial void ProcessSharedVolumeServiceDeleteResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSharedVolumeServiceDeleteRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - volumeId: volumeId); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareSharedVolumeServiceDeleteRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + volumeId: volumeId!); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessSharedVolumeServiceDeleteResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SharedVolumeServiceDelete", + methodName: "SharedVolumeServiceDeleteAsync", + pathTemplate: "$\"/compute/clusters/storage/volumes/{volumeId}\"", + httpMethod: "DELETE", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SharedVolumeServiceDelete", + methodName: "SharedVolumeServiceDeleteAsync", + pathTemplate: "$\"/compute/clusters/storage/volumes/{volumeId}\"", + httpMethod: "DELETE", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessSharedVolumeServiceDeleteResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SharedVolumeServiceDelete", + methodName: "SharedVolumeServiceDeleteAsync", + pathTemplate: "$\"/compute/clusters/storage/volumes/{volumeId}\"", + httpMethod: "DELETE", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::Together.GPUClustersSharedVolumeDeleteResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Together.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), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return - await global::Together.GPUClustersSharedVolumeDeleteResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessSharedVolumeServiceDeleteResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SharedVolumeServiceDelete", + methodName: "SharedVolumeServiceDeleteAsync", + pathTemplate: "$\"/compute/clusters/storage/volumes/{volumeId}\"", + httpMethod: "DELETE", + 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); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SharedVolumeServiceDelete", + methodName: "SharedVolumeServiceDeleteAsync", + pathTemplate: "$\"/compute/clusters/storage/volumes/{volumeId}\"", + httpMethod: "DELETE", + 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); + ProcessSharedVolumeServiceDeleteResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.GPUClustersSharedVolumeDeleteResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.GPUClustersSharedVolumeDeleteResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.SharedVolumeServiceClient.SharedVolumeServiceGet.g.cs b/src/libs/Together/Generated/Together.SharedVolumeServiceClient.SharedVolumeServiceGet.g.cs index 5aadc199..b65ffc4b 100644 --- a/src/libs/Together/Generated/Together.SharedVolumeServiceClient.SharedVolumeServiceGet.g.cs +++ b/src/libs/Together/Generated/Together.SharedVolumeServiceClient.SharedVolumeServiceGet.g.cs @@ -14,6 +14,7 @@ public partial class SharedVolumeServiceClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -41,12 +42,13 @@ partial void ProcessSharedVolumeServiceGetResponseContent( ref string content); /// - /// Get shared volume by volume Id.
+ /// Get a shared volume by ID
/// Retrieve information about a specific shared volume. ///
/// /// The ID of the volume to retrieve /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -57,6 +59,36 @@ partial void ProcessSharedVolumeServiceGetResponseContent( /// public async global::System.Threading.Tasks.Task SharedVolumeServiceGetAsync( string volumeId, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await SharedVolumeServiceGetAsResponseAsync( + volumeId: volumeId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get a shared volume by ID
+ /// Retrieve information about a specific shared volume. + ///
+ /// + /// The ID of the volume to retrieve + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// volume = client.beta.clusters.storage.retrieve("volume_id")
+ /// print(volume) + ///
+ public async global::System.Threading.Tasks.Task> SharedVolumeServiceGetAsResponseAsync( + string volumeId, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -71,22 +103,44 @@ partial void ProcessSharedVolumeServiceGetResponseContent( securityRequirements: s_SharedVolumeServiceGetSecurityRequirements, operationName: "SharedVolumeServiceGetAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/compute/clusters/storage/volumes/{volumeId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/compute/clusters/storage/volumes/{volumeId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -96,112 +150,297 @@ partial void ProcessSharedVolumeServiceGetResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSharedVolumeServiceGetRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - volumeId: volumeId); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareSharedVolumeServiceGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + volumeId: volumeId!); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessSharedVolumeServiceGetResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SharedVolumeServiceGet", + methodName: "SharedVolumeServiceGetAsync", + pathTemplate: "$\"/compute/clusters/storage/volumes/{volumeId}\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SharedVolumeServiceGet", + methodName: "SharedVolumeServiceGetAsync", + pathTemplate: "$\"/compute/clusters/storage/volumes/{volumeId}\"", + httpMethod: "GET", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessSharedVolumeServiceGetResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SharedVolumeServiceGet", + methodName: "SharedVolumeServiceGetAsync", + pathTemplate: "$\"/compute/clusters/storage/volumes/{volumeId}\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::Together.GPUClustersSharedVolume.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Together.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), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return - await global::Together.GPUClustersSharedVolume.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessSharedVolumeServiceGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SharedVolumeServiceGet", + methodName: "SharedVolumeServiceGetAsync", + pathTemplate: "$\"/compute/clusters/storage/volumes/{volumeId}\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SharedVolumeServiceGet", + methodName: "SharedVolumeServiceGetAsync", + pathTemplate: "$\"/compute/clusters/storage/volumes/{volumeId}\"", + httpMethod: "GET", + 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); + ProcessSharedVolumeServiceGetResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.GPUClustersSharedVolume.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.GPUClustersSharedVolume.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.SharedVolumeServiceClient.SharedVolumeServiceList.g.cs b/src/libs/Together/Generated/Together.SharedVolumeServiceClient.SharedVolumeServiceList.g.cs index 98116547..90f43a98 100644 --- a/src/libs/Together/Generated/Together.SharedVolumeServiceClient.SharedVolumeServiceList.g.cs +++ b/src/libs/Together/Generated/Together.SharedVolumeServiceClient.SharedVolumeServiceList.g.cs @@ -14,6 +14,7 @@ public partial class SharedVolumeServiceClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -39,9 +40,10 @@ partial void ProcessSharedVolumeServiceListResponseContent( ref string content); /// - /// List all shared volumes.
+ /// List all shared volumes
/// List all shared volumes. ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -51,6 +53,31 @@ partial void ProcessSharedVolumeServiceListResponseContent( /// print(volumes) /// public async global::System.Threading.Tasks.Task SharedVolumeServiceListAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await SharedVolumeServiceListAsResponseAsync( + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// List all shared volumes
+ /// List all shared volumes. + ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// volumes = client.beta.clusters.storage.list()
+ /// print(volumes) + ///
+ public async global::System.Threading.Tasks.Task> SharedVolumeServiceListAsResponseAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -64,22 +91,44 @@ partial void ProcessSharedVolumeServiceListResponseContent( securityRequirements: s_SharedVolumeServiceListSecurityRequirements, operationName: "SharedVolumeServiceListAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/compute/clusters/storage/volumes", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/compute/clusters/storage/volumes", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -89,111 +138,296 @@ partial void ProcessSharedVolumeServiceListResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSharedVolumeServiceListRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareSharedVolumeServiceListRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessSharedVolumeServiceListResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SharedVolumeServiceList", + methodName: "SharedVolumeServiceListAsync", + pathTemplate: "\"/compute/clusters/storage/volumes\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SharedVolumeServiceList", + methodName: "SharedVolumeServiceListAsync", + pathTemplate: "\"/compute/clusters/storage/volumes\"", + httpMethod: "GET", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessSharedVolumeServiceListResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SharedVolumeServiceList", + methodName: "SharedVolumeServiceListAsync", + pathTemplate: "\"/compute/clusters/storage/volumes\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::Together.GPUClustersSharedVolumes.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Together.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), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return - await global::Together.GPUClustersSharedVolumes.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessSharedVolumeServiceListResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SharedVolumeServiceList", + methodName: "SharedVolumeServiceListAsync", + pathTemplate: "\"/compute/clusters/storage/volumes\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SharedVolumeServiceList", + methodName: "SharedVolumeServiceListAsync", + pathTemplate: "\"/compute/clusters/storage/volumes\"", + httpMethod: "GET", + 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); + ProcessSharedVolumeServiceListResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.GPUClustersSharedVolumes.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.GPUClustersSharedVolumes.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.SharedVolumeServiceClient.SharedVolumeServiceUpdate.g.cs b/src/libs/Together/Generated/Together.SharedVolumeServiceClient.SharedVolumeServiceUpdate.g.cs index 96aa53fe..36a3c845 100644 --- a/src/libs/Together/Generated/Together.SharedVolumeServiceClient.SharedVolumeServiceUpdate.g.cs +++ b/src/libs/Together/Generated/Together.SharedVolumeServiceClient.SharedVolumeServiceUpdate.g.cs @@ -14,6 +14,7 @@ public partial class SharedVolumeServiceClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -41,10 +42,11 @@ partial void ProcessSharedVolumeServiceUpdateResponseContent( ref string content); /// - /// Update a shared volume.
+ /// Update a shared volume
/// Update the configuration of an existing shared volume. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -59,6 +61,39 @@ partial void ProcessSharedVolumeServiceUpdateResponseContent( public async global::System.Threading.Tasks.Task SharedVolumeServiceUpdateAsync( global::Together.GPUClustersSharedVolumeUpdateRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await SharedVolumeServiceUpdateAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Update a shared volume
+ /// Update the configuration of an existing shared volume. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// from together import Together
+ /// client = Together()
+ /// volume = client.beta.clusters.storage.update(
+ /// volume_id="12345-67890-12345-67890",
+ /// size_tib=3
+ /// )
+ /// print(volume) + ///
+ public async global::System.Threading.Tasks.Task> SharedVolumeServiceUpdateAsResponseAsync( + + global::Together.GPUClustersSharedVolumeUpdateRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -75,22 +110,44 @@ partial void ProcessSharedVolumeServiceUpdateResponseContent( securityRequirements: s_SharedVolumeServiceUpdateSecurityRequirements, operationName: "SharedVolumeServiceUpdateAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/compute/clusters/storage/volumes", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Put, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/compute/clusters/storage/volumes", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Put, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -100,121 +157,306 @@ partial void ProcessSharedVolumeServiceUpdateResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSharedVolumeServiceUpdateRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareSharedVolumeServiceUpdateRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessSharedVolumeServiceUpdateResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SharedVolumeServiceUpdate", + methodName: "SharedVolumeServiceUpdateAsync", + pathTemplate: "\"/compute/clusters/storage/volumes\"", + httpMethod: "PUT", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SharedVolumeServiceUpdate", + methodName: "SharedVolumeServiceUpdateAsync", + pathTemplate: "\"/compute/clusters/storage/volumes\"", + httpMethod: "PUT", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessSharedVolumeServiceUpdateResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SharedVolumeServiceUpdate", + methodName: "SharedVolumeServiceUpdateAsync", + pathTemplate: "\"/compute/clusters/storage/volumes\"", + httpMethod: "PUT", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::Together.GPUClustersSharedVolume.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Together.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), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return - await global::Together.GPUClustersSharedVolume.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessSharedVolumeServiceUpdateResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SharedVolumeServiceUpdate", + methodName: "SharedVolumeServiceUpdateAsync", + pathTemplate: "\"/compute/clusters/storage/volumes\"", + httpMethod: "PUT", + 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); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SharedVolumeServiceUpdate", + methodName: "SharedVolumeServiceUpdateAsync", + pathTemplate: "\"/compute/clusters/storage/volumes\"", + httpMethod: "PUT", + 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); + ProcessSharedVolumeServiceUpdateResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.GPUClustersSharedVolume.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.GPUClustersSharedVolume.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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(); + } } /// - /// Update a shared volume.
+ /// Update a shared volume
/// Update the configuration of an existing shared volume. ///
/// @@ -223,11 +465,13 @@ partial void ProcessSharedVolumeServiceUpdateResponseContent( /// /// Size of the volume in whole tebibytes (TiB). /// + /// 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 SharedVolumeServiceUpdateAsync( string? volumeId = default, long? sizeTib = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.GPUClustersSharedVolumeUpdateRequest @@ -238,6 +482,7 @@ partial void ProcessSharedVolumeServiceUpdateResponseContent( return await SharedVolumeServiceUpdateAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Together/Generated/Together.SharedVolumeServiceClient.g.cs b/src/libs/Together/Generated/Together.SharedVolumeServiceClient.g.cs index 89f31fbb..b547564f 100644 --- a/src/libs/Together/Generated/Together.SharedVolumeServiceClient.g.cs +++ b/src/libs/Together/Generated/Together.SharedVolumeServiceClient.g.cs @@ -12,7 +12,7 @@ public sealed partial class SharedVolumeServiceClient : global::Together.IShared /// /// /// - public const string DefaultBaseUrl = "https://api.together.xyz/v1"; + public const string DefaultBaseUrl = "https://api.together.ai/v1"; private bool _disposeHttpClient = true; @@ -30,6 +30,12 @@ public sealed partial class SharedVolumeServiceClient : global::Together.IShared #if DEBUG = true; #endif + + /// + public global::Together.AutoSDKClientOptions Options { get; } + + + internal global::Together.AutoSDKServerConfiguration AutoSDKServerConfiguration { get; set; } = new global::Together.AutoSDKServerConfiguration(); /// /// /// @@ -49,13 +55,62 @@ public SharedVolumeServiceClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the SharedVolumeServiceClient with explicit options but no base URL override. + /// Skips passing baseUri so the default base URL from the OpenAPI spec applies. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public SharedVolumeServiceClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, + bool disposeHttpClient = true) : this( + httpClient, + baseUri: null, + authorizations, + options, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the SharedVolumeServiceClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public SharedVolumeServiceClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Together.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; + AutoSDKServerConfiguration.ExplicitBaseUri = baseUri ?? httpClient?.BaseAddress; + Initialized(HttpClient); } diff --git a/src/libs/Together/Generated/Together.TogetherClient.Authorizations.Bearer.g.cs b/src/libs/Together/Generated/Together.TogetherClient.Authorizations.Bearer.g.cs index 021aca9a..67654fdb 100644 --- a/src/libs/Together/Generated/Together.TogetherClient.Authorizations.Bearer.g.cs +++ b/src/libs/Together/Generated/Together.TogetherClient.Authorizations.Bearer.g.cs @@ -25,6 +25,7 @@ public void AuthorizeUsingBearer( Authorizations.Add(new global::Together.EndPointAuthorization { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", Value = apiKey, diff --git a/src/libs/Together/Generated/Together.TogetherClient.Constructors.Bearer.g.cs b/src/libs/Together/Generated/Together.TogetherClient.Constructors.Bearer.g.cs index 91407056..cde26d85 100644 --- a/src/libs/Together/Generated/Together.TogetherClient.Constructors.Bearer.g.cs +++ b/src/libs/Together/Generated/Together.TogetherClient.Constructors.Bearer.g.cs @@ -26,5 +26,6 @@ partial void Authorizing( ref string apiKey); partial void Authorized( global::System.Net.Http.HttpClient client); + } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.TogetherClient.g.cs b/src/libs/Together/Generated/Together.TogetherClient.g.cs index 21d99a86..1f4caa4e 100644 --- a/src/libs/Together/Generated/Together.TogetherClient.g.cs +++ b/src/libs/Together/Generated/Together.TogetherClient.g.cs @@ -4,7 +4,7 @@ namespace Together { /// - /// The Together REST API. Please see https://docs.together.ai for more details.
+ /// The Together REST API. See https://docs.together.ai for more details.
/// If no httpClient is provided, a new one will be created.
/// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. ///
@@ -13,7 +13,7 @@ public sealed partial class TogetherClient : global::Together.ITogetherClient, g /// /// /// - public const string DefaultBaseUrl = "https://api.together.xyz/v1"; + public const string DefaultBaseUrl = "https://api.together.ai/v1"; private bool _disposeHttpClient = true; @@ -21,7 +21,7 @@ public sealed partial class TogetherClient : global::Together.ITogetherClient, g public global::System.Net.Http.HttpClient HttpClient { get; } /// - public System.Uri? BaseUri => HttpClient.BaseAddress; + public System.Uri? BaseUri => ResolveDisplayedBaseUri(); /// public global::System.Collections.Generic.List Authorizations { get; } @@ -31,6 +31,12 @@ public sealed partial class TogetherClient : global::Together.ITogetherClient, g #if DEBUG = true; #endif + + /// + public global::Together.AutoSDKClientOptions Options { get; } + + + internal global::Together.AutoSDKServerConfiguration AutoSDKServerConfiguration { get; set; } = new global::Together.AutoSDKServerConfiguration(); /// /// /// @@ -40,255 +46,311 @@ public sealed partial class TogetherClient : global::Together.ITogetherClient, g /// /// /// - public AudioClient Audio => new AudioClient(HttpClient, authorizations: Authorizations) + public AudioClient Audio => new AudioClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, + AutoSDKServerConfiguration = AutoSDKServerConfiguration, }; /// /// /// - public BatchesClient Batches => new BatchesClient(HttpClient, authorizations: Authorizations) + public BatchesClient Batches => new BatchesClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, + AutoSDKServerConfiguration = AutoSDKServerConfiguration, }; /// /// /// - public ChatClient Chat => new ChatClient(HttpClient, authorizations: Authorizations) + public ChatClient Chat => new ChatClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, + AutoSDKServerConfiguration = AutoSDKServerConfiguration, }; /// /// /// - public CodeInterpreterClient CodeInterpreter => new CodeInterpreterClient(HttpClient, authorizations: Authorizations) + public CodeInterpreterClient CodeInterpreter => new CodeInterpreterClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, + AutoSDKServerConfiguration = AutoSDKServerConfiguration, }; /// /// /// - public CompletionClient Completion => new CompletionClient(HttpClient, authorizations: Authorizations) + public CompletionClient Completion => new CompletionClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, + AutoSDKServerConfiguration = AutoSDKServerConfiguration, }; /// /// /// - public DeploymentsClient Deployments => new DeploymentsClient(HttpClient, authorizations: Authorizations) + public DeploymentsClient Deployments => new DeploymentsClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, + AutoSDKServerConfiguration = AutoSDKServerConfiguration, }; /// /// /// - public DeploymentsStorageClient DeploymentsStorage => new DeploymentsStorageClient(HttpClient, authorizations: Authorizations) + public DeploymentsStorageClient DeploymentsStorage => new DeploymentsStorageClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, + AutoSDKServerConfiguration = AutoSDKServerConfiguration, }; /// /// /// - public DeploymentsVolumesClient DeploymentsVolumes => new DeploymentsVolumesClient(HttpClient, authorizations: Authorizations) + public DeploymentsVolumesClient DeploymentsVolumes => new DeploymentsVolumesClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, + AutoSDKServerConfiguration = AutoSDKServerConfiguration, }; /// /// /// - public EmbeddingsClient Embeddings => new EmbeddingsClient(HttpClient, authorizations: Authorizations) + public EmbeddingsClient Embeddings => new EmbeddingsClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, + AutoSDKServerConfiguration = AutoSDKServerConfiguration, }; /// /// /// - public EndpointsClient Endpoints => new EndpointsClient(HttpClient, authorizations: Authorizations) + public EndpointsClient Endpoints => new EndpointsClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, + AutoSDKServerConfiguration = AutoSDKServerConfiguration, }; /// /// /// - public Endpoints2Client Endpoints2 => new Endpoints2Client(HttpClient, authorizations: Authorizations) + public Endpoints2Client Endpoints2 => new Endpoints2Client(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, + AutoSDKServerConfiguration = AutoSDKServerConfiguration, }; /// /// /// - public EvaluationClient Evaluation => new EvaluationClient(HttpClient, authorizations: Authorizations) + public EvaluationClient Evaluation => new EvaluationClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, + AutoSDKServerConfiguration = AutoSDKServerConfiguration, }; /// /// /// - public FilesClient Files => new FilesClient(HttpClient, authorizations: Authorizations) + public FilesClient Files => new FilesClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, + AutoSDKServerConfiguration = AutoSDKServerConfiguration, }; /// /// /// - public FineTuningClient FineTuning => new FineTuningClient(HttpClient, authorizations: Authorizations) + public FineTuningClient FineTuning => new FineTuningClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, + AutoSDKServerConfiguration = AutoSDKServerConfiguration, }; /// /// /// - public GPUClusterServiceClient GPUClusterService => new GPUClusterServiceClient(HttpClient, authorizations: Authorizations) + public GPUClusterServiceClient GPUClusterService => new GPUClusterServiceClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, + AutoSDKServerConfiguration = AutoSDKServerConfiguration, }; /// /// /// - public HardwareClient Hardware => new HardwareClient(HttpClient, authorizations: Authorizations) + public HardwareClient Hardware => new HardwareClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, + AutoSDKServerConfiguration = AutoSDKServerConfiguration, }; /// /// /// - public ImagesClient Images => new ImagesClient(HttpClient, authorizations: Authorizations) + public ImagesClient Images => new ImagesClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, + AutoSDKServerConfiguration = AutoSDKServerConfiguration, }; /// /// /// - public JobsClient Jobs => new JobsClient(HttpClient, authorizations: Authorizations) + public JobsClient Jobs => new JobsClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, + AutoSDKServerConfiguration = AutoSDKServerConfiguration, }; /// /// /// - public ModelsClient Models => new ModelsClient(HttpClient, authorizations: Authorizations) + public ModelsClient Models => new ModelsClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, + AutoSDKServerConfiguration = AutoSDKServerConfiguration, }; /// /// /// - public QueueClient Queue => new QueueClient(HttpClient, authorizations: Authorizations) + public QueueClient Queue => new QueueClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, + AutoSDKServerConfiguration = AutoSDKServerConfiguration, }; /// /// /// - public RegionServiceClient RegionService => new RegionServiceClient(HttpClient, authorizations: Authorizations) + public RegionServiceClient RegionService => new RegionServiceClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, + AutoSDKServerConfiguration = AutoSDKServerConfiguration, }; /// /// /// - public RerankClient Rerank => new RerankClient(HttpClient, authorizations: Authorizations) + public RerankClient Rerank => new RerankClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, + AutoSDKServerConfiguration = AutoSDKServerConfiguration, }; /// /// /// - public RlClient Rl => new RlClient(HttpClient, authorizations: Authorizations) + public RlClient Rl => new RlClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, + AutoSDKServerConfiguration = AutoSDKServerConfiguration, }; /// /// /// - public SecretsClient Secrets => new SecretsClient(HttpClient, authorizations: Authorizations) + public SecretsClient Secrets => new SecretsClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, + AutoSDKServerConfiguration = AutoSDKServerConfiguration, }; /// /// /// - public SharedVolumeServiceClient SharedVolumeService => new SharedVolumeServiceClient(HttpClient, authorizations: Authorizations) + public SharedVolumeServiceClient SharedVolumeService => new SharedVolumeServiceClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, + AutoSDKServerConfiguration = AutoSDKServerConfiguration, }; /// /// /// - public VideoClient Video => new VideoClient(HttpClient, authorizations: Authorizations) + public VideoClient Video => new VideoClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, + AutoSDKServerConfiguration = AutoSDKServerConfiguration, }; /// /// /// - public VoicesClient Voices => new VoicesClient(HttpClient, authorizations: Authorizations) + public VoicesClient Voices => new VoicesClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, + AutoSDKServerConfiguration = AutoSDKServerConfiguration, }; /// /// /// - public VolumesClient Volumes => new VolumesClient(HttpClient, authorizations: Authorizations) + public VolumesClient Volumes => new VolumesClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, + AutoSDKServerConfiguration = AutoSDKServerConfiguration, + }; + + + private static readonly global::Together.AutoSDKServer[] s_availableServers = new global::Together.AutoSDKServer[] + { new global::Together.AutoSDKServer( + id: "https-api-together-ai-v1", + name: "api.together.ai v1", + url: "https://api.together.ai/v1", + description: ""), + new global::Together.AutoSDKServer( + id: "https-api-together-ai-v2", + name: "api.together.ai v2", + url: "https://api.together.ai/v2", + description: ""), }; + /// + /// The server options available for this client. + /// + public global::System.Collections.Generic.IReadOnlyList AvailableServers => s_availableServers; + + /// + /// The currently selected server for this client, if any. + /// + public global::Together.AutoSDKServer? SelectedServer + { + get => ResolveSelectedServer(); + set => SelectServer(value); + } + /// /// Creates a new instance of the TogetherClient. /// If no httpClient is provided, a new one will be created. @@ -302,13 +364,62 @@ public TogetherClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the TogetherClient with explicit options but no base URL override. + /// Skips passing baseUri so the default base URL from the OpenAPI spec applies. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public TogetherClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, + bool disposeHttpClient = true) : this( + httpClient, + baseUri: null, + authorizations, + options, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the TogetherClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public TogetherClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Together.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; + AutoSDKServerConfiguration.ExplicitBaseUri = baseUri ?? httpClient?.BaseAddress; + Initialized(HttpClient); } @@ -335,5 +446,117 @@ partial void ProcessResponseContent( global::System.Net.Http.HttpClient client, global::System.Net.Http.HttpResponseMessage response, ref string content); + + + /// + /// Selects one of the generated server options by id. + /// + public bool TrySelectServer(string serverId) + { + if (string.IsNullOrWhiteSpace(serverId)) + { + return false; + } + + foreach (var server in s_availableServers) + { + if (string.Equals(server.Id, serverId, global::System.StringComparison.OrdinalIgnoreCase)) + { + AutoSDKServerConfiguration.SelectedServer = server; + AutoSDKServerConfiguration.ExplicitBaseUri = null; + return true; + } + } + + return false; + } + + /// + /// Clears the currently selected server. + /// + public void ClearSelectedServer() + { + AutoSDKServerConfiguration.SelectedServer = null; + } + + private global::Together.AutoSDKServer? ResolveSelectedServer() + { + var selectedServer = AutoSDKServerConfiguration.SelectedServer; + if (selectedServer is null) + { + return null; + } + + foreach (var server in s_availableServers) + { + if (string.Equals(server.Id, selectedServer.Id, global::System.StringComparison.Ordinal)) + { + return server; + } + } + + return null; + } + + private void SelectServer(global::Together.AutoSDKServer? server) + { + if (server is null) + { + AutoSDKServerConfiguration.SelectedServer = null; + return; + } + + foreach (var candidate in s_availableServers) + { + if (string.Equals(candidate.Id, server.Id, global::System.StringComparison.Ordinal)) + { + AutoSDKServerConfiguration.SelectedServer = candidate; + AutoSDKServerConfiguration.ExplicitBaseUri = null; + return; + } + } + + throw new global::System.ArgumentException("The provided server is not available for this client.", nameof(server)); + } + + private global::System.Uri? ResolveDisplayedBaseUri() + { + if (AutoSDKServerConfiguration.ExplicitBaseUri is global::System.Uri explicitBaseUri) + { + return explicitBaseUri; + } + + return ResolveSelectedServer()?.Uri ?? HttpClient.BaseAddress; + } + + private global::System.Uri? ResolveBaseUri( + global::Together.AutoSDKServer[] servers, + string defaultBaseUrl) + { + if (AutoSDKServerConfiguration.ExplicitBaseUri is global::System.Uri explicitBaseUri) + { + return explicitBaseUri; + } + + if (AutoSDKServerConfiguration.SelectedServer is global::Together.AutoSDKServer selectedServer) + { + foreach (var server in servers) + { + if (string.Equals(server.Id, selectedServer.Id, global::System.StringComparison.Ordinal)) + { + return server.Uri; + } + } + } + + if (servers.Length > 0) + { + return servers[0].Uri; + } + + return string.IsNullOrWhiteSpace(defaultBaseUrl) + ? HttpClient.BaseAddress + : new global::System.Uri(defaultBaseUrl, global::System.UriKind.RelativeOrAbsolute); + } } } \ No newline at end of file diff --git a/src/libs/Together/Generated/Together.VideoClient.CreateVideo.g.cs b/src/libs/Together/Generated/Together.VideoClient.CreateVideo.g.cs index a4e6779f..b45c3141 100644 --- a/src/libs/Together/Generated/Together.VideoClient.CreateVideo.g.cs +++ b/src/libs/Together/Generated/Together.VideoClient.CreateVideo.g.cs @@ -16,6 +16,7 @@ public partial class VideoClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,6 +48,7 @@ partial void ProcessCreateVideoResponseContent( /// Create a video /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -65,6 +67,43 @@ partial void ProcessCreateVideoResponseContent( public async global::System.Threading.Tasks.Task CreateVideoAsync( global::Together.CreateVideoBody request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreateVideoAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Create video
+ /// Create a video + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.videos.create(
+ /// model="together/video-model",
+ /// prompt="A cartoon of an astronaut riding a horse on the moon"
+ /// )
+ /// print(response.id) + ///
+ public async global::System.Threading.Tasks.Task> CreateVideoAsResponseAsync( + + global::Together.CreateVideoBody request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -81,22 +120,44 @@ partial void ProcessCreateVideoResponseContent( securityRequirements: s_CreateVideoSecurityRequirements, operationName: "CreateVideoAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/videos", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using 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)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/videos", + baseUri: HttpClient.BaseAddress ?? new global::System.Uri("https://api.together.ai/v2", global::System.UriKind.RelativeOrAbsolute)); + var __path = __pathBuilder.ToString(); + __path = global::Together.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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -106,118 +167,303 @@ partial void ProcessCreateVideoResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateVideoRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateVideoRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateVideoResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateVideo", + methodName: "CreateVideoAsync", + pathTemplate: "\"/videos\"", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateVideo", + methodName: "CreateVideoAsync", + pathTemplate: "\"/videos\"", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessCreateVideoResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateVideo", + methodName: "CreateVideoAsync", + pathTemplate: "\"/videos\"", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::Together.VideoJob.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Together.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), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return - await global::Together.VideoJob.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateVideoResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateVideo", + methodName: "CreateVideoAsync", + pathTemplate: "\"/videos\"", + 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); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateVideo", + methodName: "CreateVideoAsync", + pathTemplate: "\"/videos\"", + 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); + ProcessCreateVideoResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.VideoJob.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.VideoJob.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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 video
@@ -267,6 +513,7 @@ partial void ProcessCreateVideoResponseContent( /// /// Media inputs for video generation. The accepted fields depend on the model type (e.g. i2v, r2v, t2v, videoedit). /// + /// 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 CreateVideoAsync( @@ -286,6 +533,7 @@ partial void ProcessCreateVideoResponseContent( string? negativePrompt = default, bool? generateAudio = default, global::Together.VideoMedia? media = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.CreateVideoBody @@ -310,6 +558,7 @@ partial void ProcessCreateVideoResponseContent( return await CreateVideoAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Together/Generated/Together.VideoClient.RetrieveVideo.g.cs b/src/libs/Together/Generated/Together.VideoClient.RetrieveVideo.g.cs index e046bfc2..54dcd22c 100644 --- a/src/libs/Together/Generated/Together.VideoClient.RetrieveVideo.g.cs +++ b/src/libs/Together/Generated/Together.VideoClient.RetrieveVideo.g.cs @@ -14,6 +14,7 @@ public partial class VideoClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,6 +48,7 @@ partial void ProcessRetrieveVideoResponseContent( /// /// Identifier of video from create response. /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -61,6 +63,40 @@ partial void ProcessRetrieveVideoResponseContent( /// public async global::System.Threading.Tasks.Task RetrieveVideoAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await RetrieveVideoAsResponseAsync( + id: id, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Fetch video metadata
+ /// Fetch video metadata + ///
+ /// + /// Identifier of video from create response. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.videos.retrieve(video_id)
+ /// print(response.id) + ///
+ public async global::System.Threading.Tasks.Task> RetrieveVideoAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -75,22 +111,44 @@ partial void ProcessRetrieveVideoResponseContent( securityRequirements: s_RetrieveVideoSecurityRequirements, operationName: "RetrieveVideoAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/videos/{id}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/videos/{id}", + baseUri: HttpClient.BaseAddress ?? new global::System.Uri("https://api.together.ai/v2", global::System.UriKind.RelativeOrAbsolute)); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -100,178 +158,363 @@ partial void ProcessRetrieveVideoResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareRetrieveVideoRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareRetrieveVideoRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id!); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessRetrieveVideoResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // - if ((int)__response.StatusCode == 400) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveVideo", + methodName: "RetrieveVideoAsync", + pathTemplate: "$\"/videos/{id}\"", + httpMethod: "GET", + 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 { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveVideo", + methodName: "RetrieveVideoAsync", + pathTemplate: "$\"/videos/{id}\"", + httpMethod: "GET", + 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; + } - throw new global::Together.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // - if ((int)__response.StatusCode == 404) - { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; - try - { - if (ReadResponseAsString) - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else + + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveVideo", + methodName: "RetrieveVideoAsync", + pathTemplate: "$\"/videos/{id}\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_404 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessRetrieveVideoResponseContent( + response: __response); + ProcessRetrieveVideoResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.VideoJob.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveVideo", + methodName: "RetrieveVideoAsync", + pathTemplate: "$\"/videos/{id}\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveVideo", + methodName: "RetrieveVideoAsync", + pathTemplate: "$\"/videos/{id}\"", + httpMethod: "GET", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } - return - await global::Together.VideoJob.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + throw new global::Together.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Together.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessRetrieveVideoResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.VideoJob.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.VideoJob.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.VideoClient.g.cs b/src/libs/Together/Generated/Together.VideoClient.g.cs index 23350b24..77db8e38 100644 --- a/src/libs/Together/Generated/Together.VideoClient.g.cs +++ b/src/libs/Together/Generated/Together.VideoClient.g.cs @@ -12,7 +12,7 @@ public sealed partial class VideoClient : global::Together.IVideoClient, global: /// /// /// - public const string DefaultBaseUrl = "https://api.together.xyz/v1"; + public const string DefaultBaseUrl = "https://api.together.ai/v2"; private bool _disposeHttpClient = true; @@ -30,6 +30,12 @@ public sealed partial class VideoClient : global::Together.IVideoClient, global: #if DEBUG = true; #endif + + /// + public global::Together.AutoSDKClientOptions Options { get; } + + + internal global::Together.AutoSDKServerConfiguration AutoSDKServerConfiguration { get; set; } = new global::Together.AutoSDKServerConfiguration(); /// /// /// @@ -49,13 +55,62 @@ public VideoClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the VideoClient with explicit options but no base URL override. + /// Skips passing baseUri so the default base URL from the OpenAPI spec applies. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public VideoClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, + bool disposeHttpClient = true) : this( + httpClient, + baseUri: null, + authorizations, + options, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the VideoClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public VideoClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Together.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; + AutoSDKServerConfiguration.ExplicitBaseUri = baseUri ?? httpClient?.BaseAddress; + Initialized(HttpClient); } diff --git a/src/libs/Together/Generated/Together.VoicesClient.FetchVoices.g.cs b/src/libs/Together/Generated/Together.VoicesClient.FetchVoices.g.cs index a65f6305..ed830b6b 100644 --- a/src/libs/Together/Generated/Together.VoicesClient.FetchVoices.g.cs +++ b/src/libs/Together/Generated/Together.VoicesClient.FetchVoices.g.cs @@ -14,6 +14,7 @@ public partial class VoicesClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -42,6 +43,7 @@ partial void ProcessFetchVoicesResponseContent( /// Fetch available voices for each model
/// Fetch available voices for each model ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// /// @@ -55,6 +57,35 @@ partial void ProcessFetchVoicesResponseContent( /// print(response.data) /// public async global::System.Threading.Tasks.Task FetchVoicesAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await FetchVoicesAsResponseAsync( + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Fetch available voices for each model
+ /// Fetch available voices for each model + ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + /// + /// # Docs for v1 can be found by changing the above selector ^
+ /// from together import Together
+ /// import os
+ /// client = Together(
+ /// api_key=os.environ.get("TOGETHER_API_KEY"),
+ /// )
+ /// response = client.audio.voices.list()
+ /// print(response.data) + ///
+ public async global::System.Threading.Tasks.Task> FetchVoicesAsResponseAsync( + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -68,22 +99,44 @@ partial void ProcessFetchVoicesResponseContent( securityRequirements: s_FetchVoicesSecurityRequirements, operationName: "FetchVoicesAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: "/voices", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: "/voices", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -93,111 +146,296 @@ partial void ProcessFetchVoicesResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareFetchVoicesRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareFetchVoicesRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessFetchVoicesResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "FetchVoices", + methodName: "FetchVoicesAsync", + pathTemplate: "\"/voices\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "FetchVoices", + methodName: "FetchVoicesAsync", + pathTemplate: "\"/voices\"", + httpMethod: "GET", + 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; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessFetchVoicesResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "FetchVoices", + methodName: "FetchVoicesAsync", + pathTemplate: "\"/voices\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::Together.ListVoicesResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Together.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), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return - await global::Together.ListVoicesResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessFetchVoicesResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "FetchVoices", + methodName: "FetchVoicesAsync", + pathTemplate: "\"/voices\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "FetchVoices", + methodName: "FetchVoicesAsync", + pathTemplate: "\"/voices\"", + httpMethod: "GET", + 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); + ProcessFetchVoicesResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.ListVoicesResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.ListVoicesResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.VoicesClient.g.cs b/src/libs/Together/Generated/Together.VoicesClient.g.cs index 43cbe1f3..7ca9b1a4 100644 --- a/src/libs/Together/Generated/Together.VoicesClient.g.cs +++ b/src/libs/Together/Generated/Together.VoicesClient.g.cs @@ -12,7 +12,7 @@ public sealed partial class VoicesClient : global::Together.IVoicesClient, globa /// /// /// - public const string DefaultBaseUrl = "https://api.together.xyz/v1"; + public const string DefaultBaseUrl = "https://api.together.ai/v1"; private bool _disposeHttpClient = true; @@ -30,6 +30,12 @@ public sealed partial class VoicesClient : global::Together.IVoicesClient, globa #if DEBUG = true; #endif + + /// + public global::Together.AutoSDKClientOptions Options { get; } + + + internal global::Together.AutoSDKServerConfiguration AutoSDKServerConfiguration { get; set; } = new global::Together.AutoSDKServerConfiguration(); /// /// /// @@ -49,13 +55,62 @@ public VoicesClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the VoicesClient with explicit options but no base URL override. + /// Skips passing baseUri so the default base URL from the OpenAPI spec applies. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public VoicesClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, + bool disposeHttpClient = true) : this( + httpClient, + baseUri: null, + authorizations, + options, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the VoicesClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public VoicesClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Together.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; + AutoSDKServerConfiguration.ExplicitBaseUri = baseUri ?? httpClient?.BaseAddress; + Initialized(HttpClient); } diff --git a/src/libs/Together/Generated/Together.VolumesClient.DeleteDeploymentsStorageVolumesById.g.cs b/src/libs/Together/Generated/Together.VolumesClient.DeleteDeploymentsStorageVolumesById.g.cs index 1431087a..7479d6d3 100644 --- a/src/libs/Together/Generated/Together.VolumesClient.DeleteDeploymentsStorageVolumesById.g.cs +++ b/src/libs/Together/Generated/Together.VolumesClient.DeleteDeploymentsStorageVolumesById.g.cs @@ -14,6 +14,7 @@ public partial class VolumesClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,10 +48,35 @@ partial void ProcessDeleteDeploymentsStorageVolumesByIdResponseContent( /// /// Volume ID or name /// + /// 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 DeleteDeploymentsStorageVolumesByIdAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await DeleteDeploymentsStorageVolumesByIdAsResponseAsync( + id: id, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Delete a volume
+ /// Delete an existing volume + ///
+ /// + /// Volume ID or name + /// + /// 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> DeleteDeploymentsStorageVolumesByIdAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -65,22 +91,44 @@ partial void ProcessDeleteDeploymentsStorageVolumesByIdResponseContent( securityRequirements: s_DeleteDeploymentsStorageVolumesByIdSecurityRequirements, operationName: "DeleteDeploymentsStorageVolumesByIdAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/deployments/storage/volumes/{id}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Delete, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/deployments/storage/volumes/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Delete, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -90,184 +138,369 @@ partial void ProcessDeleteDeploymentsStorageVolumesByIdResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteDeploymentsStorageVolumesByIdRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteDeploymentsStorageVolumesByIdRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id!); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteDeploymentsStorageVolumesByIdResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Volume not found - if ((int)__response.StatusCode == 404) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; - string? __value_404 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "deleteDeploymentsStorageVolumesById", + methodName: "DeleteDeploymentsStorageVolumesByIdAsync", + pathTemplate: "$\"/deployments/storage/volumes/{id}\"", + httpMethod: "DELETE", + 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 { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "deleteDeploymentsStorageVolumesById", + methodName: "DeleteDeploymentsStorageVolumesByIdAsync", + pathTemplate: "$\"/deployments/storage/volumes/{id}\"", + httpMethod: "DELETE", + 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; + } - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_404 = __ex; - } - throw new global::Together.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Internal server error - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - string? __value_500 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "deleteDeploymentsStorageVolumesById", + methodName: "DeleteDeploymentsStorageVolumesByIdAsync", + pathTemplate: "$\"/deployments/storage/volumes/{id}\"", + httpMethod: "DELETE", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_500 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessDeleteDeploymentsStorageVolumesByIdResponseContent( + response: __response); + ProcessDeleteDeploymentsStorageVolumesByIdResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return __content; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "deleteDeploymentsStorageVolumesById", + methodName: "DeleteDeploymentsStorageVolumesByIdAsync", + pathTemplate: "$\"/deployments/storage/volumes/{id}\"", + httpMethod: "DELETE", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "deleteDeploymentsStorageVolumesById", + methodName: "DeleteDeploymentsStorageVolumesByIdAsync", + pathTemplate: "$\"/deployments/storage/volumes/{id}\"", + httpMethod: "DELETE", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Volume not found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + string? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return __content; - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Together.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal server error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + string? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessDeleteDeploymentsStorageVolumesByIdResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __content); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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(); + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __content); + } + 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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.VolumesClient.EditDeploymentsStorageVolumesById.g.cs b/src/libs/Together/Generated/Together.VolumesClient.EditDeploymentsStorageVolumesById.g.cs index 6769bd80..1103d0b9 100644 --- a/src/libs/Together/Generated/Together.VolumesClient.EditDeploymentsStorageVolumesById.g.cs +++ b/src/libs/Together/Generated/Together.VolumesClient.EditDeploymentsStorageVolumesById.g.cs @@ -14,6 +14,7 @@ public partial class VolumesClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -50,12 +51,42 @@ partial void ProcessEditDeploymentsStorageVolumesByIdResponseContent( /// Volume ID or name. /// /// + /// 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 EditDeploymentsStorageVolumesByIdAsync( string id, global::Together.UpdateVolumeRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await EditDeploymentsStorageVolumesByIdAsResponseAsync( + id: id, + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Update a volume
+ /// Update an existing volume's configuration or contents + ///
+ /// + /// Volume ID or name. + /// + /// + /// 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> EditDeploymentsStorageVolumesByIdAsResponseAsync( + string id, + + global::Together.UpdateVolumeRequest request, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -73,22 +104,44 @@ partial void ProcessEditDeploymentsStorageVolumesByIdResponseContent( securityRequirements: s_EditDeploymentsStorageVolumesByIdSecurityRequirements, operationName: "EditDeploymentsStorageVolumesByIdAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/deployments/storage/volumes/{id}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: new global::System.Net.Http.HttpMethod("PATCH"), - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/deployments/storage/volumes/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: new global::System.Net.Http.HttpMethod("PATCH"), + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -98,233 +151,418 @@ partial void ProcessEditDeploymentsStorageVolumesByIdResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareEditDeploymentsStorageVolumesByIdRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareEditDeploymentsStorageVolumesByIdRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id!, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessEditDeploymentsStorageVolumesByIdResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Invalid request - if ((int)__response.StatusCode == 400) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - string? __value_400 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "editDeploymentsStorageVolumesById", + methodName: "EditDeploymentsStorageVolumesByIdAsync", + pathTemplate: "$\"/deployments/storage/volumes/{id}\"", + httpMethod: "PATCH", + 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 { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "editDeploymentsStorageVolumesById", + methodName: "EditDeploymentsStorageVolumesByIdAsync", + pathTemplate: "$\"/deployments/storage/volumes/{id}\"", + httpMethod: "PATCH", + 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; + } - __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } - throw new global::Together.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseObject = __value_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Volume not found - if ((int)__response.StatusCode == 404) - { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; - string? __value_404 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "editDeploymentsStorageVolumesById", + methodName: "EditDeploymentsStorageVolumesByIdAsync", + pathTemplate: "$\"/deployments/storage/volumes/{id}\"", + httpMethod: "PATCH", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_404 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Internal server error - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - string? __value_500 = null; - try + using (__response) { - if (ReadResponseAsString) - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); - } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); - } + ProcessResponse( + client: HttpClient, + response: __response); + ProcessEditDeploymentsStorageVolumesByIdResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "editDeploymentsStorageVolumesById", + methodName: "EditDeploymentsStorageVolumesByIdAsync", + pathTemplate: "$\"/deployments/storage/volumes/{id}\"", + httpMethod: "PATCH", + 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); } - catch (global::System.Exception __ex) + else { - __exception_500 = __ex; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "editDeploymentsStorageVolumesById", + methodName: "EditDeploymentsStorageVolumesByIdAsync", + pathTemplate: "$\"/deployments/storage/volumes/{id}\"", + httpMethod: "PATCH", + 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); } + // Invalid request + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + string? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) - { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } + __value_400 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_400, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + throw new global::Together.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseObject = __value_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Volume not found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + string? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessEditDeploymentsStorageVolumesByIdResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } - try - { - __response.EnsureSuccessStatusCode(); + throw new global::Together.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal server error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + string? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - global::Together.VolumeResponseItem.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - } - catch (global::System.Exception __ex) - { - throw new global::Together.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 - cancellationToken -#endif - ).ConfigureAwait(false); + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } - return - await global::Together.VolumeResponseItem.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessEditDeploymentsStorageVolumesByIdResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.VolumeResponseItem.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.VolumeResponseItem.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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(); + } } /// /// Update a volume
@@ -334,7 +572,7 @@ partial void ProcessEditDeploymentsStorageVolumesByIdResponseContent( /// Volume ID or name. /// /// - /// Content specifies the new content that will be preloaded to this volume + /// Content specifies the new content to preload to this volume. /// /// /// Name is the new unique identifier for the volume within the project @@ -342,6 +580,7 @@ partial void ProcessEditDeploymentsStorageVolumesByIdResponseContent( /// /// Type is the new volume type (currently only "readOnly" is supported) /// + /// 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 EditDeploymentsStorageVolumesByIdAsync( @@ -349,6 +588,7 @@ partial void ProcessEditDeploymentsStorageVolumesByIdResponseContent( global::Together.VolumeContentRequest? content = default, string? name = default, global::Together.VolumeType? type = default, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Together.UpdateVolumeRequest @@ -361,6 +601,7 @@ partial void ProcessEditDeploymentsStorageVolumesByIdResponseContent( return await EditDeploymentsStorageVolumesByIdAsync( id: id, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Together/Generated/Together.VolumesClient.GetDeploymentsStorageVolumesById.g.cs b/src/libs/Together/Generated/Together.VolumesClient.GetDeploymentsStorageVolumesById.g.cs index 5475603a..8cbe2138 100644 --- a/src/libs/Together/Generated/Together.VolumesClient.GetDeploymentsStorageVolumesById.g.cs +++ b/src/libs/Together/Generated/Together.VolumesClient.GetDeploymentsStorageVolumesById.g.cs @@ -14,6 +14,7 @@ public partial class VolumesClient { new global::Together.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "BearerAuth", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,10 +48,35 @@ partial void ProcessGetDeploymentsStorageVolumesByIdResponseContent( /// /// Volume ID or name /// + /// 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 GetDeploymentsStorageVolumesByIdAsync( string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetDeploymentsStorageVolumesByIdAsResponseAsync( + id: id, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get a volume by ID or name
+ /// Retrieve details of a specific volume by its ID or name + ///
+ /// + /// Volume ID or name + /// + /// 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> GetDeploymentsStorageVolumesByIdAsResponseAsync( + string id, + global::Together.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -65,22 +91,44 @@ partial void ProcessGetDeploymentsStorageVolumesByIdResponseContent( securityRequirements: s_GetDeploymentsStorageVolumesByIdSecurityRequirements, operationName: "GetDeploymentsStorageVolumesByIdAsync"); - var __pathBuilder = new global::Together.PathBuilder( - path: $"/deployments/storage/volumes/{id}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Together.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Together.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Together.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Together.PathBuilder( + path: $"/deployments/storage/volumes/{id}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Together.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + 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; + __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 == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -90,188 +138,373 @@ partial void ProcessGetDeploymentsStorageVolumesByIdResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Together.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetDeploymentsStorageVolumesByIdRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - id: id); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetDeploymentsStorageVolumesByIdRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id!); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetDeploymentsStorageVolumesByIdResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Volume not found - if ((int)__response.StatusCode == 404) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; - string? __value_404 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Together.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsStorageVolumesById", + methodName: "GetDeploymentsStorageVolumesByIdAsync", + pathTemplate: "$\"/deployments/storage/volumes/{id}\"", + httpMethod: "GET", + 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 { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsStorageVolumesById", + methodName: "GetDeploymentsStorageVolumesByIdAsync", + pathTemplate: "$\"/deployments/storage/volumes/{id}\"", + httpMethod: "GET", + 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; + } - __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_404 = __ex; - } - throw new global::Together.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseObject = __value_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Internal server error - if ((int)__response.StatusCode == 500) - { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - string? __value_500 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Together.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + var __retryDelay = global::Together.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsStorageVolumesById", + methodName: "GetDeploymentsStorageVolumesByIdAsync", + pathTemplate: "$\"/deployments/storage/volumes/{id}\"", + httpMethod: "GET", + 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::Together.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - else - { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); - } + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_500 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Together.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessGetDeploymentsStorageVolumesByIdResponseContent( + response: __response); + ProcessGetDeploymentsStorageVolumesByIdResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Together.VolumeResponseItem.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Together.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsStorageVolumesById", + methodName: "GetDeploymentsStorageVolumesByIdAsync", + pathTemplate: "$\"/deployments/storage/volumes/{id}\"", + httpMethod: "GET", + 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); } - catch (global::System.Exception __ex) + else { - throw new global::Together.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), - }; + await global::Together.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Together.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "getDeploymentsStorageVolumesById", + methodName: "GetDeploymentsStorageVolumesByIdAsync", + pathTemplate: "$\"/deployments/storage/volumes/{id}\"", + httpMethod: "GET", + 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 - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Volume not found + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + string? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Together.VolumeResponseItem.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 - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_404 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_404, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Together.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseObject = __value_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Internal server error + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + string? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_500, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Together.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + 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); + ProcessGetDeploymentsStorageVolumesByIdResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Together.VolumeResponseItem.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Together.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::Together.VolumeResponseItem.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Together.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Together.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::Together.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), + }; + } + } - throw new global::Together.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/Together/Generated/Together.VolumesClient.g.cs b/src/libs/Together/Generated/Together.VolumesClient.g.cs index 4d63aa5b..b06419d4 100644 --- a/src/libs/Together/Generated/Together.VolumesClient.g.cs +++ b/src/libs/Together/Generated/Together.VolumesClient.g.cs @@ -12,7 +12,7 @@ public sealed partial class VolumesClient : global::Together.IVolumesClient, glo /// /// /// - public const string DefaultBaseUrl = "https://api.together.xyz/v1"; + public const string DefaultBaseUrl = "https://api.together.ai/v1"; private bool _disposeHttpClient = true; @@ -30,6 +30,12 @@ public sealed partial class VolumesClient : global::Together.IVolumesClient, glo #if DEBUG = true; #endif + + /// + public global::Together.AutoSDKClientOptions Options { get; } + + + internal global::Together.AutoSDKServerConfiguration AutoSDKServerConfiguration { get; set; } = new global::Together.AutoSDKServerConfiguration(); /// /// /// @@ -49,13 +55,62 @@ public VolumesClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the VolumesClient with explicit options but no base URL override. + /// Skips passing baseUri so the default base URL from the OpenAPI spec applies. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public VolumesClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, + bool disposeHttpClient = true) : this( + httpClient, + baseUri: null, + authorizations, + options, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the VolumesClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public VolumesClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Together.AutoSDKClientOptions? options, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Together.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; + AutoSDKServerConfiguration.ExplicitBaseUri = baseUri ?? httpClient?.BaseAddress; + Initialized(HttpClient); } diff --git a/src/libs/Together/Generated/autosdk.generated-examples.json b/src/libs/Together/Generated/autosdk.generated-examples.json new file mode 100644 index 00000000..23a3152c --- /dev/null +++ b/src/libs/Together/Generated/autosdk.generated-examples.json @@ -0,0 +1,48 @@ +{ + "Examples": [ + { + "Order": 1, + "Title": "List all endpoints", + "Slug": "listendpoints", + "Description": "Returns a list of all endpoints associated with your account. You can filter the results by type (dedicated or serverless).", + "Language": "csharp", + "Code": "using var client = new TogetherClient(apiKey);\nvar response = await client.Endpoints.ListEndpointsAsync();\n\n// Example response:\n// {\n// \u0022object\u0022: \u0022list\u0022,\n// \u0022data\u0022: [\n// {\n// \u0022object\u0022: \u0022endpoint\u0022,\n// \u0022id\u0022: \u0022endpoint-5c0c20db-62fe-4f41-8ffc-d9e4ea1a264e\u0022,\n// \u0022name\u0022: \u0022allenai/OLMo-7B\u0022,\n// \u0022model\u0022: \u0022allenai/OLMo-7B\u0022,\n// \u0022type\u0022: \u0022serverless\u0022,\n// \u0022owner\u0022: \u0022together\u0022,\n// \u0022state\u0022: \u0022STARTED\u0022,\n// \u0022created_at\u0022: \u00222024-02-28T21:34:35.444Z\u0022\n// }\n// ]\n// }", + "Format": "sdk", + "OperationId": "listEndpoints", + "Setup": "This example assumes \u0060using Together;\u0060 is in scope and \u0060apiKey\u0060 contains the required credential." + }, + { + "Order": 2, + "Title": "Create job", + "Slug": "create-job", + "Description": "Create a fine-tuning job with the provided model and training data.", + "Language": "http", + "Code": "### Create job\nPOST {{host}}/fine-tunes\nAuthorization: Bearer {{token}}\nContent-Type: application/json\nAccept: application/json\n\n{\n \u0022training_file\u0022: \u0022string\u0022,\n \u0022validation_file\u0022: \u0022string\u0022,\n \u0022packing\u0022: true,\n \u0022max_seq_length\u0022: 0,\n \u0022model\u0022: \u0022string\u0022,\n \u0022n_epochs\u0022: 1,\n \u0022n_checkpoints\u0022: 1,\n \u0022n_evals\u0022: 0,\n \u0022batch_size\u0022: \u0022max\u0022,\n \u0022gradient_accumulation_steps\u0022: 1,\n \u0022learning_rate\u0022: 0.00001,\n \u0022lr_scheduler\u0022: {\n \u0022lr_scheduler_type\u0022: \u0022linear\u0022,\n \u0022lr_scheduler_args\u0022: {\n \u0022min_lr_ratio\u0022: 0.0\n }\n },\n \u0022warmup_ratio\u0022: 0.0,\n \u0022max_grad_norm\u0022: 1.0,\n \u0022weight_decay\u0022: 0.0,\n \u0022random_seed\u0022: 0,\n \u0022suffix\u0022: \u0022string\u0022,\n \u0022wandb_api_key\u0022: \u0022string\u0022,\n \u0022wandb_base_url\u0022: \u0022string\u0022,\n \u0022wandb_project_name\u0022: \u0022string\u0022,\n \u0022wandb_name\u0022: \u0022string\u0022,\n \u0022wandb_entity\u0022: \u0022string\u0022,\n \u0022train_on_inputs\u0022: \u0022auto\u0022,\n \u0022training_method\u0022: {\n \u0022method\u0022: \u0022sft\u0022,\n \u0022train_on_inputs\u0022: \u0022auto\u0022\n },\n \u0022training_type\u0022: \u0022openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464\u0022,\n \u0022multimodal_params\u0022: {\n \u0022train_vision\u0022: true\n },\n \u0022from_checkpoint\u0022: \u0022string\u0022,\n \u0022from_hf_model\u0022: \u0022string\u0022,\n \u0022hf_model_revision\u0022: \u0022string\u0022,\n \u0022hf_api_token\u0022: \u0022string\u0022,\n \u0022hf_output_repo_name\u0022: \u0022string\u0022\n}\n\n## Responses\n# 200\n# Description: Fine-tuning job initiated successfully\n# Content-Type: application/json", + "Format": "http", + "OperationId": "createFineTunes", + "Setup": null + }, + { + "Order": 3, + "Title": "Cancel job", + "Slug": "cancel-job", + "Description": "Cancel a currently running fine-tuning job. Returns a FinetuneResponseTruncated object.", + "Language": "http", + "Code": "### Cancel job\nPOST {{host}}/fine-tunes/{{id}}/cancel\nAuthorization: Bearer {{token}}\nAccept: application/json\n\n## Responses\n# 200\n# Description: Successfully cancelled the fine-tuning job.\n# Content-Type: application/json\n# 400\n# Description: Invalid request parameters.\n# 404\n# Description: Fine-tune ID not found.", + "Format": "http", + "OperationId": "createFineTunesByIdCancel", + "Setup": null + }, + { + "Order": 4, + "Title": "Get metrics", + "Slug": "get-metrics", + "Description": "Retrieves recorded training metrics for a fine-tuning job in chronological order. All query parameters are optional: omit them to retrieve all metrics.", + "Language": "http", + "Code": "### Get metrics\nGET {{host}}/fine-tunes/{{id}}/metrics?global_step_from=0\u0026global_step_to=500\u0026logged_at_from=2024-01-01T00:00:00Z\u0026logged_at_to=2024-01-01T12:00:00Z\u0026resolution=100\nAuthorization: Bearer {{token}}\nAccept: application/json\n\n## Responses\n# 200\n# Description: List of metrics snapshots in chronological order.\n# Content-Type: application/json\n# 400\n# Description: Invalid request: bad JSON body or missing job ID.\n# 404\n# Description: Fine-tune job not found.\n# 500\n# Description: Internal server error: failed to retrieve metrics.", + "Format": "http", + "OperationId": "getFineTunesByIdMetrics", + "Setup": null + } + ] +} \ No newline at end of file diff --git a/src/libs/Together/openapi.yaml b/src/libs/Together/openapi.yaml index 7c3f6669..85dc7a85 100644 --- a/src/libs/Together/openapi.yaml +++ b/src/libs/Together/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.1.0 info: title: Together APIs - description: The Together REST API. Please see https://docs.together.ai for more details. + description: The Together REST API. See https://docs.together.ai for more details. version: '2.0.0' termsOfService: https://www.together.ai/terms-of-service contact: @@ -11,7 +11,7 @@ info: name: MIT url: https://github.com/togethercomputer/openapi/blob/main/LICENSE servers: - - url: https://api.together.xyz/v1 + - url: https://api.together.ai/v1 security: - bearerAuth: [] paths: @@ -78,7 +78,7 @@ paths: deployment = client.beta.jig.deploy( name="my-deployment", gpu_type="h100-80gb", - image="registry.together.xyz/proj_abcdefg1234567890/my-image:latest" + image="registry.together.ai/proj_abcdefg1234567890/my-image:latest" ) print(deployment) - lang: TypeScript @@ -90,7 +90,7 @@ paths: const deployment = await client.beta.jig.deploy({ name: "my-deployment", gpu_type: "h100-80gb", - image: "registry.together.xyz/proj_abcdefg1234567890/my-image:latest" + image: "registry.together.ai/proj_abcdefg1234567890/my-image:latest" }); console.log(deployment); - lang: JavaScript @@ -102,7 +102,7 @@ paths: const deployment = await client.beta.jig.deploy({ name: "my-deployment", gpu_type: "h100-80gb", - image: "registry.together.xyz/proj_abcdefg1234567890/my-image:latest" + image: "registry.together.ai/proj_abcdefg1234567890/my-image:latest" }); console.log(deployment); requestBody: @@ -1018,7 +1018,7 @@ paths: summary: Fetch video metadata description: Fetch video metadata servers: - - url: https://api.together.xyz/v2 + - url: https://api.together.ai/v2 operationId: retrieveVideo x-codeSamples: - lang: Python @@ -1097,7 +1097,7 @@ paths: description: Create a video operationId: createVideo servers: - - url: https://api.together.xyz/v2 + - url: https://api.together.ai/v2 x-codeSamples: - lang: Python label: Together AI SDK (v2) @@ -1260,7 +1260,7 @@ paths: - lang: Shell label: cURL source: | - curl -X POST "https://api.together.xyz/v1/chat/completions" \ + curl -X POST "https://api.together.ai/v1/chat/completions" \ -H "Authorization: Bearer $TOGETHER_API_KEY" \ -H "Content-Type: application/json" \ -d '{ @@ -1400,7 +1400,7 @@ paths: - lang: Shell label: cURL source: | - curl -X POST "https://api.together.xyz/v1/completions" \ + curl -X POST "https://api.together.ai/v1/completions" \ -H "Authorization: Bearer $TOGETHER_API_KEY" \ -H "Content-Type: application/json" \ -d '{ @@ -1533,7 +1533,7 @@ paths: - lang: Shell label: cURL source: | - curl -X POST "https://api.together.xyz/v1/embeddings" \ + curl -X POST "https://api.together.ai/v1/embeddings" \ -H "Authorization: Bearer $TOGETHER_API_KEY" \ -H "Content-Type: application/json" \ -d '{ @@ -1656,7 +1656,7 @@ paths: - lang: Shell label: cURL source: | - curl "https://api.together.xyz/v1/models" \ + curl "https://api.together.ai/v1/models" \ -H "Authorization: Bearer $TOGETHER_API_KEY" \ -H "Content-Type: application/json" operationId: models @@ -1775,7 +1775,7 @@ paths: - lang: Shell label: cURL source: | - curl -X POST "https://api.together.xyz/v1/models" \ + curl -X POST "https://api.together.ai/v1/models" \ -H "Authorization: Bearer $TOGETHER_API_KEY" \ -H "Content-Type: application/json" \ -d '{ @@ -1907,7 +1907,7 @@ paths: - lang: Shell label: cURL source: | - curl -X POST "https://api.together.xyz/v1/images/generations" \ + curl -X POST "https://api.together.ai/v1/images/generations" \ -H "Authorization: Bearer $TOGETHER_API_KEY" \ -H "Content-Type: application/json" \ -d '{ @@ -1931,9 +1931,7 @@ paths: model: type: string description: > - The model to use for image generation.
-
- [See all of Together AI's image models](https://docs.together.ai/docs/serverless-models#image-models) + The model to use for image generation.

[See all of Together AI's image models](https://docs.together.ai/docs/serverless-models#image-models) example: black-forest-labs/FLUX.1-schnell anyOf: - type: string @@ -2079,7 +2077,7 @@ paths: - lang: Shell label: cURL source: | - curl "https://api.together.xyz/v1/files" \ + curl "https://api.together.ai/v1/files" \ -H "Authorization: Bearer $TOGETHER_API_KEY" \ -H "Content-Type: application/json" responses: @@ -2149,7 +2147,7 @@ paths: - lang: Shell label: cURL source: | - curl "https://api.together.xyz/v1/files/ID" \ + curl "https://api.together.ai/v1/files/ID" \ -H "Authorization: Bearer $TOGETHER_API_KEY" \ -H "Content-Type: application/json" parameters: @@ -2225,7 +2223,7 @@ paths: - lang: Shell label: cURL source: | - curl -X "DELETE" "https://api.together.xyz/v1/files/file-id" \ + curl -X "DELETE" "https://api.together.ai/v1/files/file-id" \ -H "Authorization: Bearer $TOGETHER_API_KEY" parameters: - name: id @@ -2303,7 +2301,7 @@ paths: - lang: Shell label: cURL source: | - curl "https://api.together.xyz/v1/files/file-id/content" \ + curl "https://api.together.ai/v1/files/file-id/content" \ -H "Authorization: Bearer $TOGETHER_API_KEY" \ -H "Content-Type: application/json" parameters: @@ -2393,7 +2391,7 @@ paths: - lang: Shell label: cURL source: | - curl "https://api.together.xyz/v1/files/upload" \ + curl "https://api.together.ai/v1/files/upload" \ -H "Authorization: Bearer $TOGETHER_API_KEY" \ -F "file=@/path/to/data.jsonl" \ -F "file_name=data.jsonl" \ @@ -2518,7 +2516,7 @@ paths: - lang: Shell label: cURL source: | - curl -X POST "https://api.together.xyz/v1/fine-tunes" \ + curl -X POST "https://api.together.ai/v1/fine-tunes" \ -H "Authorization: Bearer $TOGETHER_API_KEY" \ -H "Content-Type: application/json" \ -d '{ @@ -2545,6 +2543,9 @@ paths: type: boolean default: true description: Whether to use sequence packing for training. + max_seq_length: + type: integer + description: Maximum sequence length to use for training. If not specified, the maximum allowed for the model and training method will be used. model: type: string description: Name of the base model to run fine-tune job on @@ -2568,6 +2569,10 @@ paths: - max default: 'max' description: Number of training examples processed together (larger batches use more memory but may train faster). Defaults to "max". We use training optimizations like packing, so the effective batch size may be different than the value you set. + gradient_accumulation_steps: + type: integer + default: 1 + description: Number of steps to accumulate gradients before performing a weight update. Effectively increases the batch size without requiring more memory. For example, with batch_size=4 and gradient_accumulation_steps=8, the effective batch size is 32. learning_rate: type: number format: float @@ -2597,11 +2602,11 @@ paths: type: integer nullable: true description: > - Random seed for reproducible training. When set, the same seed produces the same run (e.g. data shuffle, init). - If omitted or null, the server applies its default seed (e.g. 42). + Random seed for reproducible training. When set, the same seed produces the same run (e.g. data shuffle, init). If omitted or null, the server applies its default seed (e.g. 42). suffix: type: string - description: Suffix that will be added to your fine-tuned model name + maxLength: 64 + description: Suffix to add to your fine-tuned model name. Must be at most 64 characters long. wandb_api_key: type: string description: Integration key for tracking experiments and model metrics on W&B platform @@ -2610,7 +2615,7 @@ paths: description: The base URL of a dedicated Weights & Biases instance. wandb_project_name: type: string - description: The Weights & Biases project for your run. If not specified, will use `together` as the project name. + description: The Weights & Biases project for your run. If not specified, uses `together` as the project name. wandb_name: type: string description: The Weights & Biases name for your run. @@ -2625,7 +2630,7 @@ paths: - auto type: boolean default: auto - description: Whether to mask the user messages in conversational data or prompts in instruction data. + description: Whether to mask user messages in conversational data or prompts in instruction data. deprecated: true training_method: type: object @@ -2640,12 +2645,12 @@ paths: anyOf: - $ref: '#/components/schemas/FullTrainingType' - $ref: '#/components/schemas/LoRATrainingType' - description: The training type to use. If not provided, the job will default to LoRA training type. + description: The training type to use. Defaults to LoRA if not provided. multimodal_params: $ref: '#/components/schemas/MultimodalParams' from_checkpoint: type: string - description: The checkpoint identifier to continue training from a previous fine-tuning job. Format is `{$JOB_ID}` or `{$OUTPUT_MODEL_NAME}` or `{$JOB_ID}:{$STEP}` or `{$OUTPUT_MODEL_NAME}:{$STEP}`. The step value is optional; without it, the final checkpoint will be used. + description: The checkpoint identifier to continue training from a previous fine-tuning job. Format is `{$JOB_ID}` or `{$OUTPUT_MODEL_NAME}` or `{$JOB_ID}:{$STEP}` or `{$OUTPUT_MODEL_NAME}:{$STEP}`. The step value is optional; without it, uses the final checkpoint. from_hf_model: type: string description: The Hugging Face Hub repo to start training from. Should be as close as possible to the base model (specified by the `model` argument) in terms of architecture and size. @@ -2730,7 +2735,7 @@ paths: - lang: Shell label: cURL source: | - curl "https://api.together.xyz/v1/fine-tunes" \ + curl "https://api.together.ai/v1/fine-tunes" \ -H "Authorization: Bearer $TOGETHER_API_KEY" \ -H "Content-Type: application/json" responses: @@ -2784,10 +2789,10 @@ paths: oneOf: - $ref: '#/components/schemas/FullTrainingType' - $ref: '#/components/schemas/LoRATrainingType' - description: The training type to use. If not provided, the job will default to LoRA training type. + description: The training type to use. Defaults to LoRA if not provided. from_checkpoint: type: string - description: The checkpoint identifier to continue training from a previous fine-tuning job. Format is `{$JOB_ID}` or `{$OUTPUT_MODEL_NAME}` or `{$JOB_ID}:{$STEP}` or `{$OUTPUT_MODEL_NAME}:{$STEP}`. The step value is optional; without it, the final checkpoint will be used. + description: The checkpoint identifier to continue training from a previous fine-tuning job. Format is `{$JOB_ID}` or `{$OUTPUT_MODEL_NAME}` or `{$JOB_ID}:{$STEP}` or `{$OUTPUT_MODEL_NAME}:{$STEP}`. The step value is optional; without it, uses the final checkpoint. responses: '500': description: Internal Server Error @@ -2807,11 +2812,11 @@ paths: description: The price of the fine-tuning job allowed_to_proceed: type: boolean - description: Whether the user is allowed to proceed with the fine-tuning job + description: Whether you are allowed to proceed with the fine-tuning job. example: true user_limit: type: number - description: The user's credit limit in dollars + description: Your credit limit in dollars. estimated_train_token_count: type: number description: The estimated number of tokens to be trained @@ -2878,7 +2883,7 @@ paths: - lang: Shell label: cURL source: | - curl "https://api.together.xyz/v1/fine-tunes/ft-id" \ + curl "https://api.together.ai/v1/fine-tunes/ft-id" \ -H "Authorization: Bearer $TOGETHER_API_KEY" \ -H "Content-Type: application/json" parameters: @@ -2954,7 +2959,7 @@ paths: - lang: Shell label: cURL source: | - curl -X "DELETE" "https://api.together.xyz/v1/fine-tunes/ft-id?force=false" \ + curl -X "DELETE" "https://api.together.ai/v1/fine-tunes/ft-id?force=false" \ -H "Authorization: Bearer $TOGETHER_API_KEY" \ -H "Content-Type: application/json" parameters: @@ -3051,7 +3056,7 @@ paths: - lang: Shell label: cURL source: | - curl "https://api.together.xyz/v1/fine-tunes/ft-id/events" \ + curl "https://api.together.ai/v1/fine-tunes/ft-id/events" \ -H "Authorization: Bearer $TOGETHER_API_KEY" \ -H "Content-Type: application/json" parameters: @@ -3128,7 +3133,7 @@ paths: - lang: Shell label: cURL source: | - curl "https://api.together.xyz/v1/fine-tunes/ft-id/checkpoints" \ + curl "https://api.together.ai/v1/fine-tunes/ft-id/checkpoints" \ -H "Authorization: Bearer $TOGETHER_API_KEY" \ -H "Content-Type: application/json" parameters: @@ -3214,7 +3219,7 @@ paths: - lang: Shell label: cURL source: | - curl "https://api.together.xyz/v1/finetune/download?ft_id=ft-id&checkpoint=merged" + curl "https://api.together.ai/v1/finetune/download?ft_id=ft-id&checkpoint=merged" -H "Authorization: Bearer $TOGETHER_API_KEY" \ -H "Content-Type: application/json" parameters: @@ -3311,7 +3316,7 @@ paths: - lang: Shell label: cURL source: | - curl -X POST "https://api.together.xyz/v1/fine-tunes/ft-id/cancel" \ + curl -X POST "https://api.together.ai/v1/fine-tunes/ft-id/cancel" \ -H "Authorization: Bearer $TOGETHER_API_KEY" \ -H "Content-Type: application/json" parameters: @@ -3332,6 +3337,95 @@ paths: description: Invalid request parameters. '404': description: Fine-tune ID not found. + /fine-tunes/{id}/metrics: + get: + tags: ['Fine-tuning'] + summary: Get metrics + description: > + Retrieves recorded training metrics for a fine-tuning job in chronological order. + All query parameters are optional: omit them to retrieve all metrics. + x-codeSamples: + - lang: Shell + label: cURL + source: | + curl -X GET "https://api.together.ai/v1/fine-tunes/ft-id/metrics?global_step_from=0&global_step_to=500" \ + -H "Authorization: Bearer $TOGETHER_API_KEY" + parameters: + - name: id + in: path + required: true + schema: + description: Fine-tune job ID. A string that starts with `ft-`. + type: string + - name: global_step_from + in: query + required: false + schema: + type: integer + format: int64 + description: Return only metrics with global_step >= this value. + example: 0 + - name: global_step_to + in: query + required: false + schema: + type: integer + format: int64 + description: Return only metrics with global_step <= this value. + example: 500 + - name: logged_at_from + in: query + required: false + schema: + type: string + format: date-time + description: Return only metrics logged at or after this ISO-8601 timestamp. + example: "2024-01-01T00:00:00Z" + - name: logged_at_to + in: query + required: false + schema: + type: string + format: date-time + description: Return only metrics logged at or before this ISO-8601 timestamp. + example: "2024-01-01T12:00:00Z" + - name: resolution + in: query + required: false + schema: + type: integer + format: int64 + description: Number of (uniformly sampled) train metrics to return. + example: 100 + responses: + '200': + description: List of metrics snapshots in chronological order. + content: + application/json: + schema: + type: object + properties: + metrics: + type: array + items: + type: object + additionalProperties: + type: number + description: A flat dictionary of scalar metric values. + example: + metrics: + - train/loss: 0.5 + train/learning_rate: 0.0001 + train/global_step: 7 + - train/loss: 0.45 + train/learning_rate: 0.00009 + train/global_step: 14 + '400': + description: 'Invalid request: bad JSON body or missing job ID.' + '404': + description: Fine-tune job not found. + '500': + description: 'Internal server error: failed to retrieve metrics.' /fine-tunes/models/supported: get: tags: ['Fine-tuning'] @@ -3341,7 +3435,7 @@ paths: - lang: Shell label: cURL (list all) source: | - curl "https://api.together.xyz/v1/fine-tunes/models/supported" \ + curl "https://api.together.ai/v1/fine-tunes/models/supported" \ -H "Authorization: Bearer $TOGETHER_API_KEY" responses: '200': @@ -3367,7 +3461,7 @@ paths: - lang: Shell label: cURL source: | - curl "https://api.together.xyz/v1/fine-tunes/models/limits?model_name=meta-llama/Meta-Llama-3.1-8B-Instruct-Reference" \ + curl "https://api.together.ai/v1/fine-tunes/models/limits?model_name=meta-llama/Meta-Llama-3.1-8B-Instruct-Reference" \ -H "Authorization: Bearer $TOGETHER_API_KEY" parameters: - in: query @@ -3555,7 +3649,7 @@ paths: - lang: Shell label: cURL source: | - curl -X POST "https://api.together.xyz/v1/rerank" \ + curl -X POST "https://api.together.ai/v1/rerank" \ -H "Authorization: Bearer $TOGETHER_API_KEY" \ -H "Content-Type: application/json" \ -d '{ @@ -3721,7 +3815,7 @@ paths: - lang: Shell label: cURL source: | - curl -X POST "https://api.together.xyz/v1/audio/speech" \ + curl -X POST "https://api.together.ai/v1/audio/speech" \ -H "Authorization: Bearer $TOGETHER_API_KEY" \ -H "Content-Type: application/json" \ -d '{ @@ -3777,15 +3871,18 @@ paths: **Connection Setup:** - Protocol: WebSocket (wss://) - Authentication: Pass API key as Bearer token in Authorization header - - Parameters: Sent as query parameters (model, voice, max_partial_length) + - Parameters: Sent as query parameters (model, voice, max_partial_length, language) **Client Events:** - - `tts_session.updated`: Update session parameters like voice + - `tts_session.updated`: Update session parameters like voice. The `session` object also accepts an `extra_params` field for additional model-specific parameters that fine-tune speech generation behavior, such as `pronunciation_dict` (a list of pronunciation rules for specific characters or symbols, where each entry uses the format `"/"` (e.g., `["omg/oh my god"]`) to override how the model pronounces matching tokens). ```json { "type": "tts_session.updated", "session": { - "voice": "tara" + "voice": "tara", + "extra_params": { + "pronunciation_dict": ["omg/oh my god"] + } } } ``` @@ -3866,9 +3963,9 @@ paths: - The `input_text_buffer.commit` event is received **Audio Format:** - - Format: WAV (PCM s16le) + - Format: Raw PCM (s16le, mono) - Sample Rate: 24000 Hz - - Encoding: Base64 + - Encoding: Base64 (per delta event) - Delivered via `conversation.item.audio_output.delta` events **Error Codes:** @@ -3890,7 +3987,7 @@ paths: async def generate_speech(): api_key = os.environ.get("TOGETHER_API_KEY") - url = "wss://api.together.ai/v1/audio/speech/websocket?model=hexgrad/Kokoro-82M&voice=tara" + url = "wss://api.together.ai/v1/audio/speech/websocket?model=hexgrad/Kokoro-82M&voice=af_heart" headers = { "Authorization": f"Bearer {api_key}" @@ -3900,6 +3997,9 @@ paths: # Wait for session created session_msg = await ws.recv() session_data = json.loads(session_msg) + if session_data.get("type") != "session.created": + print(f"Failed to start session: {session_data}") + return print(f"Session created: {session_data['session']['id']}") # Send text for TTS @@ -3941,10 +4041,10 @@ paths: print(f"Error: {error.get('message')}") break - # Save the audio to a file - with open("output.wav", "wb") as f: + # Save the raw PCM samples to a file + with open("output.pcm", "wb") as f: f.write(audio_data) - print("Audio saved to output.wav") + print("Audio saved to output.pcm") # Run send and receive concurrently await asyncio.gather(send_text(), receive_audio()) @@ -3957,7 +4057,7 @@ paths: import fs from 'fs'; const apiKey = process.env.TOGETHER_API_KEY; - const url = 'wss://api.together.ai/v1/audio/speech/websocket?model=hexgrad/Kokoro-82M&voice=tara'; + const url = 'wss://api.together.ai/v1/audio/speech/websocket?model=hexgrad/Kokoro-82M&voice=af_heart'; const ws = new WebSocket(url, { headers: { @@ -4017,11 +4117,11 @@ paths: }); ws.on('close', () => { - // Save the audio to a file + // Save the raw PCM samples to a file if (audioData.length > 0) { const completeAudio = Buffer.concat(audioData); - fs.writeFileSync('output.wav', completeAudio); - console.log('Audio saved to output.wav'); + fs.writeFileSync('output.pcm', completeAudio); + console.log('Audio saved to output.pcm'); } }); @@ -4056,6 +4156,15 @@ paths: description: | Maximum number of characters in partial text before forcing TTS generation even without a sentence ending. Helps reduce latency for long text without punctuation. + - in: query + name: language + required: false + schema: + type: string + default: en + example: en + description: | + Language or locale of input text. Accepts ISO 639-1 language codes (e.g., `en`, `fr`, `es`, `zh`) as well as locale codes for region-specific variants. Locale codes must be lowercase (e.g., `zh-hk` for Cantonese). Can also be set via `tts_session.updated` event. responses: '101': description: | @@ -4159,7 +4268,7 @@ paths: - lang: Shell label: cURL source: | - curl -X POST "https://api.together.xyz/v1/audio/transcriptions" \ + curl -X POST "https://api.together.ai/v1/audio/transcriptions" \ -H "Authorization: Bearer $TOGETHER_API_KEY" \ -F "file=@audio.wav" \ -F "model=openai/whisper-large-v3" @@ -4287,7 +4396,7 @@ paths: - lang: Shell label: cURL source: | - curl -X POST "https://api.together.xyz/v1/audio/translations" \ + curl -X POST "https://api.together.ai/v1/audio/translations" \ -H "Authorization: Bearer $TOGETHER_API_KEY" \ -F "file=@audio.wav" \ -F "model=openai/whisper-large-v3" \ @@ -4327,7 +4436,7 @@ paths: /compute/clusters: get: tags: ['GPUClusterService'] - summary: List all GPU clusters. + summary: List all GPU clusters description: List all GPU clusters. operationId: GPUClusterService_List responses: @@ -4377,7 +4486,7 @@ paths: console.log(response.clusters); post: tags: ['GPUClusterService'] - summary: Create GPU Cluster + summary: Create a GPU cluster description: | Create an Instant Cluster on Together's high-performance GPU clusters. With features like on-demand scaling, long-lived resizable high-bandwidth shared DC-local storage, @@ -4503,7 +4612,7 @@ paths: console.log(cluster); put: tags: ['GPUClusterService'] - summary: Update a GPU Cluster. + summary: Update a GPU cluster description: Update the configuration of an existing GPU cluster. operationId: GPUClusterService_Update parameters: @@ -4527,45 +4636,45 @@ paths: schema: $ref: '#/components/schemas/GPUClusterInfo' x-codeSamples: - - lang: Python - label: Together AI SDK (v2) - source: | - from together import Together - client = Together() - - cluster = client.beta.clusters.update("cluster_id", cluster_type="KUBERNETES", num_gpus=24) - print(cluster) - - lang: TypeScript - label: Together AI SDK (TypeScript) - source: | - import Together from "together-ai"; - const client = new Together(); - - const cluster = await client.beta.clusters.update({ - cluster_id: "cluster_id", - cluster_type: "kubernetes", - num_gpus: 24, - }) - console.log(cluster) - - lang: JavaScript - label: Together AI SDK (JavaScript) - source: | - import Together from "together-ai"; - const client = new Together(); - - const cluster = await client.beta.clusters.update({ - cluster_id: "cluster_id", - cluster_type: "kubernetes", - num_gpus: 24, - }) - console.log(cluster) - - lang: Shell - label: cURL - source: | - curl -X PUT \ - -H "Authorization Bearer $TOGETHER_API_KEY" \ - --data '{ "cluster_id": "cluster id", "cluster_type": "kubernetes", "num_gpus": 24 }' \ - https://api.together.ai/v1/compute/clusters + - lang: Python + label: Together AI SDK (v2) + source: | + from together import Together + client = Together() + + cluster = client.beta.clusters.update("cluster_id", cluster_type="KUBERNETES", num_gpus=24) + print(cluster) + - lang: TypeScript + label: Together AI SDK (TypeScript) + source: | + import Together from "together-ai"; + const client = new Together(); + + const cluster = await client.beta.clusters.update({ + cluster_id: "cluster_id", + cluster_type: "kubernetes", + num_gpus: 24, + }) + console.log(cluster) + - lang: JavaScript + label: Together AI SDK (JavaScript) + source: | + import Together from "together-ai"; + const client = new Together(); + + const cluster = await client.beta.clusters.update({ + cluster_id: "cluster_id", + cluster_type: "kubernetes", + num_gpus: 24, + }) + console.log(cluster) + - lang: Shell + label: cURL + source: | + curl -X PUT \ + -H "Authorization Bearer $TOGETHER_API_KEY" \ + --data '{ "cluster_id": "cluster id", "cluster_type": "kubernetes", "num_gpus": 24 }' \ + https://api.together.ai/v1/compute/clusters delete: tags: ['GPUClusterService'] summary: Delete GPU cluster by cluster ID @@ -4666,7 +4775,7 @@ paths: /compute/clusters/storage/volumes: get: tags: ['SharedVolumeService'] - summary: List all shared volumes. + summary: List all shared volumes description: List all shared volumes. operationId: SharedVolumeService_List responses: @@ -4709,7 +4818,7 @@ paths: https://api.together.ai/v1/compute/clusters/storages put: tags: ['SharedVolumeService'] - summary: Update a shared volume. + summary: Update a shared volume description: | Update the configuration of an existing shared volume. operationId: SharedVolumeService_Update @@ -4727,49 +4836,49 @@ paths: schema: $ref: '#/components/schemas/GPUClustersSharedVolume' x-codeSamples: - - lang: Python - label: Together AI SDK (v2) - source: | - from together import Together - client = Together() - - volume = client.beta.clusters.storage.update( - volume_id="12345-67890-12345-67890", - size_tib=3 - ) - print(volume) - - lang: TypeScript - label: Together AI SDK (TypeScript) - source: | - import Together from "together-ai"; - const client = new Together(); - - const volume = await client.beta.clusters.storage.update({ - volume_id: "12345-67890-12345-67890", - size_tib: 3 - }); - console.log(volume); - - lang: JavaScript - label: Together AI SDK (JavaScript) - source: | - import Together from "together-ai"; - const client = new Together(); - - const volume = await client.beta.clusters.storage.update({ - volume_id: "12345-67890-12345-67890", - size_tib: 3 - }); - console.log(volume); - - lang: Shell - label: cURL - source: | - curl -X PUT \ - -H "Authorization: Bearer $TOGETHER_API_KEY" \ - --data '{ "volume_id": "12345-67890-12345-67890", "size_tib": 3}' \ - https://api.together.ai/v1/compute/clusters/storage/volumes + - lang: Python + label: Together AI SDK (v2) + source: | + from together import Together + client = Together() + + volume = client.beta.clusters.storage.update( + volume_id="12345-67890-12345-67890", + size_tib=3 + ) + print(volume) + - lang: TypeScript + label: Together AI SDK (TypeScript) + source: | + import Together from "together-ai"; + const client = new Together(); + + const volume = await client.beta.clusters.storage.update({ + volume_id: "12345-67890-12345-67890", + size_tib: 3 + }); + console.log(volume); + - lang: JavaScript + label: Together AI SDK (JavaScript) + source: | + import Together from "together-ai"; + const client = new Together(); + + const volume = await client.beta.clusters.storage.update({ + volume_id: "12345-67890-12345-67890", + size_tib: 3 + }); + console.log(volume); + - lang: Shell + label: cURL + source: | + curl -X PUT \ + -H "Authorization: Bearer $TOGETHER_API_KEY" \ + --data '{ "volume_id": "12345-67890-12345-67890", "size_tib": 3}' \ + https://api.together.ai/v1/compute/clusters/storage/volumes post: tags: ['SharedVolumeService'] - summary: Create a shared volume. + summary: Create a shared volume description: | Instant Clusters supports long-lived, resizable in-DC shared storage with user data persistence. You can dynamically create and attach volumes to your cluster at cluster creation time, and resize as your data grows. @@ -4832,7 +4941,7 @@ paths: /compute/clusters/storage/volumes/{volume_id}: get: tags: ['SharedVolumeService'] - summary: Get shared volume by volume Id. + summary: Get a shared volume by ID description: Retrieve information about a specific shared volume. operationId: SharedVolumeService_Get parameters: @@ -4843,12 +4952,12 @@ paths: description: The ID of the volume to retrieve type: string responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/GPUClustersSharedVolume' + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/GPUClustersSharedVolume' x-codeSamples: - lang: Python label: Together AI SDK (v2) @@ -4882,7 +4991,7 @@ paths: https://api.together.ai/v1/compute/clusters/storage/volumes/${VOLUME_ID} delete: tags: ['SharedVolumeService'] - summary: Delete shared volume by volume id. + summary: Delete a shared volume by ID description: | Delete a shared volume. Note that if this volume is attached to a cluster, deleting will fail. operationId: SharedVolumeService_Delete @@ -4934,7 +5043,7 @@ paths: /clusters/availability-zones: get: tags: ['endpoints'] - summary: List all available availability zones. + summary: List all available availability zones description: List all available availability zones. operationId: availabilityZones responses: @@ -4985,13 +5094,13 @@ paths: - lang: Shell label: cURL source: | - curl "https://api.together.xyz/v1/clusters/availability-zones" \ + curl "https://api.together.ai/v1/clusters/availability-zones" \ -H "Authorization: Bearer $TOGETHER_API_KEY" \ -H "Content-Type: application/json" /endpoints: get: tags: ['Endpoints'] - summary: List all endpoints, can be filtered by type + summary: List all endpoints description: Returns a list of all endpoints associated with your account. You can filter the results by type (dedicated or serverless). x-codeSamples: - lang: Python @@ -5054,7 +5163,7 @@ paths: - lang: Shell label: cURL source: | - curl "https://api.together.xyz/v1/endpoints" \ + curl "https://api.together.ai/v1/endpoints" \ -H "Authorization: Bearer $TOGETHER_API_KEY" \ -H "Content-Type: application/json" operationId: listEndpoints @@ -5126,8 +5235,8 @@ paths: $ref: '#/components/schemas/ErrorData' post: tags: ['Endpoints'] - summary: Create a dedicated endpoint, it will start automatically - description: Creates a new dedicated endpoint for serving models. The endpoint will automatically start after creation. You can deploy any supported model on hardware configurations that meet the model's requirements. + summary: Create a dedicated endpoint + description: Creates a new dedicated endpoint for serving models. The endpoint starts automatically after creation. You can deploy any supported model on hardware configurations that meet the model's requirements. x-codeSamples: - lang: Python label: Together AI SDK (v2) @@ -5209,7 +5318,7 @@ paths: - lang: Shell label: cURL source: | - curl -X POST "https://api.together.xyz/v1/endpoints" \ + curl -X POST "https://api.together.ai/v1/endpoints" \ -H "Authorization: Bearer $TOGETHER_API_KEY" \ -H "Content-Type: application/json" \ -d '{ @@ -5307,7 +5416,7 @@ paths: - lang: Shell label: cURL source: | - curl "https://api.together.xyz/v1/endpoints/endpoint-id" \ + curl "https://api.together.ai/v1/endpoints/endpoint-id" \ -H "Authorization: Bearer $TOGETHER_API_KEY" \ -H "Content-Type: application/json" operationId: getEndpoint @@ -5414,7 +5523,7 @@ paths: - lang: Shell label: cURL source: | - curl -X PATCH "https://api.together.xyz/v1/endpoints/endpoint-id" \ + curl -X PATCH "https://api.together.ai/v1/endpoints/endpoint-id" \ -H "Authorization: Bearer $TOGETHER_API_KEY" \ -H "Content-Type: application/json" \ -d '{ @@ -5452,7 +5561,7 @@ paths: description: New autoscaling configuration for the endpoint inactive_timeout: type: integer - description: The number of minutes of inactivity after which the endpoint will be automatically stopped. Set to 0 to disable automatic timeout. + description: The number of minutes of inactivity after which the endpoint stops automatically. Set to 0 to disable automatic timeout. nullable: true example: 60 responses: @@ -5542,7 +5651,7 @@ paths: - lang: Shell label: cURL source: | - curl -X "DELETE" "https://api.together.xyz/v1/endpoints/endpoint-id" \ + curl -X "DELETE" "https://api.together.ai/v1/endpoints/endpoint-id" \ -H "Authorization: Bearer $TOGETHER_API_KEY" operationId: deleteEndpoint parameters: @@ -5580,9 +5689,7 @@ paths: tags: ['Hardware'] summary: List available hardware configurations description: > - Returns a list of available hardware configurations for deploying models. - When a model parameter is provided, it returns only hardware configurations compatible - with that model, including their current availability status. + Returns a list of available hardware configurations for deploying models. When a model parameter is provided, it returns only hardware configurations compatible with that model, including their current availability status. x-codeSamples: - lang: Python label: Together AI SDK (v2) @@ -5640,7 +5747,7 @@ paths: - lang: Shell label: cURL source: | - curl "https://api.together.xyz/v1/hardware" \ + curl "https://api.together.ai/v1/hardware" \ -H "Authorization: Bearer $TOGETHER_API_KEY" \ -H "Content-Type: application/json" operationId: listHardware @@ -5688,9 +5795,10 @@ paths: /tci/execute: post: tags: ['Code Interpreter'] + summary: Execute code callbacks: {} description: | - Executes the given code snippet and returns the output. Without a session_id, a new session will be created to run the code. If you do pass in a valid session_id, the code will be run in that session. This is useful for running multiple code snippets in the same environment, because dependencies and similar things are persisted + Executes the given code snippet and returns the output. Without a session_id, a new session is created to run the code. If you pass a valid session_id, the code runs in that session. This is useful for running multiple code snippets in the same environment, because dependencies and similar things are persisted between calls to the same session. x-codeSamples: - lang: Python @@ -5759,7 +5867,7 @@ paths: - lang: Shell label: cURL source: | - curl -X POST "https://api.together.xyz/v1/tci/execute" \ + curl -X POST "https://api.together.ai/v1/tci/execute" \ -H "Authorization: Bearer $TOGETHER_API_KEY" \ -H "Content-Type: application/json" \ -d '{ @@ -5784,6 +5892,7 @@ paths: description: Execute Response /tci/sessions: get: + summary: List active sessions tags: ['Code Interpreter'] callbacks: {} description: | @@ -5839,7 +5948,7 @@ paths: - lang: Shell label: cURL source: | - curl "https://api.together.xyz/v1/tci/sessions" \ + curl "https://api.together.ai/v1/tci/sessions" \ -H "Authorization: Bearer $TOGETHER_API_KEY" \ -H "Content-Type: application/json" operationId: sessions/list @@ -5913,7 +6022,7 @@ paths: - lang: Shell label: cURL source: | - curl "https://api.together.xyz/v1/batches" \ + curl "https://api.together.ai/v1/batches" \ -H "Authorization: Bearer $TOGETHER_API_KEY" \ -H "Content-Type: application/json" security: @@ -6004,13 +6113,45 @@ paths: - lang: Shell label: cURL source: | - curl -X POST "https://api.together.xyz/v1/batches" \ + curl -X POST "https://api.together.ai/v1/batches" \ -H "Authorization: Bearer $TOGETHER_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "endpoint": "/v1/chat/completions", "input_file_id": "file-id" }' + - lang: Python + label: Audio transcriptions (Python) + source: | + # Audio transcription batches use the /v1/audio/transcriptions endpoint. + # Each line in the uploaded JSONL must include `"method": "FILE"` so the + # worker dispatches the request as multipart/form-data. Example line: + # {"custom_id": "transcription-1", "method": "FILE", + # "body": {"file": "https://example.com/audio.wav", + # "model": "openai/whisper-large-v3"}} + from together import Together + import os + + client = Together( + api_key=os.environ.get("TOGETHER_API_KEY"), + ) + + batch = client.batches.create( + input_file_id="file_id", + endpoint="/v1/audio/transcriptions", + ) + + print(batch.job) + - lang: Shell + label: Audio transcriptions (cURL) + source: | + curl -X POST "https://api.together.ai/v1/batches" \ + -H "Authorization: Bearer $TOGETHER_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "endpoint": "/v1/audio/transcriptions", + "input_file_id": "file-id" + }' security: - bearerAuth: [] requestBody: @@ -6111,7 +6252,7 @@ paths: - lang: Shell label: cURL source: | - curl "https://api.together.xyz/v1/batches/ID" \ + curl "https://api.together.ai/v1/batches/ID" \ -H "Authorization: Bearer $TOGETHER_API_KEY" \ -H "Content-Type: application/json" security: @@ -6221,7 +6362,7 @@ paths: - lang: Shell label: cURL source: | - curl -X POST "https://api.together.xyz/v1/batches/ID/cancel" \ + curl -X POST "https://api.together.ai/v1/batches/ID/cancel" \ -H "Authorization: Bearer $TOGETHER_API_KEY" \ -H "Content-Type: application/json" security: @@ -6745,12 +6886,60 @@ paths: "audio": "" } ``` - - `input_audio_buffer.commit`: Signal end of audio stream + - `input_audio_buffer.commit`: Signal end of audio stream. When VAD is enabled, the server automatically detects speech boundaries and emits `completed` events. When VAD is disabled, you must send `commit` to trigger transcription of the buffered audio. ```json { "type": "input_audio_buffer.commit" } ``` + - `transcription_session.updated`: Update session configuration, including Voice Activity Detection (VAD) parameters. Send this after receiving `session.created`. Can also be sent at any time during the session to change VAD settings. + ```json + { + "type": "transcription_session.updated", + "session": { + "turn_detection": { + "type": "server_vad", + "threshold": 0.3, + "min_silence_duration_ms": 500, + "min_speech_duration_ms": 250, + "max_speech_duration_s": 5.0, + "speech_pad_ms": 250 + } + } + } + ``` + To disable VAD entirely (manual commit mode), set `turn_detection` to `null`: + ```json + { + "type": "transcription_session.updated", + "session": { + "turn_detection": null + } + } + ``` + + **Voice Activity Detection (VAD)** + + VAD controls how the server automatically detects speech segments in the audio stream. When enabled (the default), the server uses Silero VAD to identify speech regions and emits transcription events as each segment completes. When disabled, you must manually call `input_audio_buffer.commit` to trigger transcription. + + VAD can be configured in two ways: + 1. **Query parameters** at connection time: `turn_detection=server_vad&threshold=0.3&min_silence_duration_ms=500` + 2. **Session message** after connection: Send `transcription_session.updated` with a `turn_detection` object (see above) + + To disable VAD at connection time, use `turn_detection=none` as a query parameter. + + **VAD Parameters:** + + All parameters are optional. Omitted fields use their defaults. + + | Parameter | Type | Default | Description | + |-----------|------|---------|-------------| + | `type` | string | `server_vad` | VAD mode. Use `server_vad` to enable, or set `turn_detection` to `null` to disable. | + | `threshold` | float | `0.3` | Speech probability threshold (0.0–1.0). Audio frames with probability above this value are classified as speech. Lower values detect more speech but may increase false positives. For low-SNR audio (e.g., 8kHz phone calls), values of 0.01–0.2 may work better. | + | `min_silence_duration_ms` | int | `500` | Minimum silence duration in milliseconds before ending a speech segment. Higher values merge nearby speech bursts into single segments. For phone calls with mid-sentence pauses, 2000–5000ms prevents over-segmentation. | + | `min_speech_duration_ms` | int | `250` | Minimum speech segment duration in milliseconds. Segments shorter than this are discarded. Filters out brief noise bursts or clicks. | + | `max_speech_duration_s` | float | `5.0` | Maximum speech segment duration in seconds. Segments longer than this are force-split at the longest internal silence gap. Useful for continuous speech without natural pauses. | + | `speech_pad_ms` | int | `250` | Padding in milliseconds added to the start and end of each detected segment. Prevents clipping speech edges. When padding would cause adjacent segments to overlap, the gap is split at the midpoint instead. | **Server Events:** - `session.created`: Initial session confirmation (sent first) @@ -6765,6 +6954,22 @@ paths: } } ``` + - `transcription_session.updated`: Confirms session configuration was applied. Sent in response to a client `transcription_session.updated` message. + ```json + { + "type": "transcription_session.updated", + "session": { + "turn_detection": { + "type": "server_vad", + "threshold": 0.3, + "min_silence_duration_ms": 500, + "min_speech_duration_ms": 250, + "max_speech_duration_s": 5.0, + "speech_pad_ms": 250 + } + } + } + ``` - `conversation.item.input_audio_transcription.delta`: Partial transcription results ```json { @@ -7696,9 +7901,10 @@ components: type: string description: Generation stops when any of these strings is produced seed: - type: string - format: int64 - example: 42 + oneOf: + - type: string + - type: integer + example: "42" description: Random seed for reproducibility RL.InputChunk: type: object @@ -7970,9 +8176,10 @@ components: properties: step: description: Step number - type: string - format: uint64 - example: 100 + oneOf: + - type: string + - type: integer + example: "100" RL.SampleResult: type: object description: Result of a sample operation @@ -8006,12 +8213,13 @@ components: tokens: type: array example: - - 123 - - 456 - - 789 + - "123" + - "456" + - "789" items: - type: string - format: int64 + oneOf: + - type: string + - type: integer description: Generated token IDs logprobs: type: array @@ -8112,8 +8320,21 @@ components: description: Checkpoint ID to resume from type: string example: 123e4567-e89b-12d3-a456-426614174000 + type: + $ref: '#/components/schemas/RL.SessionType' + default: SESSION_TYPE_TRAINER_AND_GENERATOR + example: SESSION_TYPE_TRAINER_ONLY + description: Type of the training session. Defaults to TRAINER_AND_GENERATOR when unspecified. TRAINER_ONLY provisions only the trainer and rejects sample requests. lora_config: $ref: '#/components/schemas/RL.LoraConfig' + RL.SessionType: + description: Type of a training session. TRAINER_AND_GENERATOR provisions both trainer and generator; TRAINER_ONLY provisions only the trainer and rejects generator-dependent operations such as sample. + default: SESSION_TYPE_UNSPECIFIED + type: string + enum: + - SESSION_TYPE_UNSPECIFIED + - SESSION_TYPE_TRAINER_AND_GENERATOR + - SESSION_TYPE_TRAINER_ONLY RL.TrainingSessionStatus: description: Status of the training session default: TRAINING_SESSION_STATUS_UNSPECIFIED @@ -8139,6 +8360,7 @@ components: - created_at - updated_at - lora_config + - type properties: id: type: string @@ -8170,9 +8392,10 @@ components: description: Checkpoint ID this session was resumed from step: description: Current training step - type: string - format: uint64 - example: 100 + oneOf: + - type: string + - type: integer + example: "100" default: "0" created_at: type: string @@ -8186,6 +8409,10 @@ components: description: Timestamp when the training session was last updated lora_config: $ref: '#/components/schemas/RL.LoraConfig' + type: + $ref: '#/components/schemas/RL.SessionType' + example: SESSION_TYPE_TRAINER_AND_GENERATOR + description: Type of the training session. TRAINER_AND_GENERATOR provisions both trainer and generator; TRAINER_ONLY provisions only the trainer and rejects generator-dependent operations such as sample. RL.TrainingSessionsListResponse: type: object description: Paginated list of training sessions @@ -8221,6 +8448,11 @@ components: example: 0.05 default: "0.05" description: Dropout of the LoRA adapter + enable: + type: boolean + example: true + default: "true" + description: Whether to enable LoRA fine-tuning. If false, full fine-tuning is used. RL.AdamWOptimizerParams: description: AdamW optimizer parameters type: object @@ -8293,9 +8525,10 @@ components: example: 123e4567-e89b-12d3-a456-426614174000 description: Unique identifier for the checkpoint step: - type: string - format: uint64 - example: 42 + oneOf: + - type: string + - type: integer + example: "42" description: Training step at time of save created_at: type: string @@ -8334,9 +8567,10 @@ components: example: 123e4567-e89b-12d3-a456-426614174000 description: Unique identifier for the checkpoint step: - type: string - format: uint64 - example: 42 + oneOf: + - type: string + - type: integer + example: "42" description: Training step at time of save created_at: type: string @@ -8399,9 +8633,10 @@ components: example: "https://..." description: Presigned URL for downloading the file size: - type: string - format: int64 - example: 123456789 + oneOf: + - type: string + - type: integer + example: "123456789" description: File size in bytes RL.CheckpointDownloadResponse: type: object @@ -8454,61 +8689,94 @@ components: - gpu_type - num_gpus - cluster_name - - driver_version + - cuda_version + - nvidia_driver_version - billing_type type: object properties: - cluster_type: - description: Type of cluster to create. - type: string - enum: [KUBERNETES, SLURM] - region: - description: Region to create the GPU cluster in. Usable regions can be found from `client.clusters.list_regions()` - type: string - gpu_type: - description: Type of GPU to use in the cluster - type: string - enum: - - H100_SXM - - H200_SXM - - RTX_6000_PCI - - L40_PCIE - - B200_SXM - - H100_SXM_INF - num_gpus: - description: Number of GPUs to allocate in the cluster. This must be multiple of 8. For example, 8, 16 or 24 - type: integer - cluster_name: - description: Name of the GPU cluster. - type: string - duration_days: - x-stainless-terraform-configurability: computed - description: Duration in days to keep the cluster running. - type: integer - driver_version: - description: NVIDIA driver version to use in the cluster. - type: string - enum: - - CUDA_12_5_555 - - CUDA_12_6_560 - - CUDA_12_6_565 - - CUDA_12_8_570 - shared_volume: - x-stainless-terraform-configurability: computed - $ref: '#/components/schemas/GPUClustersSharedVolumeCreateRequest' - description: Inline configuration to create a shared volume with the cluster creation. - volume_id: - description: ID of an existing volume to use with the cluster creation. - type: string - billing_type: - description: | - RESERVED billing types allow you to specify the duration of the cluster reservation via the duration_days field. - ON_DEMAND billing types will give you ownership of the cluster until you delete it. - x-stainless-terraform-configurability: computed - type: string - enum: - - RESERVED - - ON_DEMAND + cluster_type: + description: Type of cluster to create. + type: string + enum: [KUBERNETES, SLURM] + region: + description: Region to create the GPU cluster in. Usable regions can be found from `client.clusters.list_regions()` + type: string + gpu_type: + description: Type of GPU to use in the cluster + type: string + enum: + - H100_SXM + - H200_SXM + - RTX_6000_PCI + - L40_PCIE + - B200_SXM + - H100_SXM_INF + num_gpus: + description: Number of GPUs to allocate in the cluster. This must be multiple of 8. For example, 8, 16 or 24 + type: integer + cluster_name: + description: Name of the GPU cluster. + type: string + duration_days: + x-stainless-terraform-configurability: computed + description: Duration in days to keep the cluster running. + type: integer + shared_volume: + x-stainless-terraform-configurability: computed + $ref: '#/components/schemas/GPUClustersSharedVolumeCreateRequest' + description: Inline configuration to create a shared volume with the cluster creation. + volume_id: + description: ID of an existing volume to use with the cluster creation. + type: string + billing_type: + description: | + RESERVED billing types allow you to specify the duration of the cluster reservation via the duration_days field. + ON_DEMAND billing types will give you ownership of the cluster until you delete it. + SCHEDULED_CAPACITY billing types allow you to reserve capacity for a scheduled time window. You must specify the reservation_start_time and reservation_end_time with this request. + x-stainless-terraform-configurability: computed + type: string + enum: + - RESERVED + - ON_DEMAND + - SCHEDULED_CAPACITY + gpu_node_failover_enabled: + type: boolean + default: false + description: Whether automated GPU node failover should be enabled for this cluster. By default, it is disabled. + auto_scaled: + type: boolean + default: false + description: Whether GPU cluster should be auto-scaled based on the workload. By default, it is not auto-scaled. + auto_scale_max_gpus: + type: integer + description: Maximum number of GPUs to which the cluster can be auto-scaled up. This field is required if auto_scaled is true. + slurm_shm_size_gib: + type: integer + description: Shared memory size in GiB for Slurm cluster. This field is required if cluster_type is SLURM. + capacity_pool_id: + type: string + description: ID of the capacity pool to use for the cluster. This field is optional and only applicable if the cluster is created from a capacity pool. + reservation_start_time: + type: string + description: Reservation start time of the cluster. This field is required for SCHEDULED billing to specify the reservation start time for the cluster. If not provided, the cluster provisions immediately. + format: date-time + reservation_end_time: + type: string + description: Reservation end time of the cluster. This field is required for SCHEDULED billing to specify the reservation end time for the cluster. + format: date-time + install_traefik: + type: boolean + default: false + description: Whether to install Traefik ingress controller in the cluster. This field is only applicable for Kubernetes clusters and is false by default. + cuda_version: + type: string + description: CUDA version for this cluster. For example, 12.5 + nvidia_driver_version: + type: string + description: Nvidia driver version for this cluster. For example, 550. Only some combination of cuda_version and nvidia_driver_version are supported. + slurm_image: + type: string + description: Custom Slurm image for Slurm clusters. GPUClusterGPUWorkerNode: type: object required: @@ -8539,6 +8807,8 @@ components: type: array items: type: string + instance_id: + type: string GPUClusterInfo: type: object required: @@ -8547,8 +8817,8 @@ components: - region - gpu_type - cluster_name - - duration_hours - - driver_version + - cuda_version + - nvidia_driver_version - volumes - status - control_plane_nodes @@ -8575,12 +8845,6 @@ components: type: string duration_hours: type: integer - driver_version: - enum: - - CUDA_12_5_555 - - CUDA_12_6_560 - - CUDA_12_6_565 - - CUDA_12_8_570 volumes: type: array items: @@ -8611,15 +8875,38 @@ components: type: string num_gpus: type: integer + slurm_shm_size_gib: + type: integer + capacity_pool_id: + type: string + reservation_start_time: + type: string + format: date-time + reservation_end_time: + type: string + format: date-time + install_traefik: + type: boolean + cuda_version: + type: string + nvidia_driver_version: + type: string + created_at: + type: string + format: date-time GPUClusterUpdateRequest: - type: object - properties: - cluster_type: - description: Type of cluster to update. - enum: [KUBERNETES, SLURM] - num_gpus: - description: Number of GPUs to allocate in the cluster. This must be multiple of 8. For example, 8, 16 or 24 - type: integer + type: object + properties: + cluster_type: + description: Type of cluster to update. + enum: [KUBERNETES, SLURM] + num_gpus: + description: Number of GPUs to allocate in the cluster. This must be multiple of 8. For example, 8, 16 or 24 + type: integer + reservation_end_time: + type: string + description: Timestamp at which the cluster should be decommissioned. Only accepted for prepaid clusters. + format: date-time GPUClusterVolume: type: object required: @@ -8641,9 +8928,9 @@ components: required: [clusters] properties: clusters: - type: array - items: - $ref: '#/components/schemas/GPUClusterInfo' + type: array + items: + $ref: '#/components/schemas/GPUClusterInfo' InstanceTypesResponse: type: object properties: @@ -8689,10 +8976,10 @@ components: type: object description: CUDA/NVIDIA driver versions pair available in the region to use in the create cluster request. required: - - cuda_driver_version + - cuda_version - nvidia_driver_version properties: - cuda_driver_version: + cuda_version: description: CUDA driver version. type: string nvidia_driver_version: @@ -8809,9 +9096,7 @@ components: model: type: string description: > - The model to be used for the rerank request.
-
- [See all of Together AI's rerank models](https://docs.together.ai/docs/serverless-models#rerank-models) + The model to be used for the rerank request.

[See all of Together AI's rerank models](https://docs.together.ai/docs/serverless-models#rerank-models) example: Salesforce/Llama-Rank-V1 anyOf: - type: string @@ -8835,22 +9120,10 @@ components: type: string example: Our solar system orbits the Milky Way galaxy at about 515,000 mph example: - - { - 'title': 'Llama', - 'text': 'The llama is a domesticated South American camelid, widely used as a meat and pack animal by Andean cultures since the pre-Columbian era.', - } - - { - 'title': 'Panda', - 'text': 'The giant panda (Ailuropoda melanoleuca), also known as the panda bear or simply panda, is a bear species endemic to China.', - } - - { - 'title': 'Guanaco', - 'text': 'The guanaco is a camelid native to South America, closely related to the llama. Guanacos are one of two wild South American camelids; the other species is the vicuña, which lives at higher elevations.', - } - - { - 'title': 'Wild Bactrian camel', - 'text': 'The wild Bactrian camel (Camelus ferus) is an endangered species of camel endemic to Northwest China and southwestern Mongolia.', - } + - {'title': 'Llama', 'text': 'The llama is a domesticated South American camelid, widely used as a meat and pack animal by Andean cultures since the pre-Columbian era.'} + - {'title': 'Panda', 'text': 'The giant panda (Ailuropoda melanoleuca), also known as the panda bear or simply panda, is a bear species endemic to China.'} + - {'title': 'Guanaco', 'text': 'The guanaco is a camelid native to South America, closely related to the llama. Guanacos are one of two wild South American camelids; the other species is the vicuña, which lives at higher elevations.'} + - {'title': 'Wild Bactrian camel', 'text': 'The wild Bactrian camel (Camelus ferus) is an endangered species of camel endemic to Northwest China and southwestern Mongolia.'} top_n: type: integer description: The number of top results to return. @@ -8906,30 +9179,11 @@ components: type: string nullable: true example: - - { - 'index': 0, - 'relevance_score': 0.29980177813003117, - 'document': - { - 'text': '{"title":"Llama","text":"The llama is a domesticated South American camelid, widely used as a meat and pack animal by Andean cultures since the pre-Columbian era."}', - }, - } - - { - 'index': 2, - 'relevance_score': 0.2752447527354349, - 'document': - { - 'text': '{"title":"Guanaco","text":"The guanaco is a camelid native to South America, closely related to the llama. Guanacos are one of two wild South American camelids; the other species is the vicuña, which lives at higher elevations."}', - }, - } + - {'index': 0, 'relevance_score': 0.29980177813003117, 'document': {'text': '{"title":"Llama","text":"The llama is a domesticated South American camelid, widely used as a meat and pack animal by Andean cultures since the pre-Columbian era."}'}} + - {'index': 2, 'relevance_score': 0.2752447527354349, 'document': {'text': '{"title":"Guanaco","text":"The guanaco is a camelid native to South America, closely related to the llama. Guanacos are one of two wild South American camelids; the other species is the vicuña, which lives at higher elevations."}'}} usage: $ref: '#/components/schemas/UsageData' - example: - { - 'prompt_tokens': 1837, - 'completion_tokens': 0, - 'total_tokens': 1837, - } + example: {'prompt_tokens': 1837, 'completion_tokens': 0, 'total_tokens': 1837} ErrorData: type: object @@ -9055,9 +9309,7 @@ components: model: type: string description: > - The name of the model to query.
-
- [See all of Together AI's chat models](https://docs.together.ai/docs/serverless-models#chat-models) + The name of the model to query.

[See all of Together AI's chat models](https://docs.together.ai/docs/serverless-models#chat-models) example: mistralai/Mixtral-8x7B-Instruct-v0.1 anyOf: - type: string @@ -9072,7 +9324,7 @@ components: description: The maximum number of tokens to generate. stop: type: array - description: A list of string sequences that will truncate (stop) inference text output. For example, "" will stop generation as soon as the model generates the given token. + description: A list of string sequences that truncate (stop) inference text output. For example, "" stops generation as soon as the model generates the given token. items: type: string temperature: @@ -9098,10 +9350,10 @@ components: type: integer minimum: 0 maximum: 20 - description: An integer between 0 and 20 of the top k tokens to return log probabilities for at each generation step, instead of just the sampled token. Log probabilities help assess model confidence in token predictions. + description: An integer between 0 and 20 of the top k tokens to return log probabilities for at each generation step, instead of only the sampled token. Log probabilities help assess model confidence in token predictions. echo: type: boolean - description: If true, the response will contain the prompt. Can be used with `logprobs` to return prompt logprobs. + description: If true, the response contains the prompt. Can be used with `logprobs` to return prompt logprobs. n: type: integer description: The number of completions to generate for each prompt. @@ -9134,7 +9386,7 @@ components: type: number format: float description: Adjusts the likelihood of specific tokens appearing in the generated output. - example: { '1024': -10.5, '105': 21.4 } + example: {'1024': -10.5, '105': 21.4} seed: type: integer description: Seed value for reproducibility. @@ -9342,15 +9594,13 @@ components: model: type: string description: > - The name of the model to query.
-
- [See all of Together AI's chat models](https://docs.together.ai/docs/serverless-models#chat-models) + The name of the model to query.

[See all of Together AI's chat models](https://docs.together.ai/docs/serverless-models#chat-models) max_tokens: type: integer description: The maximum number of tokens to generate. stop: type: array - description: A list of string sequences that will truncate (stop) inference text output. For example, "" will stop generation as soon as the model generates the given token. + description: A list of string sequences that truncate (stop) inference text output. For example, "" stops generation as soon as the model generates the given token. items: type: string temperature: @@ -9369,7 +9619,7 @@ components: type: string enum: ['truncate', 'error'] default: 'error' - description: Defined the behavior of the API when max_tokens exceed the maximum context length of the model. When set to 'error', API will return 400 with appropriate error message. When set to 'truncate', override the max_tokens with maximum context length of the model. + description: Defines the behavior of the API when max_tokens exceed the maximum context length of the model. When set to 'error', the API returns 400 with an appropriate error message. When set to 'truncate', overrides max_tokens with the maximum context length of the model. repetition_penalty: type: number description: A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition. @@ -9380,10 +9630,10 @@ components: type: integer minimum: 0 maximum: 20 - description: An integer between 0 and 20 of the top k tokens to return log probabilities for at each generation step, instead of just the sampled token. Log probabilities help assess model confidence in token predictions. + description: An integer between 0 and 20 of the top k tokens to return log probabilities for at each generation step, instead of only the sampled token. Log probabilities help assess model confidence in token predictions. echo: type: boolean - description: If true, the response will contain the prompt. Can be used with `logprobs` to return prompt logprobs. + description: If true, the response contains the prompt. Can be used with `logprobs` to return prompt logprobs. n: type: integer description: The number of completions to generate for each prompt. @@ -9407,7 +9657,7 @@ components: type: number format: float description: Adjusts the likelihood of specific tokens appearing in the generated output. - example: { '1024': -10.5, '105': 21.4 } + example: {'1024': -10.5, '105': 21.4} seed: type: integer description: Seed value for reproducibility. @@ -9434,7 +9684,7 @@ components: ensures the message the model generates is valid JSON. Using `json_schema` is preferred for models that support it. discriminator: - propertyName: type + propertyName: type anyOf: - $ref: '#/components/schemas/ResponseFormatText' - $ref: '#/components/schemas/ResponseFormatJsonSchema' @@ -9871,13 +10121,7 @@ components: properties: model: description: > - The name of the model to query.
-
- [See all of Together AI's chat models](https://docs.together.ai/docs/serverless-models#audio-models) - The current supported tts models are: - - cartesia/sonic - - hexgrad/Kokoro-82M - - canopylabs/orpheus-3b-0.1-ft + The name of the model to query.

[See all of Together AI's chat models](https://docs.together.ai/docs/serverless-models#audio-models) The current supported tts models are: - cartesia/sonic - hexgrad/Kokoro-82M - canopylabs/orpheus-3b-0.1-ft example: canopylabs/orpheus-3b-0.1-ft anyOf: - type: string @@ -9891,12 +10135,7 @@ components: description: Input text to generate the audio for voice: description: > - The voice to use for generating the audio. - The voices supported are different for each model. For eg - for canopylabs/orpheus-3b-0.1-ft, one of the voices supported is tara, for hexgrad/Kokoro-82M, one of the voices supported is af_alloy and for cartesia/sonic, one of the voices supported is "friendly sidekick". -
-
- You can view the voices supported for each model using the /v1/voices endpoint sending the model name as the query parameter. - [View all supported voices here](https://docs.together.ai/docs/text-to-speech#supported-voices). + The voice to use for generating the audio. The voices supported are different for each model. For eg - for canopylabs/orpheus-3b-0.1-ft, one of the voices supported is tara, for hexgrad/Kokoro-82M, one of the voices supported is af_alloy and for cartesia/sonic, one of the voices supported is "friendly sidekick".

You can view the voices supported for each model using the /v1/voices endpoint sending the model name as the query parameter. [View all supported voices here](https://docs.together.ai/docs/text-to-speech#supported-voices).

`hexgrad/Kokoro-82M` additionally supports voice mixing, where two or more voices are combined into a single blended voice by joining their names with `+` (e.g. `af_bella+af_heart`). Optional per-voice weights can be provided in parentheses (e.g. `af_bella(2)+af_heart(1)`). Other models require a single voice name. type: string response_format: type: string @@ -9908,27 +10147,13 @@ components: - raw language: type: string - description: Language of input text. + description: | + Language or locale of input text. Accepts ISO 639-1 language codes (e.g., `en`, `fr`, `es`, `zh`) as well as locale codes for region-specific variants. Locale codes must be lowercase (e.g., `zh-hk` for Cantonese). default: en - enum: - - en - - de - - fr - - es - - hi - - it - - ja - - ko - - nl - - pl - - pt - - ru - - sv - - tr - - zh + example: en response_encoding: type: string - description: Audio encoding of response + description: Audio encoding of response. Only applicable when response_format is raw or pcm. Cartesia models respect this parameter and support all values. Orpheus, Kokoro, and Minimax models always return pcm_s16le regardless of this setting. default: pcm_f32le enum: - pcm_f32le @@ -9938,7 +10163,7 @@ components: sample_rate: type: integer default: 44100 - description: Sampling rate to use for the output audio. The default sampling rate for canopylabs/orpheus-3b-0.1-ft and hexgrad/Kokoro-82M is 24000 and for cartesia/sonic is 44100. + description: Sampling rate in Hz for the output audio. Cartesia and Minimax models respect this parameter. Orpheus and Kokoro models always output at 24000 Hz regardless of this setting. bit_rate: type: integer description: Bitrate of the MP3 audio output in bits per second. Only applicable when response_format is mp3. Higher values produce better audio quality at larger file sizes. Default is 128000. Currently supported on Cartesia models. @@ -9953,6 +10178,16 @@ components: type: boolean default: false description: 'If true, output is streamed for several characters at a time instead of waiting for the full response. The stream terminates with `data: [DONE]`. If false, return the encoded audio as octet stream' + extra_params: + type: object + description: Additional model-specific parameters that fine-tune speech generation behavior. + properties: + pronunciation_dict: + type: array + items: + type: string + description: A list of pronunciation rules for specific characters or symbols. Each entry uses the format `"/"` (e.g., `["omg/oh my god"]`) to override how the model pronounces matching tokens. + example: ["omg/oh my god"] AudioTranscriptionRequest: type: object @@ -9963,7 +10198,7 @@ components: oneOf: - $ref: '#/components/schemas/AudioFileBinary' - $ref: '#/components/schemas/AudioFileUrl' - description: Audio file upload or public HTTP/HTTPS URL. Supported formats .wav, .mp3, .m4a, .webm, .flac. + description: Audio file upload or public HTTP/HTTPS URL. Supported formats .wav, .mp3, .m4a, .webm, .flac, .ogg, .opus, .aac. model: type: string description: Model to use for transcription @@ -9977,7 +10212,11 @@ components: example: en prompt: type: string - description: Optional text to bias decoding. + description: >- + Optional text to bias decoding. Supported only on Whisper-family + models (e.g. `openai/whisper-large-v3`). Other STT models + (e.g. `nvidia/parakeet-tdt-0.6b-v3`) accept the field for API + compatibility but ignore it. response_format: type: string description: The format of the response @@ -10013,14 +10252,7 @@ components: diarize: type: boolean description: > - Whether to enable speaker diarization. When enabled, you will get the speaker id for each word in the transcription. - In the response, in the words array, you will get the speaker id for each word. - In addition, we also return the speaker_segments array which contains the speaker id for each speaker segment along with the start and end time of the segment along with all the words in the segment. -
-
- For eg - - ... - "speaker_segments": [ + Whether to enable speaker diarization. When enabled, you will get the speaker id for each word in the transcription. In the response, in the words array, you will get the speaker id for each word. In addition, we also return the speaker_segments array which contains the speaker id for each speaker segment along with the start and end time of the segment along with all the words in the segment.

For eg - ... "speaker_segments": [ "speaker_id": "SPEAKER_00", "start": 0, "end": 30.02, @@ -10059,19 +10291,11 @@ components: AudioTranscriptionVerboseJsonResponse: type: object required: - - task - language - duration - text - segments properties: - task: - type: string - description: The task performed - enum: - - transcribe - - translate - example: transcribe language: type: string description: The language of the audio @@ -10205,7 +10429,7 @@ components: - type: string format: uri description: Public HTTP/HTTPS URL to audio file - description: Audio file upload or public HTTP/HTTPS URL. Supported formats .wav, .mp3, .m4a, .webm, .flac. + description: Audio file upload or public HTTP/HTTPS URL. Supported formats .wav, .mp3, .m4a, .webm, .flac, .ogg, .opus, .aac. model: type: string description: Model to use for translation @@ -10219,7 +10443,11 @@ components: example: en prompt: type: string - description: Optional text to bias decoding. + description: >- + Optional text to bias decoding. Supported only on Whisper-family + models (e.g. `openai/whisper-large-v3`). Other STT models + (e.g. `nvidia/parakeet-tdt-0.6b-v3`) accept the field for API + compatibility but ignore it. response_format: type: string description: The format of the response @@ -10271,19 +10499,11 @@ components: AudioTranslationVerboseJsonResponse: type: object required: - - task - language - duration - text - segments properties: - task: - type: string - description: The task performed - enum: - - transcribe - - translate - example: translate language: type: string description: The target language of the translation @@ -10409,9 +10629,7 @@ components: model: type: string description: > - The name of the embedding model to use.
-
- [See all of Together AI's embedding models](https://docs.together.ai/docs/serverless-models#embedding-models) + The name of the embedding model to use.

[See all of Together AI's embedding models](https://docs.together.ai/docs/serverless-models#embedding-models) example: togethercomputer/m2-bert-80M-8k-retrieval anyOf: - type: string @@ -10697,6 +10915,12 @@ components: type: object required: [hourly, input, output, base, finetune] properties: + base: + type: number + example: 0 + finetune: + type: number + example: 0 hourly: type: number example: 0 @@ -10706,12 +10930,9 @@ components: output: type: number example: 0.3 - base: + cached_input: type: number - example: 0 - finetune: - type: number - example: 0 + example: 0.2 ToolsPart: type: object @@ -10808,10 +11029,6 @@ components: enum: - fine-tune - eval - - eval-sample - - eval-output - - eval-summary - - batch-generated - batch-api FileType: type: string @@ -10982,7 +11199,7 @@ components: description: Start timestamp of the current stage of the fine-tune job user_id: type: string - description: Identifier for the user who created the job + description: Identifier for who created the job. owner_address: type: string description: Owner address information @@ -11007,6 +11224,9 @@ components: packing: type: boolean description: Whether sequence packing is being used for training. + max_seq_length: + type: integer + description: Maximum sequence length to use for training. If not specified, uses the maximum allowed for the model and training method. model: type: string description: Base model used for fine-tuning @@ -11370,7 +11590,7 @@ components: - auto type: boolean default: auto - description: Whether to mask the user messages in conversational data or prompts in instruction data. + description: Whether to mask user messages in conversational data or prompts in instruction data. required: - method - train_on_inputs @@ -11596,7 +11816,7 @@ components: example: STARTED inactive_timeout: type: integer - description: The number of minutes of inactivity after which the endpoint will be automatically stopped. Set to null, omit or set to 0 to disable automatic timeout. + description: The number of minutes of inactivity after which the endpoint stops automatically. Set to null, omit, or set to 0 to disable automatic timeout. nullable: true example: 60 availability_zone: @@ -11807,7 +12027,7 @@ components: example: "print('Hello, world!')" type: string files: - description: Files to upload to the session. If present, files will be uploaded before executing the given code. + description: Files to upload to the session. If present, files are uploaded before executing the given code. items: properties: content: @@ -11828,11 +12048,11 @@ components: type: array language: default: python - description: Programming language for the code to execute. Currently only supports Python, but more will be added. + description: Programming language for the code to execute. Currently only supports Python. enum: - python session_id: - description: Identifier of the current session. Used to make follow-up calls. Requests will return an error if the session does not belong to the caller or has expired. + description: Identifier of the current session. Used to make follow-up calls. Returns an error if the session does not belong to the caller or has expired. example: ses_abcDEF123 nullable: false type: string @@ -11840,7 +12060,7 @@ components: ExecuteResponse: title: ExecuteResponse type: object - description: 'The result of the execution. If successful, `data` contains the result and `errors` will be null. If unsuccessful, `data` will be null and `errors` will contain the errors.' + description: 'The result of the execution. If successful, `data` contains the result and `errors` is null. If unsuccessful, `data` is null and `errors` contains the errors.' oneOf: - title: SuccessfulExecution type: object @@ -12116,7 +12336,15 @@ components: properties: endpoint: type: string - description: The endpoint to use for batch processing + enum: + - /v1/chat/completions + - /v1/audio/transcriptions + - /v1/audio/translations + description: | + The endpoint to use for batch processing. Each line of the uploaded input file is dispatched against this endpoint. + - `/v1/chat/completions` — chat completion batches + - `/v1/audio/transcriptions` — audio transcription batches (e.g. `openai/whisper-large-v3`) + - `/v1/audio/translations` — audio translation batches example: '/v1/chat/completions' input_file_id: type: string @@ -12333,6 +12561,23 @@ components: external_base_url: type: string description: "Base URL for external judge models. Must be OpenAI-compatible base URL." + num_workers: + type: integer + minimum: 1 + description: "Number of concurrent workers for inference requests. Overrides the default concurrency for this model. Useful for tuning throughput when using proxy endpoints (e.g. OpenRouter) or rate-limited external APIs." + example: 5 + max_tokens: + type: integer + minimum: 1 + description: "Maximum number of tokens the judge model can generate. Defaults to 32768. Increase for reasoning models (e.g. Gemini, o-series) that consume output token budget for chain-of-thought." + example: 8192 + temperature: + type: number + format: float + minimum: 0 + maximum: 2 + description: "Sampling temperature for the judge model. Defaults to 0.05." + example: 0.0 EvaluationModelOrString: oneOf: @@ -12384,6 +12629,11 @@ components: external_base_url: type: string description: "Base URL for external models. Must be OpenAI-compatible base URL" + num_workers: + type: integer + minimum: 1 + description: "Number of concurrent workers for inference requests. Overrides the default concurrency for this model. Useful for tuning throughput when using proxy endpoints (e.g. OpenRouter) or rate-limited external APIs." + example: 5 EvaluationResponse: type: object @@ -12643,20 +12893,7 @@ components: deprecated: true description: "Deprecated: use media.frame_images instead. Array of images to guide video generation, similar to keyframes." example: - - [ - { - "input_image": "aac49721-1964-481a-ae78-8a4e29b91402", - "frame": 0 - }, - { - "input_image": "c00abf5f-6cdb-4642-a01d-1bfff7bc3cf7", - "frame": 48 - }, - { - "input_image": "3ad204c3-a9de-4963-8a1a-c3911e3afafe", - "frame": "last" - } - ] + - [{"input_image": "aac49721-1964-481a-ae78-8a4e29b91402", "frame": 0}, {"input_image": "c00abf5f-6cdb-4642-a01d-1bfff7bc3cf7", "frame": 48}, {"input_image": "3ad204c3-a9de-4963-8a1a-c3911e3afafe", "frame": "last"}] type: array items: $ref: '#/components/schemas/VideoFrameImageInput' @@ -12815,118 +13052,99 @@ components: ContainerStatus: properties: finishedAt: - description: FinishedAt is the timestamp when the container finished execution - (if terminated) + description: FinishedAt is the timestamp when the container finished execution (if terminated) type: string message: - description: Message provides a human-readable message with details about the - container's status + description: Message provides a human-readable message with details about the container's status type: string name: description: Name is the name of the container type: string reason: - description: Reason provides a brief machine-readable reason for the container's - current status + description: Reason provides a brief machine-readable reason for the container's current status type: string startedAt: description: StartedAt is the timestamp when the container started execution type: string status: - description: Status is the current state of the container (e.g., "Running", - "Terminated", "Waiting") + description: Status is the current state of the container (e.g., "Running", "Terminated", "Waiting") type: string type: object CreateDeploymentRequest: properties: args: - description: Args overrides the container's CMD. Provide as an array of - arguments (e.g., ["python", "app.py"]) + description: Args overrides the container's CMD. Provide as an array of arguments (e.g., ["python", "app.py"]) items: type: string type: array autoscaling: - description: 'Autoscaling configuration. Example: {"metric": "QueueBacklogPerWorker", - "target": 1.01} to scale based on queue backlog. Omit or set to null to - disable autoscaling' + description: 'Autoscaling configuration. Example: {"metric": "QueueBacklogPerWorker", "target": 1.01} to scale based on queue backlog. Omit or set to null to disable autoscaling' oneOf: - - $ref: "#/components/schemas/HTTPAutoscalingConfig" - - $ref: "#/components/schemas/QueueAutoscalingConfig" - - $ref: "#/components/schemas/CustomMetricAutoscalingConfig" + - $ref: "#/components/schemas/HTTPAutoscalingConfig" + - $ref: "#/components/schemas/QueueAutoscalingConfig" + - $ref: "#/components/schemas/CustomMetricAutoscalingConfig" command: - description: Command overrides the container's ENTRYPOINT. Provide as an - array (e.g., ["/bin/sh", "-c"]) + description: Command overrides the container's ENTRYPOINT. Provide as an array (e.g., ["/bin/sh", "-c"]) items: type: string type: array cpu: - description: CPU is the number of CPU cores to allocate per container instance - (e.g., 0.1 = 100 milli cores) + description: CPU is the number of CPU cores to allocate per container instance (e.g., 0.1 = 100 milli cores) minimum: 0.1 type: number description: - description: Description is an optional human-readable description of your - deployment + description: Description is an optional human-readable description of your deployment type: string environment_variables: - description: EnvironmentVariables is a list of environment variables to - set in the container. Each must have a name and either a value or value_from_secret + description: EnvironmentVariables is a list of environment variables to set in the container. Each must have a name and either a value or value_from_secret items: $ref: "#/components/schemas/EnvironmentVariable" type: array gpu_count: - description: GPUCount is the number of GPUs to allocate per container instance. - Defaults to 0 if not specified + description: GPUCount is the number of GPUs to allocate per container instance. Defaults to 0 if not specified type: integer gpu_type: description: GPUType specifies the GPU hardware to use (e.g., "h100-80gb"). enum: - - h100-80gb + - h100-80gb + - h100-40gb-mig + - b200-192gb type: string health_check_path: - description: HealthCheckPath is the HTTP path for health checks (e.g., "/health"). - If set, the platform will check this endpoint to determine container health + description: HealthCheckPath is the HTTP path for health checks (e.g., "/health"). If set, the platform checks this endpoint to determine container health. type: string image: description: Image is the container image to deploy from registry.together.ai. type: string max_replicas: - description: MaxReplicas is the maximum number of container instances that - can be scaled up to. If not set, will be set to MinReplicas + description: MaxReplicas is the maximum number of container instances. Defaults to MinReplicas if not set. type: integer memory: - description: Memory is the amount of RAM to allocate per container instance - in GiB (e.g., 0.5 = 512MiB) + description: Memory is the amount of RAM to allocate per container instance in GiB (e.g., 0.5 = 512MiB) maximum: 1000 type: number min_replicas: - description: MinReplicas is the minimum number of container instances to - run. Defaults to 1 if not specified + description: MinReplicas is the minimum number of container instances to run. Defaults to 1 if not specified type: integer name: - description: Name is the unique identifier for your deployment. Must contain - only alphanumeric characters, underscores, or hyphens (1-100 characters) + description: Name is the unique identifier for your deployment. Must contain only alphanumeric characters, underscores, or hyphens (1-100 characters) maxLength: 100 minLength: 1 type: string port: - description: Port is the container port your application listens on (e.g., - 8080 for web servers). Required if your application serves traffic + description: Port is the container port your application listens on (e.g., 8080 for web servers). Required if your application serves traffic maximum: 65535 minimum: 1 type: integer storage: - description: Storage is the amount of ephemeral disk storage to allocate - per container instance (e.g., 10 = 10GiB) + description: Storage is the amount of ephemeral disk storage to allocate per container instance (e.g., 10 = 10GiB) maximum: 400 type: integer termination_grace_period_seconds: - description: TerminationGracePeriodSeconds is the time in seconds to wait - for graceful shutdown before forcefully terminating the replica + description: TerminationGracePeriodSeconds is the time in seconds to wait for graceful shutdown before forcefully terminating the replica type: integer volumes: - description: Volumes is a list of volume mounts to attach to the container. - Each mount must reference an existing volume by name + description: Volumes is a list of volume mounts to attach to the container. Each mount must reference an existing volume by name items: $ref: "#/components/schemas/VolumeMount" type: array @@ -12938,24 +13156,19 @@ components: CreateSecretRequest: properties: description: - description: Description is an optional human-readable description of the - secret's purpose (max 500 characters) + description: Description is an optional human-readable description of the secret's purpose (max 500 characters) maxLength: 500 type: string name: - description: Name is the unique identifier for the secret. Can contain - alphanumeric characters, underscores, hyphens, forward slashes, and - periods (1-100 characters) + description: Name is the unique identifier for the secret. Can contain alphanumeric characters, underscores, hyphens, forward slashes, and periods (1-100 characters) maxLength: 100 minLength: 1 type: string project_id: - description: ProjectID is ignored - the project is automatically determined from - your authentication + description: ProjectID is ignored - the project is automatically determined from your authentication type: string value: - description: Value is the sensitive data to store securely (e.g., API keys, - passwords, tokens). This value will be encrypted at rest + description: Value is the sensitive data to store securely (e.g., API keys, passwords, tokens). Encrypted at rest. minLength: 1 type: string required: @@ -13006,53 +13219,46 @@ components: type: string type: array autoscaling: - description: Autoscaling contains autoscaling configuration parameters for - this deployment. Omitted when autoscaling is disabled (nil) + description: Autoscaling contains autoscaling configuration parameters for this deployment. Omitted when autoscaling is disabled (nil) oneOf: - - $ref: '#/components/schemas/HTTPAutoscalingConfig' - - $ref: '#/components/schemas/QueueAutoscalingConfig' - - $ref: '#/components/schemas/CustomMetricAutoscalingConfig' + - $ref: '#/components/schemas/HTTPAutoscalingConfig' + - $ref: '#/components/schemas/QueueAutoscalingConfig' + - $ref: '#/components/schemas/CustomMetricAutoscalingConfig' command: description: Command is the entrypoint command run in the container items: type: string type: array cpu: - description: CPU is the amount of CPU resource allocated to each replica in - cores (fractional value is allowed) + description: CPU is the amount of CPU resource allocated to each replica in cores (fractional value is allowed) type: number created_at: description: CreatedAt is the ISO8601 timestamp when this deployment was created type: string format: date-time description: - description: Description provides a human-readable explanation of the - deployment's purpose or content + description: Description provides a human-readable explanation of the deployment's purpose or content type: string desired_replicas: - description: DesiredReplicas is the number of replicas that the orchestrator is - targeting + description: DesiredReplicas is the number of replicas that the orchestrator is targeting type: integer environment_variables: - description: EnvironmentVariables is a list of environment variables set in the - container + description: EnvironmentVariables is a list of environment variables set in the container items: $ref: "#/components/schemas/EnvironmentVariable" type: array gpu_count: - description: GPUCount is the number of GPUs allocated to each replica in this - deployment + description: GPUCount is the number of GPUs allocated to each replica in this deployment type: integer gpu_type: - description: GPUType specifies the type of GPU requested (if any) for this - deployment + description: GPUType specifies the type of GPU requested (if any) for this deployment enum: - h100-80gb - - " a100-80gb" + - h100-40gb-mig + - b200-192gb type: string health_check_path: - description: HealthCheckPath is the HTTP path used for health checks of the - application + description: HealthCheckPath is the HTTP path used for health checks of the application type: string id: description: ID is the unique identifier of the deployment @@ -13061,16 +13267,13 @@ components: description: Image specifies the container image used for this deployment type: string max_replicas: - description: MaxReplicas is the maximum number of replicas to run for this - deployment + description: MaxReplicas is the maximum number of replicas to run for this deployment type: integer memory: - description: Memory is the amount of memory allocated to each replica in GiB - (fractional value is allowed) + description: Memory is the amount of memory allocated to each replica in GiB (fractional value is allowed) type: number min_replicas: - description: MinReplicas is the minimum number of replicas to run for this - deployment + description: MinReplicas is the minimum number of replicas to run for this deployment type: integer name: description: Name is the name of the deployment @@ -13082,32 +13285,27 @@ components: description: Port is the container port that the deployment exposes type: integer ready_replicas: - description: ReadyReplicas is the current number of replicas that are in the - Ready state + description: ReadyReplicas is the current number of replicas that are in the Ready state type: integer replica_events: additionalProperties: $ref: "#/components/schemas/ReplicaEvent" - description: ReplicaEvents is a mapping of replica names or IDs to their status - events + description: ReplicaEvents is a mapping of replica names or IDs to their status events type: object status: allOf: - $ref: "#/components/schemas/DeploymentStatus" - description: Status represents the overall status of the deployment (e.g., - Updating, Scaling, Ready, Failed) + description: Status represents the overall status of the deployment (e.g., Updating, Scaling, Ready, Failed) enum: - Updating - Scaling - Ready - Failed storage: - description: Storage is the amount of storage (in MB or units as defined by the - platform) allocated to each replica + description: Storage is the amount of storage (in MB or units as defined by the platform) allocated to each replica type: integer updated_at: - description: UpdatedAt is the ISO8601 timestamp when this deployment was last - updated + description: UpdatedAt is the ISO8601 timestamp when this deployment was last updated type: string format: date-time volumes: @@ -13131,42 +13329,33 @@ components: EnvironmentVariable: properties: name: - description: Name is the environment variable name (e.g., "DATABASE_URL"). Must - start with a letter or underscore, followed by letters, numbers, or - underscores + description: Name is the environment variable name (e.g., "DATABASE_URL"). Must start with a letter or underscore, followed by letters, numbers, or underscores type: string value: - description: Value is the plain text value for the environment variable. Use - this for non-sensitive values. Either Value or ValueFromSecret must - be set, but not both + description: Value is the plain text value for the environment variable. Use this for non-sensitive values. Either Value or ValueFromSecret must be set, but not both type: string value_from_secret: - description: ValueFromSecret references a secret by name or ID to use as the - value. Use this for sensitive values like API keys or passwords. - Either Value or ValueFromSecret must be set, but not both + description: ValueFromSecret references a secret by name or ID to use as the value. Use this for sensitive values like API keys or passwords. Either Value or ValueFromSecret must be set, but not both type: string required: - name type: object HTTPAutoscalingConfig: - description: Autoscaling config for HTTPTotalRequests and HTTPAvgRequestDuration - metrics + description: Autoscaling config for HTTPTotalRequests and HTTPAvgRequestDuration metrics properties: metric: description: Metric must be HTTPTotalRequests or HTTPAvgRequestDuration enum: - - HTTPTotalRequests - - HTTPAvgRequestDuration + - HTTPTotalRequests + - HTTPAvgRequestDuration example: HTTPTotalRequests type: string target: - description: 'Target is the threshold value. Default: 100 for HTTPTotalRequests, - 500 (ms) for HTTPAvgRequestDuration' + description: 'Target is the threshold value. Default: 100 for HTTPTotalRequests, 500 (ms) for HTTPAvgRequestDuration' example: 100 type: number time_interval_minutes: - description: 'TimeIntervalMinutes is the rate window in minutes. Default: - 10' + description: 'TimeIntervalMinutes is the rate window in minutes. Default: 10' example: 10 type: integer type: object @@ -13176,12 +13365,11 @@ components: metric: description: Metric must be QueueBacklogPerWorker enum: - - QueueBacklogPerWorker + - QueueBacklogPerWorker example: QueueBacklogPerWorker type: string model: - description: Model overrides the model name for queue status lookup. Defaults - to the deployment app name + description: Model overrides the model name for queue status lookup. Defaults to the deployment app name type: string target: description: 'Target is the threshold value. Default: 1.01' @@ -13192,14 +13380,13 @@ components: description: Autoscaling config for CustomMetric metric properties: custom_metric_name: - description: CustomMetricName is the Prometheus metric name. Required. Must - match [a-zA-Z_:][a-zA-Z0-9_:]* + description: CustomMetricName is the Prometheus metric name. Required. Must match [a-zA-Z_:][a-zA-Z0-9_:]* example: my_custom_metric type: string metric: description: Metric must be CustomMetric enum: - - CustomMetric + - CustomMetric example: CustomMetric type: string target: @@ -13225,8 +13412,7 @@ components: description: Message is a human-readable description of the event type: string reason: - description: Reason is a brief machine-readable reason for this event (e.g., - "Pulling", "Started", "Failed") + description: Reason is a brief machine-readable reason for this event (e.g., "Pulling", "Started", "Failed") type: string type: object ListSecretsResponse: @@ -13257,35 +13443,28 @@ components: description: Image is the container image used for this replica type: string replica_ready_since: - description: ReplicaReadySince is the timestamp when the replica became ready to - serve traffic + description: ReplicaReadySince is the timestamp when the replica became ready to serve traffic type: string replica_status: - description: ReplicaStatus is the current status of the replica (e.g., - "Running", "Waiting", "Terminated") + description: ReplicaStatus is the current status of the replica (e.g., "Running", "Waiting", "Terminated") type: string replica_status_message: - description: ReplicaStatusMessage provides a human-readable message explaining - the replica's status + description: ReplicaStatusMessage provides a human-readable message explaining the replica's status type: string replica_status_reason: - description: ReplicaStatusReason provides a brief machine-readable reason for - the replica's status + description: ReplicaStatusReason provides a brief machine-readable reason for the replica's status type: string revision_id: description: RevisionID is the deployment revision ID associated with this replica type: string volume_preload_completed_at: - description: VolumePreloadCompletedAt is the timestamp when the volume preload - completed + description: VolumePreloadCompletedAt is the timestamp when the volume preload completed type: string volume_preload_started_at: - description: VolumePreloadStartedAt is the timestamp when the volume preload - started + description: VolumePreloadStartedAt is the timestamp when the volume preload started type: string volume_preload_status: - description: VolumePreloadStatus is the status of the volume preload (e.g., - "InProgress", "Completed", "Failed") + description: VolumePreloadStatus is the status of the volume preload (e.g., "InProgress", "Completed", "Failed") type: string type: object SecretResponseItem: @@ -13294,7 +13473,7 @@ components: description: CreatedAt is the ISO8601 timestamp when this secret was created type: string created_by: - description: CreatedBy is the identifier of the user who created this secret + description: CreatedBy is the identifier of who created this secret. type: string description: description: Description is a human-readable description of the secret's purpose @@ -13303,8 +13482,7 @@ components: description: ID is the unique identifier for this secret type: string last_updated_by: - description: LastUpdatedBy is the identifier of the user who last updated this - secret + description: LastUpdatedBy is the identifier of who last updated this secret. type: string name: description: Name is the name/key of the secret @@ -13319,36 +13497,30 @@ components: UpdateDeploymentRequest: properties: args: - description: Args overrides the container's CMD. Provide as an array of - arguments (e.g., ["python", "app.py"]) + description: Args overrides the container's CMD. Provide as an array of arguments (e.g., ["python", "app.py"]) items: type: string type: array autoscaling: - description: Autoscaling configuration for the deployment. Set to {} to - disable autoscaling + description: Autoscaling configuration for the deployment. Set to {} to disable autoscaling oneOf: - - $ref: "#/components/schemas/HTTPAutoscalingConfig" - - $ref: "#/components/schemas/QueueAutoscalingConfig" - - $ref: "#/components/schemas/CustomMetricAutoscalingConfig" + - $ref: "#/components/schemas/HTTPAutoscalingConfig" + - $ref: "#/components/schemas/QueueAutoscalingConfig" + - $ref: "#/components/schemas/CustomMetricAutoscalingConfig" command: - description: Command overrides the container's ENTRYPOINT. Provide as an - array (e.g., ["/bin/sh", "-c"]) + description: Command overrides the container's ENTRYPOINT. Provide as an array (e.g., ["/bin/sh", "-c"]) items: type: string type: array cpu: - description: CPU is the number of CPU cores to allocate per container instance - (e.g., 0.1 = 100 milli cores) + description: CPU is the number of CPU cores to allocate per container instance (e.g., 0.1 = 100 milli cores) minimum: 0.1 type: number description: - description: Description is an optional human-readable description of your - deployment + description: Description is an optional human-readable description of your deployment type: string environment_variables: - description: EnvironmentVariables is a list of environment variables to - set in the container. This will replace all existing environment variables + description: EnvironmentVariables is a list of environment variables to set in the container. Replaces all existing environment variables. items: $ref: "#/components/schemas/EnvironmentVariable" type: array @@ -13358,51 +13530,45 @@ components: gpu_type: description: GPUType specifies the GPU hardware to use (e.g., "h100-80gb") enum: - - h100-80gb + - h100-80gb + - h100-40gb-mig + - b200-192gb type: string health_check_path: - description: HealthCheckPath is the HTTP path for health checks (e.g., "/health"). - Set to empty string to disable health checks + description: HealthCheckPath is the HTTP path for health checks (e.g., "/health"). Set to empty string to disable health checks type: string image: description: Image is the container image to deploy from registry.together.ai. type: string max_replicas: - description: MaxReplicas is the maximum number of replicas that can be scaled - up to. + description: MaxReplicas is the maximum number of replicas that can be scaled up to. type: integer memory: - description: Memory is the amount of RAM to allocate per container instance - in GiB (e.g., 0.5 = 512MiB) + description: Memory is the amount of RAM to allocate per container instance in GiB (e.g., 0.5 = 512MiB) maximum: 1000 type: number min_replicas: description: MinReplicas is the minimum number of replicas to run type: integer name: - description: Name is the new unique identifier for your deployment. Must - contain only alphanumeric characters, underscores, or hyphens (1-100 characters) + description: Name is the new unique identifier for your deployment. Must contain only alphanumeric characters, underscores, or hyphens (1-100 characters) maxLength: 100 minLength: 1 type: string port: - description: Port is the container port your application listens on (e.g., - 8080 for web servers) + description: Port is the container port your application listens on (e.g., 8080 for web servers) maximum: 65535 minimum: 1 type: integer storage: - description: Storage is the amount of ephemeral disk storage to allocate - per container instance (e.g., 10 = 10GiB) + description: Storage is the amount of ephemeral disk storage to allocate per container instance (e.g., 10 = 10GiB) maximum: 400 type: integer termination_grace_period_seconds: - description: TerminationGracePeriodSeconds is the time in seconds to wait - for graceful shutdown before forcefully terminating the replica + description: TerminationGracePeriodSeconds is the time in seconds to wait for graceful shutdown before forcefully terminating the replica type: integer volumes: - description: Volumes is a list of volume mounts to attach to the container. - This will replace all existing volumes + description: Volumes is a list of volume mounts to attach to the container. Replaces all existing volumes. items: $ref: "#/components/schemas/VolumeMount" type: array @@ -13410,24 +13576,19 @@ components: UpdateSecretRequest: properties: description: - description: Description is an optional human-readable description of the - secret's purpose (max 500 characters) + description: Description is an optional human-readable description of the secret's purpose (max 500 characters) maxLength: 500 type: string name: - description: Name is the new unique identifier for the secret. Can contain - alphanumeric characters, underscores, hyphens, forward slashes, and - periods (1-100 characters) + description: Name is the new unique identifier for the secret. Can contain alphanumeric characters, underscores, hyphens, forward slashes, and periods (1-100 characters) maxLength: 100 minLength: 1 type: string project_id: - description: ProjectID is ignored - the project is automatically determined from - your authentication + description: ProjectID is ignored - the project is automatically determined from your authentication type: string value: - description: Value is the new sensitive data to store securely. Updating this - will replace the existing secret value + description: Value is the new sensitive data to store securely. Updating this replaces the existing secret value. minLength: 1 type: string type: object @@ -13436,8 +13597,7 @@ components: content: allOf: - $ref: "#/components/schemas/VolumeContentRequest" - description: Content specifies the new content that will be preloaded to this - volume + description: Content specifies the new content to preload to this volume. name: description: Name is the new unique identifier for the volume within the project type: string @@ -13449,16 +13609,13 @@ components: VolumeMount: properties: mount_path: - description: MountPath is the path in the container where the volume will - be mounted (e.g., "/data") + description: MountPath is the path in the container where the volume mounts (e.g., "/data"). type: string name: - description: Name is the name of the volume to mount. Must reference an - existing volume by name or ID + description: Name is the name of the volume to mount. Must reference an existing volume by name or ID type: string version: - description: Version is the volume version to mount. On create, defaults - to the latest version. On update, defaults to the currently mounted version. + description: Version is the volume version to mount. On create, defaults to the latest version. On update, defaults to the currently mounted version. type: integer required: - mount_path @@ -13478,8 +13635,7 @@ components: description: ID is the unique identifier for this volume type: string mounted_by: - description: MountedBy is the list of deployment IDs currently mounting - current volume version + description: MountedBy is the list of deployment IDs currently mounting current volume version items: type: string type: array @@ -13493,14 +13649,12 @@ components: type: $ref: '#/components/schemas/VolumeType' updated_at: - description: UpdatedAt is the ISO8601 timestamp when this volume was last - updated + description: UpdatedAt is the ISO8601 timestamp when this volume was last updated type: string version_history: additionalProperties: $ref: '#/components/schemas/VersionHistoryItem' - description: VersionHistory contains previous versions of this volume, keyed - by version number + description: VersionHistory contains previous versions of this volume, keyed by version number type: object type: object VersionHistoryItem: @@ -13516,39 +13670,33 @@ components: type: integer type: object VolumeContentRequest: - description: Content specifies the new content that will be preloaded to this - volume + description: Content specifies the new content to preload to this volume. properties: source_prefix: - description: SourcePrefix is the file path prefix for the content to be - preloaded into the volume + description: SourcePrefix is the file path prefix for the content to be preloaded into the volume example: models/ type: string type: - description: Type is the content type (currently only "files" is supported - which allows preloading files uploaded via Files API into the volume) + description: Type is the content type (currently only "files" is supported which allows preloading files uploaded via Files API into the volume) enum: - - files + - files example: files type: string type: object VolumeContent: properties: files: - description: Files is the list of files that will be preloaded into the - volume, if the volume content type is "files" + description: Files is the list of files to preload into the volume, if the volume content type is "files". items: $ref: '#/components/schemas/FileInfo' type: array uniqueItems: false source_prefix: - description: SourcePrefix is the file path prefix for the content to be - preloaded into the volume + description: SourcePrefix is the file path prefix for the content to be preloaded into the volume example: models/ type: string type: - description: Type is the content type (currently only "files" is supported which - allows preloading files uploaded via Files API into the volume) + description: Type is the content type (currently only "files" is supported which allows preloading files uploaded via Files API into the volume) enum: - files example: files