Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 121 additions & 0 deletions src/libs/Reka/Generated/Reka.AutoSDKHttpResponse.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@

#nullable enable

namespace Reka
{
/// <summary>
/// Represents a successful HTTP response with status code and headers.
/// </summary>
public partial class AutoSDKHttpResponse
{
/// <summary>
/// Initializes a new instance of the <see cref="AutoSDKHttpResponse"/> class.
/// </summary>
public AutoSDKHttpResponse(
global::System.Net.HttpStatusCode statusCode,
global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>> headers)
: this(
statusCode: statusCode,
headers: headers,
requestUri: null)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="AutoSDKHttpResponse"/> class.
/// </summary>
public AutoSDKHttpResponse(
global::System.Net.HttpStatusCode statusCode,
global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>> headers,
global::System.Uri? requestUri)
{
StatusCode = statusCode;
Headers = headers ?? throw new global::System.ArgumentNullException(nameof(headers));
RequestUri = requestUri;
}

/// <summary>
/// Gets the HTTP status code.
/// </summary>
public global::System.Net.HttpStatusCode StatusCode { get; }
/// <summary>
/// Gets the response headers.
/// </summary>
public global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>> Headers { get; }
/// <summary>
/// Gets the final request URI associated with the response.
/// </summary>
public global::System.Uri? RequestUri { get; }

internal static global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>> 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<string>)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;
}
}

/// <summary>
/// Represents a successful HTTP response with status code, headers, and body.
/// </summary>
public partial class AutoSDKHttpResponse<T> : AutoSDKHttpResponse
{
/// <summary>
/// Initializes a new instance of the <see cref="AutoSDKHttpResponse{T}"/> class.
/// </summary>
public AutoSDKHttpResponse(
global::System.Net.HttpStatusCode statusCode,
global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>> headers,
T body)
: this(
statusCode: statusCode,
headers: headers,
requestUri: null,
body: body)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="AutoSDKHttpResponse{T}"/> class.
/// </summary>
public AutoSDKHttpResponse(
global::System.Net.HttpStatusCode statusCode,
global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>> headers,
global::System.Uri? requestUri,
T body)
: base(statusCode, headers, requestUri)
{
Body = body;
}

/// <summary>
/// Gets the response body.
/// </summary>
public T Body { get; }
}
}
68 changes: 59 additions & 9 deletions src/libs/Reka/Generated/Reka.ChatClient.CreateChatCompletion.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,29 @@ partial void ProcessCreateChatCompletionResponseContent(
/// <exception cref="global::Reka.ApiException"></exception>
public async global::System.Threading.Tasks.Task<global::Reka.CreateChatCompletionResponse> CreateChatCompletionAsync(

global::Reka.CreateChatCompletionRequest request,
global::Reka.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __response = await CreateChatCompletionAsResponseAsync(

request: request,
requestOptions: requestOptions,
cancellationToken: cancellationToken
).ConfigureAwait(false);

return __response.Body;
}
/// <summary>
/// Create a chat completion<br/>
/// Creates a chat completion for the provided messages and model.
/// </summary>
/// <param name="request"></param>
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::Reka.ApiException"></exception>
public async global::System.Threading.Tasks.Task<global::Reka.AutoSDKHttpResponse<global::Reka.CreateChatCompletionResponse>> CreateChatCompletionAsResponseAsync(

global::Reka.CreateChatCompletionRequest request,
global::Reka.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
Expand Down Expand Up @@ -81,10 +104,11 @@ partial void ProcessCreateChatCompletionResponseContent(
var __maxAttempts = global::Reka.AutoSDKRequestOptionsSupport.GetMaxAttempts(
clientOptions: Options,
requestOptions: requestOptions,
supportsRetry: true);
supportsRetry: false);

global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{

var __pathBuilder = new global::Reka.PathBuilder(
path: "/v1/chat/completions",
baseUri: HttpClient.BaseAddress);
Expand Down Expand Up @@ -164,6 +188,8 @@ partial void ProcessCreateChatCompletionResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
retryDelay: null,
retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
Expand All @@ -174,6 +200,11 @@ partial void ProcessCreateChatCompletionResponseContent(
}
catch (global::System.Net.Http.HttpRequestException __exception)
{
var __retryDelay = global::Reka.AutoSDKRequestOptionsSupport.GetRetryDelay(
clientOptions: Options,
requestOptions: requestOptions,
response: null,
attempt: __attempt);
var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
await global::Reka.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
Expand All @@ -191,6 +222,8 @@ partial void ProcessCreateChatCompletionResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
Expand All @@ -200,8 +233,7 @@ partial void ProcessCreateChatCompletionResponseContent(
__httpRequest.Dispose();
__httpRequest = null;
await global::Reka.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
clientOptions: Options,
requestOptions: requestOptions,
retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
Expand All @@ -210,6 +242,11 @@ partial void ProcessCreateChatCompletionResponseContent(
__attempt < __maxAttempts &&
global::Reka.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
var __retryDelay = global::Reka.AutoSDKRequestOptionsSupport.GetRetryDelay(
clientOptions: Options,
requestOptions: requestOptions,
response: __response,
attempt: __attempt);
await global::Reka.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
context: global::Reka.AutoSDKRequestOptionsSupport.CreateHookContext(
Expand All @@ -226,14 +263,15 @@ partial void ProcessCreateChatCompletionResponseContent(
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::Reka.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
clientOptions: Options,
requestOptions: requestOptions,
retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
Expand Down Expand Up @@ -273,6 +311,8 @@ partial void ProcessCreateChatCompletionResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
retryDelay: null,
retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
Expand All @@ -293,6 +333,8 @@ partial void ProcessCreateChatCompletionResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
retryDelay: null,
retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
// Validation Error
Expand Down Expand Up @@ -355,9 +397,13 @@ partial void ProcessCreateChatCompletionResponseContent(
{
__response.EnsureSuccessStatusCode();

return
global::Reka.CreateChatCompletionResponse.FromJson(__content, JsonSerializerContext) ??
var __value = global::Reka.CreateChatCompletionResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
return new global::Reka.AutoSDKHttpResponse<global::Reka.CreateChatCompletionResponse>(
statusCode: __response.StatusCode,
headers: global::Reka.AutoSDKHttpResponse.CreateHeaders(__response),
requestUri: __response.RequestMessage?.RequestUri,
body: __value);
}
catch (global::System.Exception __ex)
{
Expand Down Expand Up @@ -385,9 +431,13 @@ partial void ProcessCreateChatCompletionResponseContent(
#endif
).ConfigureAwait(false);

return
await global::Reka.CreateChatCompletionResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
var __value = await global::Reka.CreateChatCompletionResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
return new global::Reka.AutoSDKHttpResponse<global::Reka.CreateChatCompletionResponse>(
statusCode: __response.StatusCode,
headers: global::Reka.AutoSDKHttpResponse.CreateHeaders(__response),
requestUri: __response.RequestMessage?.RequestUri,
body: __value);
}
catch (global::System.Exception __ex)
{
Expand Down
8 changes: 4 additions & 4 deletions src/libs/Reka/Generated/Reka.ChatClient.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ public ChatClient(
/// <param name="options">Client-wide request defaults such as headers, query parameters, retries, and timeout.</param>
/// <param name="disposeHttpClient">Dispose the HttpClient when the instance is disposed. True by default.</param>
public ChatClient(
global::System.Net.Http.HttpClient? httpClient = null,
global::System.Uri? baseUri = null,
global::System.Collections.Generic.List<global::Reka.EndPointAuthorization>? authorizations = null,
global::Reka.AutoSDKClientOptions? options = null,
global::System.Net.Http.HttpClient? httpClient,
global::System.Uri? baseUri,
global::System.Collections.Generic.List<global::Reka.EndPointAuthorization>? authorizations,
global::Reka.AutoSDKClientOptions? options,
bool disposeHttpClient = true)
{

Expand Down
13 changes: 13 additions & 0 deletions src/libs/Reka/Generated/Reka.IChatClient.CreateChatCompletion.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ public partial interface IChatClient
/// Create a chat completion<br/>
/// Creates a chat completion for the provided messages and model.
/// </summary>
/// <param name="request"></param>
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::Reka.ApiException"></exception>
global::System.Threading.Tasks.Task<global::Reka.AutoSDKHttpResponse<global::Reka.CreateChatCompletionResponse>> CreateChatCompletionAsResponseAsync(

global::Reka.CreateChatCompletionRequest request,
global::Reka.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
/// <summary>
/// Create a chat completion<br/>
/// Creates a chat completion for the provided messages and model.
/// </summary>
/// <param name="messages">
/// A list of messages comprising the conversation so far.
/// </param>
Expand Down
10 changes: 10 additions & 0 deletions src/libs/Reka/Generated/Reka.IModelsClient.ListModels.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,15 @@ public partial interface IModelsClient
global::System.Threading.Tasks.Task<global::Reka.ListModelsResponse> ListModelsAsync(
global::Reka.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
/// <summary>
/// List models<br/>
/// List models available to the user. Different users may have access to different models depending on their permissions.
/// </summary>
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::Reka.ApiException"></exception>
global::System.Threading.Tasks.Task<global::Reka.AutoSDKHttpResponse<global::Reka.ListModelsResponse>> ListModelsAsResponseAsync(
global::Reka.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@ public partial interface ISpeechClient
/// Supports three modes: transcription only, translation (text output), and<br/>
/// speech-to-speech translation (with audio output).
/// </summary>
/// <param name="request"></param>
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::Reka.ApiException"></exception>
global::System.Threading.Tasks.Task<global::Reka.AutoSDKHttpResponse<global::Reka.TranscribeOrTranslateResponse>> TranscribeOrTranslateAsResponseAsync(

global::Reka.TranscribeOrTranslateRequest request,
global::Reka.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
/// <summary>
/// Transcribe or translate audio<br/>
/// Transcribes audio to text and optionally translates it to a target language.<br/>
/// Supports three modes: transcription only, translation (text output), and<br/>
/// speech-to-speech translation (with audio output).
/// </summary>
/// <param name="audioUrl">
/// URL to a WAV audio file (http/https) or a base64-encoded data URI (data:audio/wav;base64,...).
/// </param>
Expand Down
Loading
Loading