diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.CancelARun.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.CancelARun.g.cs
index 5d6cde31f..7886febc7 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.CancelARun.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.CancelARun.g.cs
@@ -14,6 +14,7 @@ public partial class AssistantsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -47,11 +48,13 @@ partial void ProcessCancelARunResponseContent(
///
///
///
+ /// 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 CancelARunAsync(
string threadId,
string runId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -67,22 +70,43 @@ partial void ProcessCancelARunResponseContent(
securityRequirements: s_CancelARunSecurityRequirements,
operationName: "CancelARunAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/threads/{threadId}/runs/{runId}/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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/threads/{threadId}/runs/{runId}/cancel",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -92,113 +116,272 @@ partial void ProcessCancelARunResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareCancelARunRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- threadId: threadId,
- runId: runId);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareCancelARunRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ threadId: threadId,
+ runId: runId);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCancelARunResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CancelARun",
+ methodName: "CancelARunAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs/{runId}/cancel\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CancelARun",
+ methodName: "CancelARunAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs/{runId}/cancel\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessCancelARunResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CancelARun",
+ methodName: "CancelARunAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs/{runId}/cancel\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.RunObject.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.RunObject.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessCancelARunResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CancelARun",
+ methodName: "CancelARunAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs/{runId}/cancel\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CancelARun",
+ methodName: "CancelARunAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs/{runId}/cancel\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessCancelARunResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.RunObject.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.RunObject.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.CreateMessage.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.CreateMessage.g.cs
index 2a58a52a2..4190edef5 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.CreateMessage.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.CreateMessage.g.cs
@@ -14,6 +14,7 @@ public partial class AssistantsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -47,12 +48,14 @@ partial void ProcessCreateMessageResponseContent(
///
///
///
+ /// 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 CreateMessageAsync(
string threadId,
global::tryAGI.OpenAI.CreateMessageRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -70,22 +73,43 @@ partial void ProcessCreateMessageResponseContent(
securityRequirements: s_CreateMessageSecurityRequirements,
operationName: "CreateMessageAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/threads/{threadId}/messages",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/threads/{threadId}/messages",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -95,119 +119,278 @@ partial void ProcessCreateMessageResponseContent(
__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);
- PrepareCreateMessageRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- threadId: threadId,
- 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::tryAGI.OpenAI.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);
+ PrepareCreateMessageRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ threadId: threadId,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCreateMessageResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateMessage",
+ methodName: "CreateMessageAsync",
+ pathTemplate: "$\"/threads/{threadId}/messages\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateMessage",
+ methodName: "CreateMessageAsync",
+ pathTemplate: "$\"/threads/{threadId}/messages\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessCreateMessageResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateMessage",
+ methodName: "CreateMessageAsync",
+ pathTemplate: "$\"/threads/{threadId}/messages\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.MessageObject.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.MessageObject.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessCreateMessageResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateMessage",
+ methodName: "CreateMessageAsync",
+ pathTemplate: "$\"/threads/{threadId}/messages\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateMessage",
+ methodName: "CreateMessageAsync",
+ pathTemplate: "$\"/threads/{threadId}/messages\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessCreateMessageResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.MessageObject.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.MessageObject.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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 message.
@@ -221,6 +404,7 @@ partial void ProcessCreateMessageResponseContent(
///
///
///
+ /// 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 CreateMessageAsync(
@@ -229,6 +413,7 @@ partial void ProcessCreateMessageResponseContent(
global::tryAGI.OpenAI.OneOf>> content,
global::System.Collections.Generic.IList? attachments = default,
global::System.Collections.Generic.Dictionary? metadata = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.CreateMessageRequest
@@ -242,6 +427,7 @@ partial void ProcessCreateMessageResponseContent(
return await CreateMessageAsync(
threadId: threadId,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.CreateRun.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.CreateRun.g.cs
index 1a1802ac8..ebeb11270 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.CreateRun.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.CreateRun.g.cs
@@ -14,6 +14,7 @@ public partial class AssistantsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -50,6 +51,7 @@ partial void ProcessCreateRunResponseContent(
///
///
///
+ /// 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 CreateRunAsync(
@@ -57,6 +59,7 @@ partial void ProcessCreateRunResponseContent(
global::tryAGI.OpenAI.CreateRunRequest request,
global::System.Collections.Generic.IList? include = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -75,25 +78,46 @@ partial void ProcessCreateRunResponseContent(
securityRequirements: s_CreateRunSecurityRequirements,
operationName: "CreateRunAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/threads/{threadId}/runs",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("include[]", include, selector: static x => x.ToValueString(), delimiter: ",", explode: true)
- ;
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/threads/{threadId}/runs",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("include[]", include, selector: static x => x.ToValueString(), delimiter: ",", explode: true)
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,120 +127,279 @@ partial void ProcessCreateRunResponseContent(
__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);
- PrepareCreateRunRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- threadId: threadId,
- include: include,
- 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::tryAGI.OpenAI.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);
+ PrepareCreateRunRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ threadId: threadId,
+ include: include,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCreateRunResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateRun",
+ methodName: "CreateRunAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateRun",
+ methodName: "CreateRunAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessCreateRunResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateRun",
+ methodName: "CreateRunAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.RunObject.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.RunObject.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessCreateRunResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateRun",
+ methodName: "CreateRunAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateRun",
+ methodName: "CreateRunAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessCreateRunResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.RunObject.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.RunObject.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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 run.
@@ -276,6 +459,7 @@ partial void ProcessCreateRunResponseContent(
/// Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON.
/// **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.
///
+ /// 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 CreateRunAsync(
@@ -298,6 +482,7 @@ partial void ProcessCreateRunResponseContent(
global::tryAGI.OpenAI.AllOf? toolChoice = default,
bool? parallelToolCalls = default,
global::tryAGI.OpenAI.AssistantsApiResponseFormatOption? responseFormat = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.CreateRunRequest
@@ -325,6 +510,7 @@ partial void ProcessCreateRunResponseContent(
threadId: threadId,
include: include,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.CreateThread.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.CreateThread.g.cs
index 5a8f9f6bb..6b1b1f083 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.CreateThread.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.CreateThread.g.cs
@@ -14,6 +14,7 @@ public partial class AssistantsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -44,11 +45,13 @@ partial void ProcessCreateThreadResponseContent(
/// Create a thread.
///
///
+ /// 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 CreateThreadAsync(
global::tryAGI.OpenAI.CreateThreadRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -65,22 +68,43 @@ partial void ProcessCreateThreadResponseContent(
securityRequirements: s_CreateThreadSecurityRequirements,
operationName: "CreateThreadAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: "/threads",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: "/threads",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,118 +114,277 @@ partial void ProcessCreateThreadResponseContent(
__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);
- PrepareCreateThreadRequest(
- 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::tryAGI.OpenAI.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);
+ PrepareCreateThreadRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCreateThreadResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateThread",
+ methodName: "CreateThreadAsync",
+ pathTemplate: "\"/threads\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateThread",
+ methodName: "CreateThreadAsync",
+ pathTemplate: "\"/threads\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessCreateThreadResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateThread",
+ methodName: "CreateThreadAsync",
+ pathTemplate: "\"/threads\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.ThreadObject.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.ThreadObject.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessCreateThreadResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateThread",
+ methodName: "CreateThreadAsync",
+ pathTemplate: "\"/threads\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateThread",
+ methodName: "CreateThreadAsync",
+ pathTemplate: "\"/threads\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessCreateThreadResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.ThreadObject.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ThreadObject.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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 thread.
@@ -211,12 +394,14 @@ partial void ProcessCreateThreadResponseContent(
///
///
///
+ /// 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 CreateThreadAsync(
global::System.Collections.Generic.IList? messages = default,
global::tryAGI.OpenAI.CreateThreadRequestToolResources2? toolResources = default,
global::System.Collections.Generic.Dictionary? metadata = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.CreateThreadRequest
@@ -228,6 +413,7 @@ partial void ProcessCreateThreadResponseContent(
return await CreateThreadAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.CreateThreadAndRun.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.CreateThreadAndRun.g.cs
index 0003a0d4b..c3f3be90c 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.CreateThreadAndRun.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.CreateThreadAndRun.g.cs
@@ -14,6 +14,7 @@ public partial class AssistantsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -44,11 +45,13 @@ partial void ProcessCreateThreadAndRunResponseContent(
/// Create a thread and run it in one request.
///
///
+ /// 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 CreateThreadAndRunAsync(
global::tryAGI.OpenAI.CreateThreadAndRunRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -65,22 +68,43 @@ partial void ProcessCreateThreadAndRunResponseContent(
securityRequirements: s_CreateThreadAndRunSecurityRequirements,
operationName: "CreateThreadAndRunAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: "/threads/runs",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: "/threads/runs",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,118 +114,277 @@ partial void ProcessCreateThreadAndRunResponseContent(
__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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareCreateThreadAndRunRequest(
- 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);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareCreateThreadAndRunRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCreateThreadAndRunResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateThreadAndRun",
+ methodName: "CreateThreadAndRunAsync",
+ pathTemplate: "\"/threads/runs\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateThreadAndRun",
+ methodName: "CreateThreadAndRunAsync",
+ pathTemplate: "\"/threads/runs\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessCreateThreadAndRunResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateThreadAndRun",
+ methodName: "CreateThreadAndRunAsync",
+ pathTemplate: "\"/threads/runs\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.RunObject.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.RunObject.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessCreateThreadAndRunResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateThreadAndRun",
+ methodName: "CreateThreadAndRunAsync",
+ pathTemplate: "\"/threads/runs\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateThreadAndRun",
+ methodName: "CreateThreadAndRunAsync",
+ pathTemplate: "\"/threads/runs\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessCreateThreadAndRunResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.RunObject.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.RunObject.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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 thread and run it in one request.
@@ -259,6 +442,7 @@ partial void ProcessCreateThreadAndRunResponseContent(
/// Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON.
/// **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.
///
+ /// 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 CreateThreadAndRunAsync(
@@ -278,6 +462,7 @@ partial void ProcessCreateThreadAndRunResponseContent(
global::tryAGI.OpenAI.AllOf? toolChoice = default,
bool? parallelToolCalls = default,
global::tryAGI.OpenAI.AssistantsApiResponseFormatOption? responseFormat = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.CreateThreadAndRunRequest
@@ -302,6 +487,7 @@ partial void ProcessCreateThreadAndRunResponseContent(
return await CreateThreadAndRunAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.DeleteMessage.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.DeleteMessage.g.cs
index 1dbced9b3..0126e1dfd 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.DeleteMessage.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.DeleteMessage.g.cs
@@ -14,6 +14,7 @@ public partial class AssistantsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -47,11 +48,13 @@ partial void ProcessDeleteMessageResponseContent(
///
///
///
+ /// 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 DeleteMessageAsync(
string threadId,
string messageId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -67,22 +70,43 @@ partial void ProcessDeleteMessageResponseContent(
securityRequirements: s_DeleteMessageSecurityRequirements,
operationName: "DeleteMessageAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/threads/{threadId}/messages/{messageId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/threads/{threadId}/messages/{messageId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -92,113 +116,272 @@ partial void ProcessDeleteMessageResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareDeleteMessageRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- threadId: threadId,
- messageId: messageId);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareDeleteMessageRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ threadId: threadId,
+ messageId: messageId);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessDeleteMessageResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteMessage",
+ methodName: "DeleteMessageAsync",
+ pathTemplate: "$\"/threads/{threadId}/messages/{messageId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteMessage",
+ methodName: "DeleteMessageAsync",
+ pathTemplate: "$\"/threads/{threadId}/messages/{messageId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessDeleteMessageResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteMessage",
+ methodName: "DeleteMessageAsync",
+ pathTemplate: "$\"/threads/{threadId}/messages/{messageId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.DeleteMessageResponse.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.DeleteMessageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessDeleteMessageResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteMessage",
+ methodName: "DeleteMessageAsync",
+ pathTemplate: "$\"/threads/{threadId}/messages/{messageId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteMessage",
+ methodName: "DeleteMessageAsync",
+ pathTemplate: "$\"/threads/{threadId}/messages/{messageId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessDeleteMessageResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.DeleteMessageResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.DeleteMessageResponse.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.DeleteThread.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.DeleteThread.g.cs
index 17cb4cea0..065ab9d51 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.DeleteThread.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.DeleteThread.g.cs
@@ -14,6 +14,7 @@ public partial class AssistantsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -44,10 +45,12 @@ partial void ProcessDeleteThreadResponseContent(
/// Delete a thread.
///
///
+ /// 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 DeleteThreadAsync(
string threadId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -62,22 +65,43 @@ partial void ProcessDeleteThreadResponseContent(
securityRequirements: s_DeleteThreadSecurityRequirements,
operationName: "DeleteThreadAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/threads/{threadId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/threads/{threadId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -87,112 +111,271 @@ partial void ProcessDeleteThreadResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareDeleteThreadRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- threadId: threadId);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareDeleteThreadRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ threadId: threadId);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessDeleteThreadResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteThread",
+ methodName: "DeleteThreadAsync",
+ pathTemplate: "$\"/threads/{threadId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteThread",
+ methodName: "DeleteThreadAsync",
+ pathTemplate: "$\"/threads/{threadId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessDeleteThreadResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteThread",
+ methodName: "DeleteThreadAsync",
+ pathTemplate: "$\"/threads/{threadId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.DeleteThreadResponse.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.DeleteThreadResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessDeleteThreadResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteThread",
+ methodName: "DeleteThreadAsync",
+ pathTemplate: "$\"/threads/{threadId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteThread",
+ methodName: "DeleteThreadAsync",
+ pathTemplate: "$\"/threads/{threadId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessDeleteThreadResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.DeleteThreadResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.DeleteThreadResponse.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.ListMessages.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.ListMessages.g.cs
index 751347f3e..53ad2d7c8 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.ListMessages.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.ListMessages.g.cs
@@ -14,6 +14,7 @@ public partial class AssistantsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -63,6 +64,7 @@ partial void ProcessListMessagesResponseContent(
///
///
///
+ /// 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 ListMessagesAsync(
@@ -72,6 +74,7 @@ partial void ProcessListMessagesResponseContent(
string? after = default,
string? before = default,
string? runId = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -91,29 +94,50 @@ partial void ProcessListMessagesResponseContent(
securityRequirements: s_ListMessagesSecurityRequirements,
operationName: "ListMessagesAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/threads/{threadId}/messages",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("limit", limit?.ToString())
- .AddOptionalParameter("order", order?.ToValueString())
- .AddOptionalParameter("after", after)
- .AddOptionalParameter("before", before)
- .AddOptionalParameter("run_id", runId)
- ;
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/threads/{threadId}/messages",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("limit", limit?.ToString())
+ .AddOptionalParameter("order", order?.ToValueString())
+ .AddOptionalParameter("after", after)
+ .AddOptionalParameter("before", before)
+ .AddOptionalParameter("run_id", runId)
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -123,117 +147,276 @@ partial void ProcessListMessagesResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareListMessagesRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- threadId: threadId,
- limit: limit,
- order: order,
- after: after,
- before: before,
- runId: runId);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareListMessagesRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ threadId: threadId,
+ limit: limit,
+ order: order,
+ after: after,
+ before: before,
+ runId: runId);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessListMessagesResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListMessages",
+ methodName: "ListMessagesAsync",
+ pathTemplate: "$\"/threads/{threadId}/messages\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListMessages",
+ methodName: "ListMessagesAsync",
+ pathTemplate: "$\"/threads/{threadId}/messages\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessListMessagesResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListMessages",
+ methodName: "ListMessagesAsync",
+ pathTemplate: "$\"/threads/{threadId}/messages\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.ListMessagesResponse.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.ListMessagesResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessListMessagesResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListMessages",
+ methodName: "ListMessagesAsync",
+ pathTemplate: "$\"/threads/{threadId}/messages\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListMessages",
+ methodName: "ListMessagesAsync",
+ pathTemplate: "$\"/threads/{threadId}/messages\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessListMessagesResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.ListMessagesResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ListMessagesResponse.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.ListRunSteps.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.ListRunSteps.g.cs
index d56a48b06..c636bb6e8 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.ListRunSteps.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.ListRunSteps.g.cs
@@ -14,6 +14,7 @@ public partial class AssistantsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -66,6 +67,7 @@ partial void ProcessListRunStepsResponseContent(
///
///
///
+ /// 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 ListRunStepsAsync(
@@ -76,6 +78,7 @@ partial void ProcessListRunStepsResponseContent(
string? after = default,
string? before = default,
global::System.Collections.Generic.IList? include = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -96,29 +99,50 @@ partial void ProcessListRunStepsResponseContent(
securityRequirements: s_ListRunStepsSecurityRequirements,
operationName: "ListRunStepsAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/threads/{threadId}/runs/{runId}/steps",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("limit", limit?.ToString())
- .AddOptionalParameter("order", order?.ToValueString())
- .AddOptionalParameter("after", after)
- .AddOptionalParameter("before", before)
- .AddOptionalParameter("include[]", include, selector: static x => x.ToValueString(), delimiter: ",", explode: true)
- ;
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/threads/{threadId}/runs/{runId}/steps",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("limit", limit?.ToString())
+ .AddOptionalParameter("order", order?.ToValueString())
+ .AddOptionalParameter("after", after)
+ .AddOptionalParameter("before", before)
+ .AddOptionalParameter("include[]", include, selector: static x => x.ToValueString(), delimiter: ",", explode: true)
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -128,118 +152,277 @@ partial void ProcessListRunStepsResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareListRunStepsRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- threadId: threadId,
- runId: runId,
- limit: limit,
- order: order,
- after: after,
- before: before,
- include: include);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareListRunStepsRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ threadId: threadId,
+ runId: runId,
+ limit: limit,
+ order: order,
+ after: after,
+ before: before,
+ include: include);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessListRunStepsResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListRunSteps",
+ methodName: "ListRunStepsAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs/{runId}/steps\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListRunSteps",
+ methodName: "ListRunStepsAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs/{runId}/steps\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessListRunStepsResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListRunSteps",
+ methodName: "ListRunStepsAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs/{runId}/steps\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.ListRunStepsResponse.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.ListRunStepsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessListRunStepsResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListRunSteps",
+ methodName: "ListRunStepsAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs/{runId}/steps\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListRunSteps",
+ methodName: "ListRunStepsAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs/{runId}/steps\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessListRunStepsResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.ListRunStepsResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ListRunStepsResponse.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.ListRuns.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.ListRuns.g.cs
index af8183d99..58d637d25 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.ListRuns.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.ListRuns.g.cs
@@ -14,6 +14,7 @@ public partial class AssistantsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -60,6 +61,7 @@ partial void ProcessListRunsResponseContent(
///
///
///
+ /// 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 ListRunsAsync(
@@ -68,6 +70,7 @@ partial void ProcessListRunsResponseContent(
global::tryAGI.OpenAI.ListRunsOrder? order = default,
string? after = default,
string? before = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -86,28 +89,49 @@ partial void ProcessListRunsResponseContent(
securityRequirements: s_ListRunsSecurityRequirements,
operationName: "ListRunsAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/threads/{threadId}/runs",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("limit", limit?.ToString())
- .AddOptionalParameter("order", order?.ToValueString())
- .AddOptionalParameter("after", after)
- .AddOptionalParameter("before", before)
- ;
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/threads/{threadId}/runs",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("limit", limit?.ToString())
+ .AddOptionalParameter("order", order?.ToValueString())
+ .AddOptionalParameter("after", after)
+ .AddOptionalParameter("before", before)
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -117,116 +141,275 @@ partial void ProcessListRunsResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareListRunsRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- threadId: threadId,
- limit: limit,
- order: order,
- after: after,
- before: before);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareListRunsRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ threadId: threadId,
+ limit: limit,
+ order: order,
+ after: after,
+ before: before);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessListRunsResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListRuns",
+ methodName: "ListRunsAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListRuns",
+ methodName: "ListRunsAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessListRunsResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListRuns",
+ methodName: "ListRunsAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.ListRunsResponse.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.ListRunsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessListRunsResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListRuns",
+ methodName: "ListRunsAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListRuns",
+ methodName: "ListRunsAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessListRunsResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.ListRunsResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ListRunsResponse.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.ModifyMessage.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.ModifyMessage.g.cs
index 897d27ee9..1110dbda6 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.ModifyMessage.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.ModifyMessage.g.cs
@@ -14,6 +14,7 @@ public partial class AssistantsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -50,6 +51,7 @@ partial void ProcessModifyMessageResponseContent(
///
///
///
+ /// 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 ModifyMessageAsync(
@@ -57,6 +59,7 @@ partial void ProcessModifyMessageResponseContent(
string messageId,
global::tryAGI.OpenAI.ModifyMessageRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -75,22 +78,43 @@ partial void ProcessModifyMessageResponseContent(
securityRequirements: s_ModifyMessageSecurityRequirements,
operationName: "ModifyMessageAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/threads/{threadId}/messages/{messageId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/threads/{threadId}/messages/{messageId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,120 +124,279 @@ partial void ProcessModifyMessageResponseContent(
__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);
- PrepareModifyMessageRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- threadId: threadId,
- messageId: messageId,
- 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::tryAGI.OpenAI.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);
+ PrepareModifyMessageRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ threadId: threadId,
+ messageId: messageId,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessModifyMessageResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyMessage",
+ methodName: "ModifyMessageAsync",
+ pathTemplate: "$\"/threads/{threadId}/messages/{messageId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyMessage",
+ methodName: "ModifyMessageAsync",
+ pathTemplate: "$\"/threads/{threadId}/messages/{messageId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessModifyMessageResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyMessage",
+ methodName: "ModifyMessageAsync",
+ pathTemplate: "$\"/threads/{threadId}/messages/{messageId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.MessageObject.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.MessageObject.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessModifyMessageResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyMessage",
+ methodName: "ModifyMessageAsync",
+ pathTemplate: "$\"/threads/{threadId}/messages/{messageId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyMessage",
+ methodName: "ModifyMessageAsync",
+ pathTemplate: "$\"/threads/{threadId}/messages/{messageId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessModifyMessageResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.MessageObject.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.MessageObject.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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();
+ }
}
///
/// Modifies a message.
@@ -221,12 +404,14 @@ partial void ProcessModifyMessageResponseContent(
///
///
///
+ /// 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 ModifyMessageAsync(
string threadId,
string messageId,
global::System.Collections.Generic.Dictionary? metadata = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.ModifyMessageRequest
@@ -238,6 +423,7 @@ partial void ProcessModifyMessageResponseContent(
threadId: threadId,
messageId: messageId,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.ModifyRun.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.ModifyRun.g.cs
index ec7d74def..8a1c659fa 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.ModifyRun.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.ModifyRun.g.cs
@@ -14,6 +14,7 @@ public partial class AssistantsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -50,6 +51,7 @@ partial void ProcessModifyRunResponseContent(
///
///
///
+ /// 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 ModifyRunAsync(
@@ -57,6 +59,7 @@ partial void ProcessModifyRunResponseContent(
string runId,
global::tryAGI.OpenAI.ModifyRunRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -75,22 +78,43 @@ partial void ProcessModifyRunResponseContent(
securityRequirements: s_ModifyRunSecurityRequirements,
operationName: "ModifyRunAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/threads/{threadId}/runs/{runId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/threads/{threadId}/runs/{runId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,120 +124,279 @@ partial void ProcessModifyRunResponseContent(
__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);
- PrepareModifyRunRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- threadId: threadId,
- runId: runId,
- 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::tryAGI.OpenAI.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);
+ PrepareModifyRunRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ threadId: threadId,
+ runId: runId,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessModifyRunResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyRun",
+ methodName: "ModifyRunAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs/{runId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyRun",
+ methodName: "ModifyRunAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs/{runId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessModifyRunResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyRun",
+ methodName: "ModifyRunAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs/{runId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.RunObject.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.RunObject.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessModifyRunResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyRun",
+ methodName: "ModifyRunAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs/{runId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyRun",
+ methodName: "ModifyRunAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs/{runId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessModifyRunResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.RunObject.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.RunObject.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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();
+ }
}
///
/// Modifies a run.
@@ -221,12 +404,14 @@ partial void ProcessModifyRunResponseContent(
///
///
///
+ /// 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 ModifyRunAsync(
string threadId,
string runId,
global::System.Collections.Generic.Dictionary? metadata = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.ModifyRunRequest
@@ -238,6 +423,7 @@ partial void ProcessModifyRunResponseContent(
threadId: threadId,
runId: runId,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.ModifyThread.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.ModifyThread.g.cs
index 52f0466ca..8300af76d 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.ModifyThread.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.ModifyThread.g.cs
@@ -14,6 +14,7 @@ public partial class AssistantsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -47,12 +48,14 @@ partial void ProcessModifyThreadResponseContent(
///
///
///
+ /// 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 ModifyThreadAsync(
string threadId,
global::tryAGI.OpenAI.ModifyThreadRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -70,22 +73,43 @@ partial void ProcessModifyThreadResponseContent(
securityRequirements: s_ModifyThreadSecurityRequirements,
operationName: "ModifyThreadAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/threads/{threadId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/threads/{threadId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -95,119 +119,278 @@ partial void ProcessModifyThreadResponseContent(
__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);
- PrepareModifyThreadRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- threadId: threadId,
- 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::tryAGI.OpenAI.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);
+ PrepareModifyThreadRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ threadId: threadId,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessModifyThreadResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyThread",
+ methodName: "ModifyThreadAsync",
+ pathTemplate: "$\"/threads/{threadId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyThread",
+ methodName: "ModifyThreadAsync",
+ pathTemplate: "$\"/threads/{threadId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessModifyThreadResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyThread",
+ methodName: "ModifyThreadAsync",
+ pathTemplate: "$\"/threads/{threadId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.ThreadObject.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.ThreadObject.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessModifyThreadResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyThread",
+ methodName: "ModifyThreadAsync",
+ pathTemplate: "$\"/threads/{threadId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyThread",
+ methodName: "ModifyThreadAsync",
+ pathTemplate: "$\"/threads/{threadId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessModifyThreadResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.ThreadObject.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ThreadObject.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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();
+ }
}
///
/// Modifies a thread.
@@ -215,12 +398,14 @@ partial void ProcessModifyThreadResponseContent(
///
///
///
+ /// 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 ModifyThreadAsync(
string threadId,
global::tryAGI.OpenAI.ModifyThreadRequestToolResources2? toolResources = default,
global::System.Collections.Generic.Dictionary? metadata = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.ModifyThreadRequest
@@ -232,6 +417,7 @@ partial void ProcessModifyThreadResponseContent(
return await ModifyThreadAsync(
threadId: threadId,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.RetrieveMessage.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.RetrieveMessage.g.cs
index 0d2532e04..27495a250 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.RetrieveMessage.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.RetrieveMessage.g.cs
@@ -14,6 +14,7 @@ public partial class AssistantsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -47,11 +48,13 @@ partial void ProcessRetrieveMessageResponseContent(
///
///
///
+ /// 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 RetrieveMessageAsync(
string threadId,
string messageId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -67,22 +70,43 @@ partial void ProcessRetrieveMessageResponseContent(
securityRequirements: s_RetrieveMessageSecurityRequirements,
operationName: "RetrieveMessageAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/threads/{threadId}/messages/{messageId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/threads/{threadId}/messages/{messageId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,113 +116,272 @@ partial void ProcessRetrieveMessageResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareRetrieveMessageRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- threadId: threadId,
- messageId: messageId);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareRetrieveMessageRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ threadId: threadId,
+ messageId: messageId);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessRetrieveMessageResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveMessage",
+ methodName: "RetrieveMessageAsync",
+ pathTemplate: "$\"/threads/{threadId}/messages/{messageId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveMessage",
+ methodName: "RetrieveMessageAsync",
+ pathTemplate: "$\"/threads/{threadId}/messages/{messageId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessRetrieveMessageResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveMessage",
+ methodName: "RetrieveMessageAsync",
+ pathTemplate: "$\"/threads/{threadId}/messages/{messageId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.MessageObject.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.MessageObject.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessRetrieveMessageResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveMessage",
+ methodName: "RetrieveMessageAsync",
+ pathTemplate: "$\"/threads/{threadId}/messages/{messageId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveMessage",
+ methodName: "RetrieveMessageAsync",
+ pathTemplate: "$\"/threads/{threadId}/messages/{messageId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessRetrieveMessageResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.MessageObject.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.MessageObject.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.RetrieveRun.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.RetrieveRun.g.cs
index ff5c258f6..c0406330a 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.RetrieveRun.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.RetrieveRun.g.cs
@@ -14,6 +14,7 @@ public partial class AssistantsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -47,11 +48,13 @@ partial void ProcessRetrieveRunResponseContent(
///
///
///
+ /// 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 RetrieveRunAsync(
string threadId,
string runId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -67,22 +70,43 @@ partial void ProcessRetrieveRunResponseContent(
securityRequirements: s_RetrieveRunSecurityRequirements,
operationName: "RetrieveRunAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/threads/{threadId}/runs/{runId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/threads/{threadId}/runs/{runId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,113 +116,272 @@ partial void ProcessRetrieveRunResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareRetrieveRunRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- threadId: threadId,
- runId: runId);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareRetrieveRunRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ threadId: threadId,
+ runId: runId);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessRetrieveRunResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveRun",
+ methodName: "RetrieveRunAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs/{runId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveRun",
+ methodName: "RetrieveRunAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs/{runId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessRetrieveRunResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveRun",
+ methodName: "RetrieveRunAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs/{runId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.RunObject.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.RunObject.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessRetrieveRunResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveRun",
+ methodName: "RetrieveRunAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs/{runId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveRun",
+ methodName: "RetrieveRunAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs/{runId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessRetrieveRunResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.RunObject.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.RunObject.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.RetrieveRunStep.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.RetrieveRunStep.g.cs
index ae1c590b6..2e1d19f89 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.RetrieveRunStep.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.RetrieveRunStep.g.cs
@@ -14,6 +14,7 @@ public partial class AssistantsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -53,6 +54,7 @@ partial void ProcessRetrieveRunStepResponseContent(
///
///
///
+ /// 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 RetrieveRunStepAsync(
@@ -60,6 +62,7 @@ partial void ProcessRetrieveRunStepResponseContent(
string runId,
string stepId,
global::System.Collections.Generic.IList? include = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -77,25 +80,46 @@ partial void ProcessRetrieveRunStepResponseContent(
securityRequirements: s_RetrieveRunStepSecurityRequirements,
operationName: "RetrieveRunStepAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/threads/{threadId}/runs/{runId}/steps/{stepId}",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("include[]", include, selector: static x => x.ToValueString(), delimiter: ",", explode: true)
- ;
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/threads/{threadId}/runs/{runId}/steps/{stepId}",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("include[]", include, selector: static x => x.ToValueString(), delimiter: ",", explode: true)
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -105,115 +129,274 @@ partial void ProcessRetrieveRunStepResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareRetrieveRunStepRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- threadId: threadId,
- runId: runId,
- stepId: stepId,
- include: include);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareRetrieveRunStepRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ threadId: threadId,
+ runId: runId,
+ stepId: stepId,
+ include: include);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessRetrieveRunStepResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveRunStep",
+ methodName: "RetrieveRunStepAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs/{runId}/steps/{stepId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveRunStep",
+ methodName: "RetrieveRunStepAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs/{runId}/steps/{stepId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessRetrieveRunStepResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveRunStep",
+ methodName: "RetrieveRunStepAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs/{runId}/steps/{stepId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.RunStepObject.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.RunStepObject.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessRetrieveRunStepResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveRunStep",
+ methodName: "RetrieveRunStepAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs/{runId}/steps/{stepId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveRunStep",
+ methodName: "RetrieveRunStepAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs/{runId}/steps/{stepId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessRetrieveRunStepResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.RunStepObject.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.RunStepObject.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.RetrieveThread.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.RetrieveThread.g.cs
index dc35b8af9..af1f883ba 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.RetrieveThread.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.RetrieveThread.g.cs
@@ -14,6 +14,7 @@ public partial class AssistantsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -44,10 +45,12 @@ partial void ProcessRetrieveThreadResponseContent(
/// Retrieves a thread.
///
///
+ /// 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 RetrieveThreadAsync(
string threadId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -62,22 +65,43 @@ partial void ProcessRetrieveThreadResponseContent(
securityRequirements: s_RetrieveThreadSecurityRequirements,
operationName: "RetrieveThreadAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/threads/{threadId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/threads/{threadId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,112 +111,271 @@ partial void ProcessRetrieveThreadResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareRetrieveThreadRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- threadId: threadId);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareRetrieveThreadRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ threadId: threadId);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessRetrieveThreadResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveThread",
+ methodName: "RetrieveThreadAsync",
+ pathTemplate: "$\"/threads/{threadId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveThread",
+ methodName: "RetrieveThreadAsync",
+ pathTemplate: "$\"/threads/{threadId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessRetrieveThreadResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveThread",
+ methodName: "RetrieveThreadAsync",
+ pathTemplate: "$\"/threads/{threadId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.ThreadObject.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.ThreadObject.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessRetrieveThreadResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveThread",
+ methodName: "RetrieveThreadAsync",
+ pathTemplate: "$\"/threads/{threadId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveThread",
+ methodName: "RetrieveThreadAsync",
+ pathTemplate: "$\"/threads/{threadId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessRetrieveThreadResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.ThreadObject.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ThreadObject.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.SubmitToolOutputsToRun.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.SubmitToolOutputsToRun.g.cs
index a169a124f..b7c2fd275 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.SubmitToolOutputsToRun.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.SubmitToolOutputsToRun.g.cs
@@ -14,6 +14,7 @@ public partial class AssistantsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -50,6 +51,7 @@ partial void ProcessSubmitToolOutputsToRunResponseContent(
///
///
///
+ /// 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 SubmitToolOutputsToRunAsync(
@@ -57,6 +59,7 @@ partial void ProcessSubmitToolOutputsToRunResponseContent(
string runId,
global::tryAGI.OpenAI.SubmitToolOutputsRunRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -75,22 +78,43 @@ partial void ProcessSubmitToolOutputsToRunResponseContent(
securityRequirements: s_SubmitToolOutputsToRunSecurityRequirements,
operationName: "SubmitToolOutputsToRunAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/threads/{threadId}/runs/{runId}/submit_tool_outputs",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/threads/{threadId}/runs/{runId}/submit_tool_outputs",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,120 +124,279 @@ partial void ProcessSubmitToolOutputsToRunResponseContent(
__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);
- PrepareSubmitToolOutputsToRunRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- threadId: threadId,
- runId: runId,
- 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::tryAGI.OpenAI.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);
+ PrepareSubmitToolOutputsToRunRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ threadId: threadId,
+ runId: runId,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessSubmitToolOutputsToRunResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "SubmitToolOutputsToRun",
+ methodName: "SubmitToolOutputsToRunAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs/{runId}/submit_tool_outputs\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "SubmitToolOutputsToRun",
+ methodName: "SubmitToolOutputsToRunAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs/{runId}/submit_tool_outputs\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessSubmitToolOutputsToRunResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "SubmitToolOutputsToRun",
+ methodName: "SubmitToolOutputsToRunAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs/{runId}/submit_tool_outputs\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.RunObject.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.RunObject.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessSubmitToolOutputsToRunResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "SubmitToolOutputsToRun",
+ methodName: "SubmitToolOutputsToRunAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs/{runId}/submit_tool_outputs\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "SubmitToolOutputsToRun",
+ methodName: "SubmitToolOutputsToRunAsync",
+ pathTemplate: "$\"/threads/{threadId}/runs/{runId}/submit_tool_outputs\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessSubmitToolOutputsToRunResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.RunObject.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.RunObject.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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();
+ }
}
///
/// When a run has the `status: "requires_action"` and `required_action.type` is `submit_tool_outputs`, this endpoint can be used to submit the outputs from the tool calls once they're all completed. All outputs must be submitted in a single request.
@@ -224,6 +407,7 @@ partial void ProcessSubmitToolOutputsToRunResponseContent(
/// A list of tools for which the outputs are being submitted.
///
///
+ /// 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 SubmitToolOutputsToRunAsync(
@@ -231,6 +415,7 @@ partial void ProcessSubmitToolOutputsToRunResponseContent(
string runId,
global::System.Collections.Generic.IList toolOutputs,
bool? stream = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.SubmitToolOutputsRunRequest
@@ -243,6 +428,7 @@ partial void ProcessSubmitToolOutputsToRunResponseContent(
threadId: threadId,
runId: runId,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.g.cs
index 35952340a..e0a13425e 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AssistantsClient.g.cs
@@ -31,6 +31,9 @@ public sealed partial class AssistantsClient : global::tryAGI.OpenAI.IAssistants
#if DEBUG
= true;
#endif
+
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
///
///
///
@@ -50,11 +53,37 @@ public AssistantsClient(
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 AssistantsClient.
+ /// 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 AssistantsClient(
+ global::System.Net.Http.HttpClient? httpClient = null,
+ global::System.Uri? baseUri = null,
+ global::System.Collections.Generic.List? authorizations = null,
+ global::tryAGI.OpenAI.AutoSDKClientOptions? options = null,
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::tryAGI.OpenAI.AutoSDKClientOptions();
_disposeHttpClient = disposeHttpClient;
Initialized(HttpClient);
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateSpeech.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateSpeech.g.cs
index 0e5bf56fb..e30db0892 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateSpeech.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateSpeech.g.cs
@@ -14,6 +14,7 @@ public partial class AudioClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -40,11 +41,13 @@ partial void ProcessCreateSpeechResponse(
/// Returns the audio file content, or a stream of audio events.
///
///
+ /// 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 CreateSpeechAsync(
global::tryAGI.OpenAI.CreateSpeechRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
[global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -61,22 +64,43 @@ partial void ProcessCreateSpeechResponse(
securityRequirements: s_CreateSpeechSecurityRequirements,
operationName: "CreateSpeechAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: "/audio/speech",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -86,95 +110,254 @@ partial void ProcessCreateSpeechResponse(
__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);
- PrepareCreateSpeechRequest(
- 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::tryAGI.OpenAI.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);
+ PrepareCreateSpeechRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCreateSpeechResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateSpeech",
+ methodName: "CreateSpeechAsync",
+ pathTemplate: "\"/audio/speech\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateSpeech",
+ methodName: "CreateSpeechAsync",
+ pathTemplate: "\"/audio/speech\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateSpeech",
+ methodName: "CreateSpeechAsync",
+ pathTemplate: "\"/audio/speech\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception)
+
+ if (__response == null)
{
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::tryAGI.OpenAI.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);
+ ProcessCreateSpeechResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateSpeech",
+ methodName: "CreateSpeechAsync",
+ pathTemplate: "\"/audio/speech\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
{
- yield break;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateSpeech",
+ methodName: "CreateSpeechAsync",
+ pathTemplate: "\"/audio/speech\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- var __streamedResponse = global::tryAGI.OpenAI.CreateSpeechResponseStreamEvent.FromJson(__content, JsonSerializerContext) ??
- throw new global::tryAGI.OpenAI.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.CreateSpeechResponseStreamEvent.FromJson(__content, JsonSerializerContext) ??
+ throw new global::tryAGI.OpenAI.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();
}
}
///
@@ -205,6 +388,7 @@ partial void ProcessCreateSpeechResponse(
/// The format to stream the audio in. Supported formats are `sse` and `audio`. `sse` is not supported for `tts-1` or `tts-1-hd`.
/// Default Value: audio
///
+ /// 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 CreateSpeechAsync(
@@ -215,6 +399,7 @@ partial void ProcessCreateSpeechResponse(
global::tryAGI.OpenAI.CreateSpeechRequestResponseFormat? responseFormat = default,
double? speed = default,
global::tryAGI.OpenAI.CreateSpeechRequestStreamFormat? streamFormat = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
[global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.CreateSpeechRequest
@@ -230,6 +415,7 @@ partial void ProcessCreateSpeechResponse(
var __enumerable = CreateSpeechAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken);
await foreach (var __response in __enumerable)
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateTranscription.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateTranscription.g.cs
index ff0aaa5fe..ed2005b5f 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateTranscription.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateTranscription.g.cs
@@ -14,6 +14,7 @@ public partial class AudioClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -46,11 +47,13 @@ partial void ProcessCreateTranscriptionResponseContent(
/// format, or a stream of transcript events.
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task> CreateTranscriptionAsync(
global::tryAGI.OpenAI.CreateTranscriptionRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -83,22 +86,43 @@ partial void ProcessCreateTranscriptionResponseContent(
securityRequirements: s_CreateTranscriptionSecurityRequirements,
operationName: "CreateTranscriptionAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: "/audio/transcriptions",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -108,196 +132,355 @@ partial void ProcessCreateTranscriptionResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
- using var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
- 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;
- }
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent(request.Model.ToString() ?? string.Empty),
- name: "\"model\"");
- if (request.Language != default)
- {
-
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"{request.Language}"),
- name: "\"language\"");
- }
- if (request.Prompt != 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.ResponseFormat?.ToValueString()}"),
- name: "\"response_format\"");
- }
- if (request.Temperature != default)
- {
-
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"{request.Temperature}"),
- name: "\"temperature\"");
- }
- if (request.Include != default)
- {
-
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.Include, x => x.ToValueString()))}]"),
- name: "\"include\"");
- }
- if (request.TimestampGranularities != default)
- {
-
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.TimestampGranularities, x => x.ToValueString()))}]"),
- name: "\"timestamp_granularities\"");
- }
- if (request.Stream != default)
- {
-
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"{request.Stream}"),
- name: "\"stream\"");
- }
- if (request.ChunkingStrategy != default)
- {
-
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"{request.ChunkingStrategy}"),
- name: "\"chunking_strategy\"");
- }
- if (request.KnownSpeakerNames != default)
- {
-
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.KnownSpeakerNames, x => x))}]"),
- name: "\"known_speaker_names\"");
- }
- if (request.KnownSpeakerReferences != default)
- {
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ 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;
+ }
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Model.ToString() ?? string.Empty),
+ name: "\"model\"");
+ if (request.Language != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"{request.Language}"),
+ name: "\"language\"");
+ }
+ if (request.Prompt != 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.ResponseFormat?.ToValueString()}"),
+ name: "\"response_format\"");
+ }
+ if (request.Temperature != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"{request.Temperature}"),
+ name: "\"temperature\"");
+ }
+ if (request.Include != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.Include, x => x.ToValueString()))}]"),
+ name: "\"include\"");
+ }
+ if (request.TimestampGranularities != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.TimestampGranularities, x => x.ToValueString()))}]"),
+ name: "\"timestamp_granularities\"");
+ }
+ if (request.Stream != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"{request.Stream}"),
+ name: "\"stream\"");
+ }
+ if (request.ChunkingStrategy != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"{request.ChunkingStrategy}"),
+ name: "\"chunking_strategy\"");
+ }
+ if (request.KnownSpeakerNames != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.KnownSpeakerNames, x => x))}]"),
+ name: "\"known_speaker_names\"");
+ }
+ if (request.KnownSpeakerReferences != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.KnownSpeakerReferences, x => x))}]"),
+ name: "\"known_speaker_references\"");
+ }
+ __httpRequest.Content = __httpRequestContent;
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareCreateTranscriptionRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.KnownSpeakerReferences, x => x))}]"),
- name: "\"known_speaker_references\"");
+ return __httpRequest;
}
- __httpRequest.Content = __httpRequestContent;
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareCreateTranscriptionRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- request: request);
-
- using var __response = await HttpClient.SendAsync(
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateTranscription",
+ methodName: "CreateTranscriptionAsync",
+ pathTemplate: "\"/audio/transcriptions\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
request: __httpRequest,
completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateTranscription",
+ methodName: "CreateTranscriptionAsync",
+ pathTemplate: "\"/audio/transcriptions\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCreateTranscriptionResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateTranscription",
+ methodName: "CreateTranscriptionAsync",
+ pathTemplate: "\"/audio/transcriptions\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ break;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessCreateTranscriptionResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
- try
+ using (__response)
{
- __response.EnsureSuccessStatusCode();
- return
- global::tryAGI.OpenAI.OneOf.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
- }
- catch (global::System.Exception __ex)
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessCreateTranscriptionResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- throw new global::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateTranscription",
+ methodName: "CreateTranscriptionAsync",
+ pathTemplate: "\"/audio/transcriptions\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.OneOf.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateTranscription",
+ methodName: "CreateTranscriptionAsync",
+ pathTemplate: "\"/audio/transcriptions\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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)
- {
- }
- throw new global::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- 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);
+ ProcessCreateTranscriptionResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.OneOf.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.OneOf.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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();
+ }
}
///
/// Transcribes audio into the input language.
@@ -347,6 +530,7 @@ partial void ProcessCreateTranscriptionResponseContent(
///
/// Optional list of audio samples (as [data URLs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs)) that contain known speaker references matching `known_speaker_names[]`. Each sample must be between 2 and 10 seconds, and can use any of the same input audio formats supported by `file`.
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task> CreateTranscriptionAsync(
@@ -362,6 +546,7 @@ partial void ProcessCreateTranscriptionResponseContent(
global::tryAGI.OpenAI.AnyOf? chunkingStrategy = default,
global::System.Collections.Generic.IList? knownSpeakerNames = default,
global::System.Collections.Generic.IList? knownSpeakerReferences = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.CreateTranscriptionRequest
@@ -383,6 +568,7 @@ partial void ProcessCreateTranscriptionResponseContent(
return await CreateTranscriptionAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateTranscriptionAsStream.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateTranscriptionAsStream.g.cs
index 07e077340..c9698bc32 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateTranscriptionAsStream.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateTranscriptionAsStream.g.cs
@@ -14,6 +14,7 @@ public partial class AudioClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -41,11 +42,13 @@ partial void ProcessCreateTranscriptionAsStreamResponse(
/// format, or a stream of transcript events.
///
///
+ /// 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 CreateTranscriptionAsStreamAsync(
global::tryAGI.OpenAI.CreateTranscriptionRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
[global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -78,22 +81,43 @@ partial void ProcessCreateTranscriptionAsStreamResponse(
securityRequirements: s_CreateTranscriptionAsStreamSecurityRequirements,
operationName: "CreateTranscriptionAsStreamAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: "/audio/transcriptions",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,173 +127,332 @@ partial void ProcessCreateTranscriptionAsStreamResponse(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
- using var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
- 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;
- }
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent(request.Model.ToString() ?? string.Empty),
- name: "\"model\"");
- if (request.Language != default)
- {
-
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"{request.Language}"),
- name: "\"language\"");
- }
- if (request.Prompt != 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.ResponseFormat?.ToValueString()}"),
- name: "\"response_format\"");
- }
- if (request.Temperature != default)
- {
-
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"{request.Temperature}"),
- name: "\"temperature\"");
- }
- if (request.Include != default)
- {
-
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.Include, x => x.ToValueString()))}]"),
- name: "\"include\"");
- }
- if (request.TimestampGranularities != default)
- {
-
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.TimestampGranularities, x => x.ToValueString()))}]"),
- name: "\"timestamp_granularities\"");
- }
- if (request.Stream != default)
- {
-
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"{request.Stream}"),
- name: "\"stream\"");
- }
- if (request.ChunkingStrategy != default)
- {
-
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"{request.ChunkingStrategy}"),
- name: "\"chunking_strategy\"");
- }
- if (request.KnownSpeakerNames != default)
- {
-
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.KnownSpeakerNames, x => x))}]"),
- name: "\"known_speaker_names\"");
- }
- if (request.KnownSpeakerReferences != default)
- {
-
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.KnownSpeakerReferences, x => x))}]"),
- name: "\"known_speaker_references\"");
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ 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;
+ }
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Model.ToString() ?? string.Empty),
+ name: "\"model\"");
+ if (request.Language != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"{request.Language}"),
+ name: "\"language\"");
+ }
+ if (request.Prompt != 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.ResponseFormat?.ToValueString()}"),
+ name: "\"response_format\"");
+ }
+ if (request.Temperature != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"{request.Temperature}"),
+ name: "\"temperature\"");
+ }
+ if (request.Include != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.Include, x => x.ToValueString()))}]"),
+ name: "\"include\"");
+ }
+ if (request.TimestampGranularities != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.TimestampGranularities, x => x.ToValueString()))}]"),
+ name: "\"timestamp_granularities\"");
+ }
+ if (request.Stream != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"{request.Stream}"),
+ name: "\"stream\"");
+ }
+ if (request.ChunkingStrategy != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"{request.ChunkingStrategy}"),
+ name: "\"chunking_strategy\"");
+ }
+ if (request.KnownSpeakerNames != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.KnownSpeakerNames, x => x))}]"),
+ name: "\"known_speaker_names\"");
+ }
+ if (request.KnownSpeakerReferences != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.KnownSpeakerReferences, x => x))}]"),
+ name: "\"known_speaker_references\"");
+ }
+ __httpRequest.Content = __httpRequestContent;
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareCreateTranscriptionAsStreamRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
+
+ return __httpRequest;
}
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareCreateTranscriptionAsStreamRequest(
- 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);
-
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCreateTranscriptionAsStreamResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateTranscriptionAsStream",
+ methodName: "CreateTranscriptionAsStreamAsync",
+ pathTemplate: "\"/audio/transcriptions\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateTranscriptionAsStream",
+ methodName: "CreateTranscriptionAsStreamAsync",
+ pathTemplate: "\"/audio/transcriptions\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateTranscriptionAsStream",
+ methodName: "CreateTranscriptionAsStreamAsync",
+ pathTemplate: "\"/audio/transcriptions\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception)
+
+ if (__response == null)
{
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::tryAGI.OpenAI.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);
+ ProcessCreateTranscriptionAsStreamResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- yield break;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateTranscriptionAsStream",
+ methodName: "CreateTranscriptionAsStreamAsync",
+ pathTemplate: "\"/audio/transcriptions\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
+ else
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateTranscriptionAsStream",
+ methodName: "CreateTranscriptionAsStreamAsync",
+ pathTemplate: "\"/audio/transcriptions\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.CreateTranscriptionResponseStreamEvent.FromJson(__content, JsonSerializerContext) ??
+ throw new global::tryAGI.OpenAI.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;
+ }
- var __streamedResponse = global::tryAGI.OpenAI.CreateTranscriptionResponseStreamEvent.FromJson(__content, JsonSerializerContext) ??
- throw new global::tryAGI.OpenAI.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();
}
}
///
@@ -320,6 +503,7 @@ partial void ProcessCreateTranscriptionAsStreamResponse(
///
/// Optional list of audio samples (as [data URLs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs)) that contain known speaker references matching `known_speaker_names[]`. Each sample must be between 2 and 10 seconds, and can use any of the same input audio formats supported by `file`.
///
+ /// 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 CreateTranscriptionAsStreamAsync(
@@ -335,6 +519,7 @@ partial void ProcessCreateTranscriptionAsStreamResponse(
global::tryAGI.OpenAI.AnyOf? chunkingStrategy = default,
global::System.Collections.Generic.IList? knownSpeakerNames = default,
global::System.Collections.Generic.IList? knownSpeakerReferences = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
[global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.CreateTranscriptionRequest
@@ -356,6 +541,7 @@ partial void ProcessCreateTranscriptionAsStreamResponse(
var __enumerable = CreateTranscriptionAsStreamAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken);
await foreach (var __response in __enumerable)
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateTranslation.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateTranslation.g.cs
index ec320bc0c..b0efd1e0f 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateTranslation.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateTranslation.g.cs
@@ -14,6 +14,7 @@ public partial class AudioClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -44,11 +45,13 @@ partial void ProcessCreateTranslationResponseContent(
/// Translates audio into English.
///
///
+ /// 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> CreateTranslationAsync(
global::tryAGI.OpenAI.CreateTranslationRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -65,22 +68,43 @@ partial void ProcessCreateTranslationResponseContent(
securityRequirements: s_CreateTranslationSecurityRequirements,
operationName: "CreateTranslationAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: "/audio/translations",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,147 +114,306 @@ partial void ProcessCreateTranslationResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
- }
- using var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
- 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;
+ }
}
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent(request.Model.ToString() ?? string.Empty),
- name: "\"model\"");
- if (request.Prompt != default)
- {
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ 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;
+ }
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Model.ToString() ?? string.Empty),
+ name: "\"model\"");
+ if (request.Prompt != 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.Prompt}"),
+ name: "\"prompt\"");
+ }
+ if (request.ResponseFormat != default)
+ {
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"{request.ResponseFormat?.ToValueString()}"),
- name: "\"response_format\"");
- }
- if (request.Temperature != default)
- {
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"{request.ResponseFormat?.ToValueString()}"),
+ name: "\"response_format\"");
+ }
+ if (request.Temperature != default)
+ {
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"{request.Temperature}"),
- name: "\"temperature\"");
- }
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareCreateTranslationRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- request: request);
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"{request.Temperature}"),
+ name: "\"temperature\"");
+ }
+ __httpRequest.Content = __httpRequestContent;
+ global::tryAGI.OpenAI.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);
+ PrepareCreateTranslationRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCreateTranslationResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateTranslation",
+ methodName: "CreateTranslationAsync",
+ pathTemplate: "\"/audio/translations\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateTranslation",
+ methodName: "CreateTranslationAsync",
+ pathTemplate: "\"/audio/translations\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessCreateTranslationResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateTranslation",
+ methodName: "CreateTranslationAsync",
+ pathTemplate: "\"/audio/translations\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.OneOf.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.OneOf.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessCreateTranslationResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateTranslation",
+ methodName: "CreateTranslationAsync",
+ pathTemplate: "\"/audio/translations\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateTranslation",
+ methodName: "CreateTranslationAsync",
+ pathTemplate: "\"/audio/translations\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessCreateTranslationResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.OneOf.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.OneOf.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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();
+ }
}
///
/// Translates audio into English.
@@ -256,6 +439,7 @@ partial void ProcessCreateTranslationResponseContent(
/// The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.
/// 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> CreateTranslationAsync(
@@ -265,6 +449,7 @@ partial void ProcessCreateTranslationResponseContent(
string? prompt = default,
global::tryAGI.OpenAI.CreateTranslationRequestResponseFormat? responseFormat = default,
double? temperature = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.CreateTranslationRequest
@@ -279,6 +464,7 @@ partial void ProcessCreateTranslationResponseContent(
return await CreateTranslationAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateVoice.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateVoice.g.cs
index c4121ca35..28ad11cf9 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateVoice.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateVoice.g.cs
@@ -14,6 +14,7 @@ public partial class AudioClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -46,11 +47,13 @@ partial void ProcessCreateVoiceResponseContent(
/// See the [custom voices guide](/docs/guides/text-to-speech#custom-voices) for requirements and best practices. Custom voices are limited to eligible customers.
///
///
+ /// 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 CreateVoiceAsync(
global::tryAGI.OpenAI.CreateVoiceRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -67,22 +70,43 @@ partial void ProcessCreateVoiceResponseContent(
securityRequirements: s_CreateVoiceSecurityRequirements,
operationName: "CreateVoiceAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: "/audio/voices",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: "/audio/voices",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -92,129 +116,288 @@ partial void ProcessCreateVoiceResponseContent(
__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.Name}"),
- name: "\"name\"");
- var __contentAudioSample = new global::System.Net.Http.ByteArrayContent(request.AudioSample ?? global::System.Array.Empty());
- __httpRequestContent.Add(
- content: __contentAudioSample,
- name: "\"audio_sample\"",
- fileName: request.AudioSamplename != null ? $"\"{request.AudioSamplename}\"" : string.Empty);
- if (__contentAudioSample.Headers.ContentDisposition != null)
- {
- __contentAudioSample.Headers.ContentDisposition.FileNameStar = null;
- }
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"{request.Consent}"),
- name: "\"consent\"");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareCreateVoiceRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- request: request);
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"{request.Name}"),
+ name: "\"name\"");
+ var __contentAudioSample = new global::System.Net.Http.ByteArrayContent(request.AudioSample ?? global::System.Array.Empty());
+ __httpRequestContent.Add(
+ content: __contentAudioSample,
+ name: "\"audio_sample\"",
+ fileName: request.AudioSamplename != null ? $"\"{request.AudioSamplename}\"" : string.Empty);
+ if (__contentAudioSample.Headers.ContentDisposition != null)
+ {
+ __contentAudioSample.Headers.ContentDisposition.FileNameStar = null;
+ }
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"{request.Consent}"),
+ name: "\"consent\"");
+ __httpRequest.Content = __httpRequestContent;
+ global::tryAGI.OpenAI.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);
+ PrepareCreateVoiceRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCreateVoiceResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateVoice",
+ methodName: "CreateVoiceAsync",
+ pathTemplate: "\"/audio/voices\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateVoice",
+ methodName: "CreateVoiceAsync",
+ pathTemplate: "\"/audio/voices\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessCreateVoiceResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateVoice",
+ methodName: "CreateVoiceAsync",
+ pathTemplate: "\"/audio/voices\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.VoiceResource.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.VoiceResource.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessCreateVoiceResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateVoice",
+ methodName: "CreateVoiceAsync",
+ pathTemplate: "\"/audio/voices\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateVoice",
+ methodName: "CreateVoiceAsync",
+ pathTemplate: "\"/audio/voices\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessCreateVoiceResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.VoiceResource.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.VoiceResource.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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();
+ }
}
///
/// Creates a custom voice.
@@ -237,6 +420,7 @@ partial void ProcessCreateVoiceResponseContent(
///
/// The consent recording ID (for example, `cons_1234`).
///
+ /// 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 CreateVoiceAsync(
@@ -244,6 +428,7 @@ partial void ProcessCreateVoiceResponseContent(
byte[] audioSample,
string audioSamplename,
string consent,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.CreateVoiceRequest
@@ -256,6 +441,7 @@ partial void ProcessCreateVoiceResponseContent(
return await CreateVoiceAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateVoiceConsent.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateVoiceConsent.g.cs
index 22f96105c..d58d0a458 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateVoiceConsent.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.CreateVoiceConsent.g.cs
@@ -14,6 +14,7 @@ public partial class AudioClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -46,11 +47,13 @@ partial void ProcessCreateVoiceConsentResponseContent(
/// See the [custom voices guide](/docs/guides/text-to-speech#custom-voices) for requirements and best practices. Custom voices are limited to eligible customers.
///
///
+ /// 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 CreateVoiceConsentAsync(
global::tryAGI.OpenAI.CreateVoiceConsentRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -67,22 +70,43 @@ partial void ProcessCreateVoiceConsentResponseContent(
securityRequirements: s_CreateVoiceConsentSecurityRequirements,
operationName: "CreateVoiceConsentAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: "/audio/voice_consents",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: "/audio/voice_consents",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -92,129 +116,288 @@ partial void ProcessCreateVoiceConsentResponseContent(
__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.Name}"),
- name: "\"name\"");
- var __contentRecording = new global::System.Net.Http.ByteArrayContent(request.Recording ?? global::System.Array.Empty());
- __httpRequestContent.Add(
- content: __contentRecording,
- name: "\"recording\"",
- fileName: request.Recordingname != null ? $"\"{request.Recordingname}\"" : string.Empty);
- if (__contentRecording.Headers.ContentDisposition != null)
- {
- __contentRecording.Headers.ContentDisposition.FileNameStar = null;
- }
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"{request.Language}"),
- name: "\"language\"");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareCreateVoiceConsentRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- request: request);
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"{request.Name}"),
+ name: "\"name\"");
+ var __contentRecording = new global::System.Net.Http.ByteArrayContent(request.Recording ?? global::System.Array.Empty());
+ __httpRequestContent.Add(
+ content: __contentRecording,
+ name: "\"recording\"",
+ fileName: request.Recordingname != null ? $"\"{request.Recordingname}\"" : string.Empty);
+ if (__contentRecording.Headers.ContentDisposition != null)
+ {
+ __contentRecording.Headers.ContentDisposition.FileNameStar = null;
+ }
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"{request.Language}"),
+ name: "\"language\"");
+ __httpRequest.Content = __httpRequestContent;
+ global::tryAGI.OpenAI.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);
+ PrepareCreateVoiceConsentRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCreateVoiceConsentResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateVoiceConsent",
+ methodName: "CreateVoiceConsentAsync",
+ pathTemplate: "\"/audio/voice_consents\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateVoiceConsent",
+ methodName: "CreateVoiceConsentAsync",
+ pathTemplate: "\"/audio/voice_consents\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessCreateVoiceConsentResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateVoiceConsent",
+ methodName: "CreateVoiceConsentAsync",
+ pathTemplate: "\"/audio/voice_consents\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.VoiceConsentResource.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.VoiceConsentResource.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessCreateVoiceConsentResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateVoiceConsent",
+ methodName: "CreateVoiceConsentAsync",
+ pathTemplate: "\"/audio/voice_consents\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateVoiceConsent",
+ methodName: "CreateVoiceConsentAsync",
+ pathTemplate: "\"/audio/voice_consents\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessCreateVoiceConsentResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.VoiceConsentResource.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.VoiceConsentResource.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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 voice consent recording.
@@ -237,6 +420,7 @@ partial void ProcessCreateVoiceConsentResponseContent(
///
/// The BCP 47 language tag for the consent phrase (for example, `en-US`).
///
+ /// 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 CreateVoiceConsentAsync(
@@ -244,6 +428,7 @@ partial void ProcessCreateVoiceConsentResponseContent(
byte[] recording,
string recordingname,
string language,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.CreateVoiceConsentRequest
@@ -256,6 +441,7 @@ partial void ProcessCreateVoiceConsentResponseContent(
return await CreateVoiceConsentAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.DeleteVoiceConsent.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.DeleteVoiceConsent.g.cs
index c48293e29..09eb9b93f 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.DeleteVoiceConsent.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.DeleteVoiceConsent.g.cs
@@ -14,6 +14,7 @@ public partial class AudioClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -46,10 +47,12 @@ partial void ProcessDeleteVoiceConsentResponseContent(
/// See the [custom voices guide](/docs/guides/text-to-speech#custom-voices). Custom voices are limited to eligible customers.
///
///
+ /// 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 DeleteVoiceConsentAsync(
string consentId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -64,22 +67,43 @@ partial void ProcessDeleteVoiceConsentResponseContent(
securityRequirements: s_DeleteVoiceConsentSecurityRequirements,
operationName: "DeleteVoiceConsentAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/audio/voice_consents/{consentId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/audio/voice_consents/{consentId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -89,112 +113,271 @@ partial void ProcessDeleteVoiceConsentResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareDeleteVoiceConsentRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- consentId: consentId);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareDeleteVoiceConsentRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ consentId: consentId);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessDeleteVoiceConsentResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteVoiceConsent",
+ methodName: "DeleteVoiceConsentAsync",
+ pathTemplate: "$\"/audio/voice_consents/{consentId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteVoiceConsent",
+ methodName: "DeleteVoiceConsentAsync",
+ pathTemplate: "$\"/audio/voice_consents/{consentId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessDeleteVoiceConsentResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteVoiceConsent",
+ methodName: "DeleteVoiceConsentAsync",
+ pathTemplate: "$\"/audio/voice_consents/{consentId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.VoiceConsentDeletedResource.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.VoiceConsentDeletedResource.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessDeleteVoiceConsentResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteVoiceConsent",
+ methodName: "DeleteVoiceConsentAsync",
+ pathTemplate: "$\"/audio/voice_consents/{consentId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteVoiceConsent",
+ methodName: "DeleteVoiceConsentAsync",
+ pathTemplate: "$\"/audio/voice_consents/{consentId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessDeleteVoiceConsentResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.VoiceConsentDeletedResource.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.VoiceConsentDeletedResource.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.ListVoiceConsents.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.ListVoiceConsents.g.cs
index 99a6b1f4f..ee5ca36d7 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.ListVoiceConsents.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.ListVoiceConsents.g.cs
@@ -14,6 +14,7 @@ public partial class AudioClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -51,11 +52,13 @@ partial void ProcessListVoiceConsentsResponseContent(
///
/// Default Value: 20
///
+ /// 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 ListVoiceConsentsAsync(
string? after = default,
int? limit = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -71,26 +74,47 @@ partial void ProcessListVoiceConsentsResponseContent(
securityRequirements: s_ListVoiceConsentsSecurityRequirements,
operationName: "ListVoiceConsentsAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: "/audio/voice_consents",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("after", after)
- .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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: "/audio/voice_consents",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("after", after)
+ .AddOptionalParameter("limit", limit?.ToString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,113 +124,272 @@ partial void ProcessListVoiceConsentsResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareListVoiceConsentsRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- after: after,
- limit: limit);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareListVoiceConsentsRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ after: after,
+ limit: limit);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessListVoiceConsentsResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListVoiceConsents",
+ methodName: "ListVoiceConsentsAsync",
+ pathTemplate: "\"/audio/voice_consents\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListVoiceConsents",
+ methodName: "ListVoiceConsentsAsync",
+ pathTemplate: "\"/audio/voice_consents\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessListVoiceConsentsResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListVoiceConsents",
+ methodName: "ListVoiceConsentsAsync",
+ pathTemplate: "\"/audio/voice_consents\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.VoiceConsentListResource.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.VoiceConsentListResource.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessListVoiceConsentsResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListVoiceConsents",
+ methodName: "ListVoiceConsentsAsync",
+ pathTemplate: "\"/audio/voice_consents\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListVoiceConsents",
+ methodName: "ListVoiceConsentsAsync",
+ pathTemplate: "\"/audio/voice_consents\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessListVoiceConsentsResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.VoiceConsentListResource.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.VoiceConsentListResource.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.RetrieveVoiceConsent.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.RetrieveVoiceConsent.g.cs
index 82d4f802c..72f108b3b 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.RetrieveVoiceConsent.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.RetrieveVoiceConsent.g.cs
@@ -14,6 +14,7 @@ public partial class AudioClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -46,10 +47,12 @@ partial void ProcessRetrieveVoiceConsentResponseContent(
/// See the [custom voices guide](/docs/guides/text-to-speech#custom-voices). Custom voices are limited to eligible customers.
///
///
+ /// 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 RetrieveVoiceConsentAsync(
string consentId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -64,22 +67,43 @@ partial void ProcessRetrieveVoiceConsentResponseContent(
securityRequirements: s_RetrieveVoiceConsentSecurityRequirements,
operationName: "RetrieveVoiceConsentAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/audio/voice_consents/{consentId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/audio/voice_consents/{consentId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,112 +113,271 @@ partial void ProcessRetrieveVoiceConsentResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareRetrieveVoiceConsentRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- consentId: consentId);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareRetrieveVoiceConsentRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ consentId: consentId);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessRetrieveVoiceConsentResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveVoiceConsent",
+ methodName: "RetrieveVoiceConsentAsync",
+ pathTemplate: "$\"/audio/voice_consents/{consentId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveVoiceConsent",
+ methodName: "RetrieveVoiceConsentAsync",
+ pathTemplate: "$\"/audio/voice_consents/{consentId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessRetrieveVoiceConsentResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveVoiceConsent",
+ methodName: "RetrieveVoiceConsentAsync",
+ pathTemplate: "$\"/audio/voice_consents/{consentId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.VoiceConsentResource.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.VoiceConsentResource.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessRetrieveVoiceConsentResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveVoiceConsent",
+ methodName: "RetrieveVoiceConsentAsync",
+ pathTemplate: "$\"/audio/voice_consents/{consentId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveVoiceConsent",
+ methodName: "RetrieveVoiceConsentAsync",
+ pathTemplate: "$\"/audio/voice_consents/{consentId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessRetrieveVoiceConsentResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.VoiceConsentResource.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.VoiceConsentResource.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.UpdateVoiceConsent.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.UpdateVoiceConsent.g.cs
index fce304357..411fc4eca 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.UpdateVoiceConsent.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.UpdateVoiceConsent.g.cs
@@ -14,6 +14,7 @@ public partial class AudioClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -49,12 +50,14 @@ partial void ProcessUpdateVoiceConsentResponseContent(
///
///
///
+ /// 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 UpdateVoiceConsentAsync(
string consentId,
global::tryAGI.OpenAI.UpdateVoiceConsentRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -72,22 +75,43 @@ partial void ProcessUpdateVoiceConsentResponseContent(
securityRequirements: s_UpdateVoiceConsentSecurityRequirements,
operationName: "UpdateVoiceConsentAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/audio/voice_consents/{consentId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/audio/voice_consents/{consentId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,119 +121,278 @@ partial void ProcessUpdateVoiceConsentResponseContent(
__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);
- PrepareUpdateVoiceConsentRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- consentId: consentId,
- 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::tryAGI.OpenAI.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);
+ PrepareUpdateVoiceConsentRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ consentId: consentId,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessUpdateVoiceConsentResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UpdateVoiceConsent",
+ methodName: "UpdateVoiceConsentAsync",
+ pathTemplate: "$\"/audio/voice_consents/{consentId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UpdateVoiceConsent",
+ methodName: "UpdateVoiceConsentAsync",
+ pathTemplate: "$\"/audio/voice_consents/{consentId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessUpdateVoiceConsentResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UpdateVoiceConsent",
+ methodName: "UpdateVoiceConsentAsync",
+ pathTemplate: "$\"/audio/voice_consents/{consentId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.VoiceConsentResource.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.VoiceConsentResource.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessUpdateVoiceConsentResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UpdateVoiceConsent",
+ methodName: "UpdateVoiceConsentAsync",
+ pathTemplate: "$\"/audio/voice_consents/{consentId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UpdateVoiceConsent",
+ methodName: "UpdateVoiceConsentAsync",
+ pathTemplate: "$\"/audio/voice_consents/{consentId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessUpdateVoiceConsentResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.VoiceConsentResource.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.VoiceConsentResource.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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();
+ }
}
///
/// Updates a voice consent recording (metadata only).
@@ -220,11 +403,13 @@ partial void ProcessUpdateVoiceConsentResponseContent(
///
/// The updated label for this consent recording.
///
+ /// 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 UpdateVoiceConsentAsync(
string consentId,
string name,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.UpdateVoiceConsentRequest
@@ -235,6 +420,7 @@ partial void ProcessUpdateVoiceConsentResponseContent(
return await UpdateVoiceConsentAsync(
consentId: consentId,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.g.cs
index eda5a4ade..63539030c 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AudioClient.g.cs
@@ -31,6 +31,9 @@ public sealed partial class AudioClient : global::tryAGI.OpenAI.IAudioClient, gl
#if DEBUG
= true;
#endif
+
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
///
///
///
@@ -50,11 +53,37 @@ 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.
+ /// 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 = null,
+ global::System.Uri? baseUri = null,
+ global::System.Collections.Generic.List? authorizations = null,
+ global::tryAGI.OpenAI.AutoSDKClientOptions? options = null,
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::tryAGI.OpenAI.AutoSDKClientOptions();
_disposeHttpClient = disposeHttpClient;
Initialized(HttpClient);
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AuditLogsClient.ListAuditLogs.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AuditLogsClient.ListAuditLogs.g.cs
index 59073765c..f888f4820 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AuditLogsClient.ListAuditLogs.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AuditLogsClient.ListAuditLogs.g.cs
@@ -14,6 +14,7 @@ public partial class AuditLogsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -70,6 +71,7 @@ partial void ProcessListAuditLogsResponseContent(
///
///
///
+ /// 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 ListAuditLogsAsync(
@@ -82,6 +84,7 @@ partial void ProcessListAuditLogsResponseContent(
int? limit = default,
string? after = default,
string? before = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -104,36 +107,57 @@ partial void ProcessListAuditLogsResponseContent(
securityRequirements: s_ListAuditLogsSecurityRequirements,
operationName: "ListAuditLogsAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: "/organization/audit_logs",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("gt", effectiveAt?.Gt?.ToString())
- .AddOptionalParameter("gte", effectiveAt?.Gte?.ToString())
- .AddOptionalParameter("lt", effectiveAt?.Lt?.ToString())
- .AddOptionalParameter("lte", effectiveAt?.Lte?.ToString())
- .AddOptionalParameter("project_ids[]", projectIds, delimiter: ",", explode: true)
- .AddOptionalParameter("event_types[]", eventTypes, selector: static x => x.ToValueString(), delimiter: ",", explode: true)
- .AddOptionalParameter("actor_ids[]", actorIds, delimiter: ",", explode: true)
- .AddOptionalParameter("actor_emails[]", actorEmails, delimiter: ",", explode: true)
- .AddOptionalParameter("resource_ids[]", resourceIds, delimiter: ",", explode: true)
- .AddOptionalParameter("limit", limit?.ToString())
- .AddOptionalParameter("after", after)
- .AddOptionalParameter("before", before)
- ;
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: "/organization/audit_logs",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("gt", effectiveAt?.Gt?.ToString())
+ .AddOptionalParameter("gte", effectiveAt?.Gte?.ToString())
+ .AddOptionalParameter("lt", effectiveAt?.Lt?.ToString())
+ .AddOptionalParameter("lte", effectiveAt?.Lte?.ToString())
+ .AddOptionalParameter("project_ids[]", projectIds, delimiter: ",", explode: true)
+ .AddOptionalParameter("event_types[]", eventTypes, selector: static x => x.ToValueString(), delimiter: ",", explode: true)
+ .AddOptionalParameter("actor_ids[]", actorIds, delimiter: ",", explode: true)
+ .AddOptionalParameter("actor_emails[]", actorEmails, delimiter: ",", explode: true)
+ .AddOptionalParameter("resource_ids[]", resourceIds, delimiter: ",", explode: true)
+ .AddOptionalParameter("limit", limit?.ToString())
+ .AddOptionalParameter("after", after)
+ .AddOptionalParameter("before", before)
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -143,120 +167,279 @@ partial void ProcessListAuditLogsResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareListAuditLogsRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- effectiveAt: effectiveAt,
- projectIds: projectIds,
- eventTypes: eventTypes,
- actorIds: actorIds,
- actorEmails: actorEmails,
- resourceIds: resourceIds,
- limit: limit,
- after: after,
- before: before);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareListAuditLogsRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ effectiveAt: effectiveAt,
+ projectIds: projectIds,
+ eventTypes: eventTypes,
+ actorIds: actorIds,
+ actorEmails: actorEmails,
+ resourceIds: resourceIds,
+ limit: limit,
+ after: after,
+ before: before);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessListAuditLogsResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListAuditLogs",
+ methodName: "ListAuditLogsAsync",
+ pathTemplate: "\"/organization/audit_logs\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListAuditLogs",
+ methodName: "ListAuditLogsAsync",
+ pathTemplate: "\"/organization/audit_logs\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessListAuditLogsResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListAuditLogs",
+ methodName: "ListAuditLogsAsync",
+ pathTemplate: "\"/organization/audit_logs\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.ListAuditLogsResponse.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.ListAuditLogsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessListAuditLogsResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListAuditLogs",
+ methodName: "ListAuditLogsAsync",
+ pathTemplate: "\"/organization/audit_logs\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListAuditLogs",
+ methodName: "ListAuditLogsAsync",
+ pathTemplate: "\"/organization/audit_logs\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessListAuditLogsResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.ListAuditLogsResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ListAuditLogsResponse.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AuditLogsClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AuditLogsClient.g.cs
index 0cc23501b..c39dac184 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AuditLogsClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.AuditLogsClient.g.cs
@@ -31,6 +31,9 @@ public sealed partial class AuditLogsClient : global::tryAGI.OpenAI.IAuditLogsCl
#if DEBUG
= true;
#endif
+
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
///
///
///
@@ -50,11 +53,37 @@ public AuditLogsClient(
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 AuditLogsClient.
+ /// 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 AuditLogsClient(
+ global::System.Net.Http.HttpClient? httpClient = null,
+ global::System.Uri? baseUri = null,
+ global::System.Collections.Generic.List? authorizations = null,
+ global::tryAGI.OpenAI.AutoSDKClientOptions? options = null,
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::tryAGI.OpenAI.AutoSDKClientOptions();
_disposeHttpClient = disposeHttpClient;
Initialized(HttpClient);
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.BatchClient.CancelBatch.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.BatchClient.CancelBatch.g.cs
index 4f4d676d9..7cf7c3b39 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.BatchClient.CancelBatch.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.BatchClient.CancelBatch.g.cs
@@ -14,6 +14,7 @@ public partial class BatchClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -44,10 +45,12 @@ partial void ProcessCancelBatchResponseContent(
/// Cancels an in-progress batch. The batch will be in status `cancelling` for up to 10 minutes, before changing to `cancelled`, where it will have partial results (if any) available in the output file.
///
///
+ /// 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 CancelBatchAsync(
string batchId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -62,22 +65,43 @@ partial void ProcessCancelBatchResponseContent(
securityRequirements: s_CancelBatchSecurityRequirements,
operationName: "CancelBatchAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/batches/{batchId}/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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/batches/{batchId}/cancel",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -87,112 +111,271 @@ partial void ProcessCancelBatchResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareCancelBatchRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- batchId: batchId);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareCancelBatchRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ batchId: batchId);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCancelBatchResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CancelBatch",
+ methodName: "CancelBatchAsync",
+ pathTemplate: "$\"/batches/{batchId}/cancel\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CancelBatch",
+ methodName: "CancelBatchAsync",
+ pathTemplate: "$\"/batches/{batchId}/cancel\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessCancelBatchResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CancelBatch",
+ methodName: "CancelBatchAsync",
+ pathTemplate: "$\"/batches/{batchId}/cancel\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.Batch.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.Batch.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessCancelBatchResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CancelBatch",
+ methodName: "CancelBatchAsync",
+ pathTemplate: "$\"/batches/{batchId}/cancel\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CancelBatch",
+ methodName: "CancelBatchAsync",
+ pathTemplate: "$\"/batches/{batchId}/cancel\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessCancelBatchResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.Batch.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.Batch.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.BatchClient.CreateBatch.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.BatchClient.CreateBatch.g.cs
index efca08f4a..cb3c77523 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.BatchClient.CreateBatch.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.BatchClient.CreateBatch.g.cs
@@ -14,6 +14,7 @@ public partial class BatchClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -44,11 +45,13 @@ partial void ProcessCreateBatchResponseContent(
/// Creates and executes a batch from an uploaded file of requests
///
///
+ /// 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 CreateBatchAsync(
global::tryAGI.OpenAI.CreateBatchRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -65,22 +68,43 @@ partial void ProcessCreateBatchResponseContent(
securityRequirements: s_CreateBatchSecurityRequirements,
operationName: "CreateBatchAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: "/batches",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,118 +114,277 @@ partial void ProcessCreateBatchResponseContent(
__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);
- PrepareCreateBatchRequest(
- 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::tryAGI.OpenAI.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);
+ PrepareCreateBatchRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCreateBatchResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateBatch",
+ methodName: "CreateBatchAsync",
+ pathTemplate: "\"/batches\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateBatch",
+ methodName: "CreateBatchAsync",
+ pathTemplate: "\"/batches\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessCreateBatchResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateBatch",
+ methodName: "CreateBatchAsync",
+ pathTemplate: "\"/batches\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.Batch.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.Batch.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessCreateBatchResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateBatch",
+ methodName: "CreateBatchAsync",
+ pathTemplate: "\"/batches\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateBatch",
+ methodName: "CreateBatchAsync",
+ pathTemplate: "\"/batches\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessCreateBatchResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.Batch.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.Batch.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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();
+ }
}
///
/// Creates and executes a batch from an uploaded file of requests
@@ -221,6 +404,7 @@ partial void ProcessCreateBatchResponseContent(
///
/// The expiration policy for the output and/or error file that are generated for a batch.
///
+ /// 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 CreateBatchAsync(
@@ -229,6 +413,7 @@ partial void ProcessCreateBatchResponseContent(
global::tryAGI.OpenAI.CreateBatchRequestCompletionWindow completionWindow = default,
global::System.Collections.Generic.Dictionary? metadata = default,
global::tryAGI.OpenAI.BatchFileExpirationAfter? outputExpiresAfter = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.CreateBatchRequest
@@ -242,6 +427,7 @@ partial void ProcessCreateBatchResponseContent(
return await CreateBatchAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.BatchClient.ListBatches.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.BatchClient.ListBatches.g.cs
index 325efc0ce..8771de873 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.BatchClient.ListBatches.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.BatchClient.ListBatches.g.cs
@@ -14,6 +14,7 @@ public partial class BatchClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -49,11 +50,13 @@ partial void ProcessListBatchesResponseContent(
///
/// Default Value: 20
///
+ /// 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 ListBatchesAsync(
string? after = default,
int? limit = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -69,26 +72,47 @@ partial void ProcessListBatchesResponseContent(
securityRequirements: s_ListBatchesSecurityRequirements,
operationName: "ListBatchesAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: "/batches",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("after", after)
- .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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: "/batches",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("after", after)
+ .AddOptionalParameter("limit", limit?.ToString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -98,113 +122,272 @@ partial void ProcessListBatchesResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareListBatchesRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- after: after,
- limit: limit);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareListBatchesRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ after: after,
+ limit: limit);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessListBatchesResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListBatches",
+ methodName: "ListBatchesAsync",
+ pathTemplate: "\"/batches\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListBatches",
+ methodName: "ListBatchesAsync",
+ pathTemplate: "\"/batches\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessListBatchesResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListBatches",
+ methodName: "ListBatchesAsync",
+ pathTemplate: "\"/batches\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.ListBatchesResponse.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.ListBatchesResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessListBatchesResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListBatches",
+ methodName: "ListBatchesAsync",
+ pathTemplate: "\"/batches\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListBatches",
+ methodName: "ListBatchesAsync",
+ pathTemplate: "\"/batches\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessListBatchesResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.ListBatchesResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ListBatchesResponse.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.BatchClient.RetrieveBatch.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.BatchClient.RetrieveBatch.g.cs
index 4c9a7e66f..d53d10dc3 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.BatchClient.RetrieveBatch.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.BatchClient.RetrieveBatch.g.cs
@@ -14,6 +14,7 @@ public partial class BatchClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -44,10 +45,12 @@ partial void ProcessRetrieveBatchResponseContent(
/// Retrieves a batch.
///
///
+ /// 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 RetrieveBatchAsync(
string batchId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -62,22 +65,43 @@ partial void ProcessRetrieveBatchResponseContent(
securityRequirements: s_RetrieveBatchSecurityRequirements,
operationName: "RetrieveBatchAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/batches/{batchId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/batches/{batchId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,112 +111,271 @@ partial void ProcessRetrieveBatchResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareRetrieveBatchRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- batchId: batchId);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareRetrieveBatchRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ batchId: batchId);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessRetrieveBatchResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveBatch",
+ methodName: "RetrieveBatchAsync",
+ pathTemplate: "$\"/batches/{batchId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveBatch",
+ methodName: "RetrieveBatchAsync",
+ pathTemplate: "$\"/batches/{batchId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessRetrieveBatchResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveBatch",
+ methodName: "RetrieveBatchAsync",
+ pathTemplate: "$\"/batches/{batchId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.Batch.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.Batch.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessRetrieveBatchResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveBatch",
+ methodName: "RetrieveBatchAsync",
+ pathTemplate: "$\"/batches/{batchId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveBatch",
+ methodName: "RetrieveBatchAsync",
+ pathTemplate: "$\"/batches/{batchId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessRetrieveBatchResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.Batch.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.Batch.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.BatchClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.BatchClient.g.cs
index 94d76307c..d6a561b7e 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.BatchClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.BatchClient.g.cs
@@ -31,6 +31,9 @@ public sealed partial class BatchClient : global::tryAGI.OpenAI.IBatchClient, gl
#if DEBUG
= true;
#endif
+
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
///
///
///
@@ -50,11 +53,37 @@ public BatchClient(
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 BatchClient.
+ /// 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 BatchClient(
+ global::System.Net.Http.HttpClient? httpClient = null,
+ global::System.Uri? baseUri = null,
+ global::System.Collections.Generic.List? authorizations = null,
+ global::tryAGI.OpenAI.AutoSDKClientOptions? options = null,
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::tryAGI.OpenAI.AutoSDKClientOptions();
_disposeHttpClient = disposeHttpClient;
Initialized(HttpClient);
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.ActivateCertificatesForOrganization.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.ActivateCertificatesForOrganization.g.cs
index a633d7daf..391c3db0a 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.ActivateCertificatesForOrganization.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.ActivateCertificatesForOrganization.g.cs
@@ -14,6 +14,7 @@ public partial class CertificatesClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -45,11 +46,13 @@ partial void ProcessActivateCertificatesForOrganizationResponseContent(
/// You can atomically and idempotently activate up to 10 certificates at a time.
///
///
+ /// 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 ActivateCertificatesForOrganizationAsync(
global::tryAGI.OpenAI.ToggleCertificatesRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -66,22 +69,43 @@ partial void ProcessActivateCertificatesForOrganizationResponseContent(
securityRequirements: s_ActivateCertificatesForOrganizationSecurityRequirements,
operationName: "ActivateCertificatesForOrganizationAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: "/organization/certificates/activate",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: "/organization/certificates/activate",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,128 +115,289 @@ partial void ProcessActivateCertificatesForOrganizationResponseContent(
__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);
- PrepareActivateCertificatesForOrganizationRequest(
- 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::tryAGI.OpenAI.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);
+ PrepareActivateCertificatesForOrganizationRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessActivateCertificatesForOrganizationResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ActivateCertificatesForOrganization",
+ methodName: "ActivateCertificatesForOrganizationAsync",
+ pathTemplate: "\"/organization/certificates/activate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ActivateCertificatesForOrganization",
+ methodName: "ActivateCertificatesForOrganizationAsync",
+ pathTemplate: "\"/organization/certificates/activate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessActivateCertificatesForOrganizationResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ActivateCertificatesForOrganization",
+ methodName: "ActivateCertificatesForOrganizationAsync",
+ pathTemplate: "\"/organization/certificates/activate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.ListCertificatesResponse.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.ListCertificatesResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessActivateCertificatesForOrganizationResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ActivateCertificatesForOrganization",
+ methodName: "ActivateCertificatesForOrganizationAsync",
+ pathTemplate: "\"/organization/certificates/activate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ActivateCertificatesForOrganization",
+ methodName: "ActivateCertificatesForOrganizationAsync",
+ pathTemplate: "\"/organization/certificates/activate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessActivateCertificatesForOrganizationResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.ListCertificatesResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ListCertificatesResponse.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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();
+ }
}
///
/// Activate certificates at the organization level.
/// You can atomically and idempotently activate up to 10 certificates at a time.
///
///
+ /// 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 ActivateCertificatesForOrganizationAsync(
global::System.Collections.Generic.IList certificateIds,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.ToggleCertificatesRequest
@@ -222,6 +407,7 @@ partial void ProcessActivateCertificatesForOrganizationResponseContent(
return await ActivateCertificatesForOrganizationAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.ActivateCertificatesForProject.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.ActivateCertificatesForProject.g.cs
index cd0dac07c..075bab521 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.ActivateCertificatesForProject.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.ActivateCertificatesForProject.g.cs
@@ -14,6 +14,7 @@ public partial class CertificatesClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -48,12 +49,14 @@ partial void ProcessActivateCertificatesForProjectResponseContent(
///
///
///
+ /// 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 ActivateCertificatesForProjectAsync(
string projectId,
global::tryAGI.OpenAI.ToggleCertificatesRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -71,22 +74,43 @@ partial void ProcessActivateCertificatesForProjectResponseContent(
securityRequirements: s_ActivateCertificatesForProjectSecurityRequirements,
operationName: "ActivateCertificatesForProjectAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/organization/projects/{projectId}/certificates/activate",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/organization/projects/{projectId}/certificates/activate",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,119 +120,278 @@ partial void ProcessActivateCertificatesForProjectResponseContent(
__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);
- PrepareActivateCertificatesForProjectRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- projectId: projectId,
- 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::tryAGI.OpenAI.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);
+ PrepareActivateCertificatesForProjectRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ projectId: projectId,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessActivateCertificatesForProjectResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ActivateCertificatesForProject",
+ methodName: "ActivateCertificatesForProjectAsync",
+ pathTemplate: "$\"/organization/projects/{projectId}/certificates/activate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ActivateCertificatesForProject",
+ methodName: "ActivateCertificatesForProjectAsync",
+ pathTemplate: "$\"/organization/projects/{projectId}/certificates/activate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessActivateCertificatesForProjectResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ActivateCertificatesForProject",
+ methodName: "ActivateCertificatesForProjectAsync",
+ pathTemplate: "$\"/organization/projects/{projectId}/certificates/activate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.ListCertificatesResponse.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.ListCertificatesResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessActivateCertificatesForProjectResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ActivateCertificatesForProject",
+ methodName: "ActivateCertificatesForProjectAsync",
+ pathTemplate: "$\"/organization/projects/{projectId}/certificates/activate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ActivateCertificatesForProject",
+ methodName: "ActivateCertificatesForProjectAsync",
+ pathTemplate: "$\"/organization/projects/{projectId}/certificates/activate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessActivateCertificatesForProjectResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.ListCertificatesResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ListCertificatesResponse.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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();
+ }
}
///
/// Activate certificates at the project level.
@@ -216,11 +399,13 @@ partial void ProcessActivateCertificatesForProjectResponseContent(
///
///
///
+ /// 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 ActivateCertificatesForProjectAsync(
string projectId,
global::System.Collections.Generic.IList certificateIds,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.ToggleCertificatesRequest
@@ -231,6 +416,7 @@ partial void ProcessActivateCertificatesForProjectResponseContent(
return await ActivateCertificatesForProjectAsync(
projectId: projectId,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.DeactivateCertificatesForOrganization.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.DeactivateCertificatesForOrganization.g.cs
index 334945e22..d7ac3483e 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.DeactivateCertificatesForOrganization.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.DeactivateCertificatesForOrganization.g.cs
@@ -14,6 +14,7 @@ public partial class CertificatesClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -45,11 +46,13 @@ partial void ProcessDeactivateCertificatesForOrganizationResponseContent(
/// You can atomically and idempotently deactivate up to 10 certificates at a time.
///
///
+ /// 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 DeactivateCertificatesForOrganizationAsync(
global::tryAGI.OpenAI.ToggleCertificatesRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -66,22 +69,43 @@ partial void ProcessDeactivateCertificatesForOrganizationResponseContent(
securityRequirements: s_DeactivateCertificatesForOrganizationSecurityRequirements,
operationName: "DeactivateCertificatesForOrganizationAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: "/organization/certificates/deactivate",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: "/organization/certificates/deactivate",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,128 +115,289 @@ partial void ProcessDeactivateCertificatesForOrganizationResponseContent(
__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);
- PrepareDeactivateCertificatesForOrganizationRequest(
- 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::tryAGI.OpenAI.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);
+ PrepareDeactivateCertificatesForOrganizationRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessDeactivateCertificatesForOrganizationResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeactivateCertificatesForOrganization",
+ methodName: "DeactivateCertificatesForOrganizationAsync",
+ pathTemplate: "\"/organization/certificates/deactivate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeactivateCertificatesForOrganization",
+ methodName: "DeactivateCertificatesForOrganizationAsync",
+ pathTemplate: "\"/organization/certificates/deactivate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessDeactivateCertificatesForOrganizationResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeactivateCertificatesForOrganization",
+ methodName: "DeactivateCertificatesForOrganizationAsync",
+ pathTemplate: "\"/organization/certificates/deactivate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.ListCertificatesResponse.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.ListCertificatesResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessDeactivateCertificatesForOrganizationResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeactivateCertificatesForOrganization",
+ methodName: "DeactivateCertificatesForOrganizationAsync",
+ pathTemplate: "\"/organization/certificates/deactivate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeactivateCertificatesForOrganization",
+ methodName: "DeactivateCertificatesForOrganizationAsync",
+ pathTemplate: "\"/organization/certificates/deactivate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessDeactivateCertificatesForOrganizationResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.ListCertificatesResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ListCertificatesResponse.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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();
+ }
}
///
/// Deactivate certificates at the organization level.
/// You can atomically and idempotently deactivate up to 10 certificates at a time.
///
///
+ /// 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 DeactivateCertificatesForOrganizationAsync(
global::System.Collections.Generic.IList certificateIds,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.ToggleCertificatesRequest
@@ -222,6 +407,7 @@ partial void ProcessDeactivateCertificatesForOrganizationResponseContent(
return await DeactivateCertificatesForOrganizationAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.DeactivateCertificatesForProject.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.DeactivateCertificatesForProject.g.cs
index f57f4f184..7cb469d4b 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.DeactivateCertificatesForProject.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.DeactivateCertificatesForProject.g.cs
@@ -14,6 +14,7 @@ public partial class CertificatesClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -48,12 +49,14 @@ partial void ProcessDeactivateCertificatesForProjectResponseContent(
///
///
///
+ /// 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 DeactivateCertificatesForProjectAsync(
string projectId,
global::tryAGI.OpenAI.ToggleCertificatesRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -71,22 +74,43 @@ partial void ProcessDeactivateCertificatesForProjectResponseContent(
securityRequirements: s_DeactivateCertificatesForProjectSecurityRequirements,
operationName: "DeactivateCertificatesForProjectAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/organization/projects/{projectId}/certificates/deactivate",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/organization/projects/{projectId}/certificates/deactivate",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,119 +120,278 @@ partial void ProcessDeactivateCertificatesForProjectResponseContent(
__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);
- PrepareDeactivateCertificatesForProjectRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- projectId: projectId,
- 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::tryAGI.OpenAI.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);
+ PrepareDeactivateCertificatesForProjectRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ projectId: projectId,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessDeactivateCertificatesForProjectResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeactivateCertificatesForProject",
+ methodName: "DeactivateCertificatesForProjectAsync",
+ pathTemplate: "$\"/organization/projects/{projectId}/certificates/deactivate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeactivateCertificatesForProject",
+ methodName: "DeactivateCertificatesForProjectAsync",
+ pathTemplate: "$\"/organization/projects/{projectId}/certificates/deactivate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessDeactivateCertificatesForProjectResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeactivateCertificatesForProject",
+ methodName: "DeactivateCertificatesForProjectAsync",
+ pathTemplate: "$\"/organization/projects/{projectId}/certificates/deactivate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.ListCertificatesResponse.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.ListCertificatesResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessDeactivateCertificatesForProjectResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeactivateCertificatesForProject",
+ methodName: "DeactivateCertificatesForProjectAsync",
+ pathTemplate: "$\"/organization/projects/{projectId}/certificates/deactivate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeactivateCertificatesForProject",
+ methodName: "DeactivateCertificatesForProjectAsync",
+ pathTemplate: "$\"/organization/projects/{projectId}/certificates/deactivate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessDeactivateCertificatesForProjectResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.ListCertificatesResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ListCertificatesResponse.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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();
+ }
}
///
/// Deactivate certificates at the project level. You can atomically and
@@ -216,11 +399,13 @@ partial void ProcessDeactivateCertificatesForProjectResponseContent(
///
///
///
+ /// 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 DeactivateCertificatesForProjectAsync(
string projectId,
global::System.Collections.Generic.IList certificateIds,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.ToggleCertificatesRequest
@@ -231,6 +416,7 @@ partial void ProcessDeactivateCertificatesForProjectResponseContent(
return await DeactivateCertificatesForProjectAsync(
projectId: projectId,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.DeleteCertificate.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.DeleteCertificate.g.cs
index 2c184ce2e..556421cad 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.DeleteCertificate.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.DeleteCertificate.g.cs
@@ -14,6 +14,7 @@ public partial class CertificatesClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -45,10 +46,12 @@ partial void ProcessDeleteCertificateResponseContent(
/// The certificate must be inactive for the organization and all projects.
///
///
+ /// 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 DeleteCertificateAsync(
string certificateId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -63,22 +66,43 @@ partial void ProcessDeleteCertificateResponseContent(
securityRequirements: s_DeleteCertificateSecurityRequirements,
operationName: "DeleteCertificateAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/organization/certificates/{certificateId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/organization/certificates/{certificateId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -88,112 +112,271 @@ partial void ProcessDeleteCertificateResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareDeleteCertificateRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- certificateId: certificateId);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareDeleteCertificateRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ certificateId: certificateId);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessDeleteCertificateResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteCertificate",
+ methodName: "DeleteCertificateAsync",
+ pathTemplate: "$\"/organization/certificates/{certificateId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteCertificate",
+ methodName: "DeleteCertificateAsync",
+ pathTemplate: "$\"/organization/certificates/{certificateId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessDeleteCertificateResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteCertificate",
+ methodName: "DeleteCertificateAsync",
+ pathTemplate: "$\"/organization/certificates/{certificateId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.DeleteCertificateResponse.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.DeleteCertificateResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessDeleteCertificateResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteCertificate",
+ methodName: "DeleteCertificateAsync",
+ pathTemplate: "$\"/organization/certificates/{certificateId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteCertificate",
+ methodName: "DeleteCertificateAsync",
+ pathTemplate: "$\"/organization/certificates/{certificateId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessDeleteCertificateResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.DeleteCertificateResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.DeleteCertificateResponse.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.GetCertificate.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.GetCertificate.g.cs
index 3e0f23dfc..85860b420 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.GetCertificate.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.GetCertificate.g.cs
@@ -14,6 +14,7 @@ public partial class CertificatesClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -48,11 +49,13 @@ partial void ProcessGetCertificateResponseContent(
///
///
///
+ /// 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 GetCertificateAsync(
string certificateId,
global::System.Collections.Generic.IList? include = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -68,25 +71,46 @@ partial void ProcessGetCertificateResponseContent(
securityRequirements: s_GetCertificateSecurityRequirements,
operationName: "GetCertificateAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/organization/certificates/{certificateId}",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("include", include, selector: static x => x.ToValueString(), delimiter: ",", explode: true)
- ;
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/organization/certificates/{certificateId}",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("include", include, selector: static x => x.ToValueString(), delimiter: ",", explode: true)
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,113 +120,272 @@ partial void ProcessGetCertificateResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareGetCertificateRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- certificateId: certificateId,
- include: include);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareGetCertificateRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ certificateId: certificateId,
+ include: include);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessGetCertificateResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetCertificate",
+ methodName: "GetCertificateAsync",
+ pathTemplate: "$\"/organization/certificates/{certificateId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetCertificate",
+ methodName: "GetCertificateAsync",
+ pathTemplate: "$\"/organization/certificates/{certificateId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessGetCertificateResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetCertificate",
+ methodName: "GetCertificateAsync",
+ pathTemplate: "$\"/organization/certificates/{certificateId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.Certificate.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.Certificate.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessGetCertificateResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetCertificate",
+ methodName: "GetCertificateAsync",
+ pathTemplate: "$\"/organization/certificates/{certificateId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetCertificate",
+ methodName: "GetCertificateAsync",
+ pathTemplate: "$\"/organization/certificates/{certificateId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessGetCertificateResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.Certificate.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.Certificate.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.ListOrganizationCertificates.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.ListOrganizationCertificates.g.cs
index 46512b783..fbce29cbf 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.ListOrganizationCertificates.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.ListOrganizationCertificates.g.cs
@@ -14,6 +14,7 @@ public partial class CertificatesClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -54,12 +55,14 @@ partial void ProcessListOrganizationCertificatesResponseContent(
///
/// Default Value: desc
///
+ /// 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 ListOrganizationCertificatesAsync(
int? limit = default,
string? after = default,
global::tryAGI.OpenAI.ListOrganizationCertificatesOrder? order = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -76,27 +79,48 @@ partial void ProcessListOrganizationCertificatesResponseContent(
securityRequirements: s_ListOrganizationCertificatesSecurityRequirements,
operationName: "ListOrganizationCertificatesAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: "/organization/certificates",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("limit", limit?.ToString())
- .AddOptionalParameter("after", after)
- .AddOptionalParameter("order", order?.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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: "/organization/certificates",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("limit", limit?.ToString())
+ .AddOptionalParameter("after", after)
+ .AddOptionalParameter("order", order?.ToValueString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,114 +130,273 @@ partial void ProcessListOrganizationCertificatesResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareListOrganizationCertificatesRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- limit: limit,
- after: after,
- order: order);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareListOrganizationCertificatesRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ limit: limit,
+ after: after,
+ order: order);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessListOrganizationCertificatesResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListOrganizationCertificates",
+ methodName: "ListOrganizationCertificatesAsync",
+ pathTemplate: "\"/organization/certificates\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListOrganizationCertificates",
+ methodName: "ListOrganizationCertificatesAsync",
+ pathTemplate: "\"/organization/certificates\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessListOrganizationCertificatesResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListOrganizationCertificates",
+ methodName: "ListOrganizationCertificatesAsync",
+ pathTemplate: "\"/organization/certificates\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.ListCertificatesResponse.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.ListCertificatesResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessListOrganizationCertificatesResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListOrganizationCertificates",
+ methodName: "ListOrganizationCertificatesAsync",
+ pathTemplate: "\"/organization/certificates\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListOrganizationCertificates",
+ methodName: "ListOrganizationCertificatesAsync",
+ pathTemplate: "\"/organization/certificates\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessListOrganizationCertificatesResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.ListCertificatesResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ListCertificatesResponse.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.ListProjectCertificates.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.ListProjectCertificates.g.cs
index 1dca6ce4e..6b0c7839a 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.ListProjectCertificates.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.ListProjectCertificates.g.cs
@@ -14,6 +14,7 @@ public partial class CertificatesClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -57,6 +58,7 @@ partial void ProcessListProjectCertificatesResponseContent(
///
/// Default Value: desc
///
+ /// 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 ListProjectCertificatesAsync(
@@ -64,6 +66,7 @@ partial void ProcessListProjectCertificatesResponseContent(
int? limit = default,
string? after = default,
global::tryAGI.OpenAI.ListProjectCertificatesOrder? order = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -81,27 +84,48 @@ partial void ProcessListProjectCertificatesResponseContent(
securityRequirements: s_ListProjectCertificatesSecurityRequirements,
operationName: "ListProjectCertificatesAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/organization/projects/{projectId}/certificates",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("limit", limit?.ToString())
- .AddOptionalParameter("after", after)
- .AddOptionalParameter("order", order?.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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/organization/projects/{projectId}/certificates",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("limit", limit?.ToString())
+ .AddOptionalParameter("after", after)
+ .AddOptionalParameter("order", order?.ToValueString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,115 +135,274 @@ partial void ProcessListProjectCertificatesResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareListProjectCertificatesRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- projectId: projectId,
- limit: limit,
- after: after,
- order: order);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareListProjectCertificatesRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ projectId: projectId,
+ limit: limit,
+ after: after,
+ order: order);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessListProjectCertificatesResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListProjectCertificates",
+ methodName: "ListProjectCertificatesAsync",
+ pathTemplate: "$\"/organization/projects/{projectId}/certificates\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListProjectCertificates",
+ methodName: "ListProjectCertificatesAsync",
+ pathTemplate: "$\"/organization/projects/{projectId}/certificates\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessListProjectCertificatesResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListProjectCertificates",
+ methodName: "ListProjectCertificatesAsync",
+ pathTemplate: "$\"/organization/projects/{projectId}/certificates\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.ListCertificatesResponse.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.ListCertificatesResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessListProjectCertificatesResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListProjectCertificates",
+ methodName: "ListProjectCertificatesAsync",
+ pathTemplate: "$\"/organization/projects/{projectId}/certificates\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListProjectCertificates",
+ methodName: "ListProjectCertificatesAsync",
+ pathTemplate: "$\"/organization/projects/{projectId}/certificates\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessListProjectCertificatesResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.ListCertificatesResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ListCertificatesResponse.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.ModifyCertificate.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.ModifyCertificate.g.cs
index 363bd26bb..ed9d15108 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.ModifyCertificate.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.ModifyCertificate.g.cs
@@ -14,6 +14,7 @@ public partial class CertificatesClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -47,12 +48,14 @@ partial void ProcessModifyCertificateResponseContent(
///
///
///
+ /// 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 ModifyCertificateAsync(
string certificateId,
global::tryAGI.OpenAI.ModifyCertificateRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -70,22 +73,43 @@ partial void ProcessModifyCertificateResponseContent(
securityRequirements: s_ModifyCertificateSecurityRequirements,
operationName: "ModifyCertificateAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/organization/certificates/{certificateId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/organization/certificates/{certificateId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -95,119 +119,278 @@ partial void ProcessModifyCertificateResponseContent(
__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);
- PrepareModifyCertificateRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- certificateId: certificateId,
- 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::tryAGI.OpenAI.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);
+ PrepareModifyCertificateRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ certificateId: certificateId,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessModifyCertificateResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyCertificate",
+ methodName: "ModifyCertificateAsync",
+ pathTemplate: "$\"/organization/certificates/{certificateId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyCertificate",
+ methodName: "ModifyCertificateAsync",
+ pathTemplate: "$\"/organization/certificates/{certificateId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessModifyCertificateResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyCertificate",
+ methodName: "ModifyCertificateAsync",
+ pathTemplate: "$\"/organization/certificates/{certificateId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.Certificate.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.Certificate.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessModifyCertificateResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyCertificate",
+ methodName: "ModifyCertificateAsync",
+ pathTemplate: "$\"/organization/certificates/{certificateId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyCertificate",
+ methodName: "ModifyCertificateAsync",
+ pathTemplate: "$\"/organization/certificates/{certificateId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessModifyCertificateResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.Certificate.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.Certificate.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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();
+ }
}
///
/// Modify a certificate. Note that only the name can be modified.
@@ -216,11 +399,13 @@ partial void ProcessModifyCertificateResponseContent(
///
/// The updated name for the certificate
///
+ /// 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 ModifyCertificateAsync(
string certificateId,
string name,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.ModifyCertificateRequest
@@ -231,6 +416,7 @@ partial void ProcessModifyCertificateResponseContent(
return await ModifyCertificateAsync(
certificateId: certificateId,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.UploadCertificate.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.UploadCertificate.g.cs
index c15a0ec92..19e427c8f 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.UploadCertificate.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.UploadCertificate.g.cs
@@ -14,6 +14,7 @@ public partial class CertificatesClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -45,11 +46,13 @@ partial void ProcessUploadCertificateResponseContent(
/// Organizations can upload up to 50 certificates.
///
///
+ /// 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 UploadCertificateAsync(
global::tryAGI.OpenAI.UploadCertificateRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -66,22 +69,43 @@ partial void ProcessUploadCertificateResponseContent(
securityRequirements: s_UploadCertificateSecurityRequirements,
operationName: "UploadCertificateAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: "/organization/certificates",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: "/organization/certificates",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,118 +115,277 @@ partial void ProcessUploadCertificateResponseContent(
__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);
- PrepareUploadCertificateRequest(
- 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::tryAGI.OpenAI.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);
+ PrepareUploadCertificateRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessUploadCertificateResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UploadCertificate",
+ methodName: "UploadCertificateAsync",
+ pathTemplate: "\"/organization/certificates\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UploadCertificate",
+ methodName: "UploadCertificateAsync",
+ pathTemplate: "\"/organization/certificates\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessUploadCertificateResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UploadCertificate",
+ methodName: "UploadCertificateAsync",
+ pathTemplate: "\"/organization/certificates\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.Certificate.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.Certificate.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessUploadCertificateResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UploadCertificate",
+ methodName: "UploadCertificateAsync",
+ pathTemplate: "\"/organization/certificates\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UploadCertificate",
+ methodName: "UploadCertificateAsync",
+ pathTemplate: "\"/organization/certificates\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessUploadCertificateResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.Certificate.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.Certificate.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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 certificate to the organization. This does **not** automatically activate the certificate.
@@ -214,11 +397,13 @@ partial void ProcessUploadCertificateResponseContent(
///
/// The certificate content in PEM format
///
+ /// 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 UploadCertificateAsync(
string content,
string? name = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.UploadCertificateRequest
@@ -229,6 +414,7 @@ partial void ProcessUploadCertificateResponseContent(
return await UploadCertificateAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.g.cs
index ec9262f94..c53008f13 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CertificatesClient.g.cs
@@ -30,6 +30,9 @@ public sealed partial class CertificatesClient : global::tryAGI.OpenAI.ICertific
#if DEBUG
= true;
#endif
+
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
///
///
///
@@ -49,11 +52,37 @@ public CertificatesClient(
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 CertificatesClient.
+ /// 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 CertificatesClient(
+ global::System.Net.Http.HttpClient? httpClient = null,
+ global::System.Uri? baseUri = null,
+ global::System.Collections.Generic.List? authorizations = null,
+ global::tryAGI.OpenAI.AutoSDKClientOptions? options = null,
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::tryAGI.OpenAI.AutoSDKClientOptions();
_disposeHttpClient = disposeHttpClient;
Initialized(HttpClient);
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.CreateChatCompletion.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.CreateChatCompletion.g.cs
index 64f565190..c7e4c4357 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.CreateChatCompletion.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.CreateChatCompletion.g.cs
@@ -14,6 +14,7 @@ public partial class ChatClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -57,11 +58,13 @@ partial void ProcessCreateChatCompletionResponseContent(
/// chunk objects if the request is streamed.
///
///
+ /// 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 CreateChatCompletionAsync(
global::tryAGI.OpenAI.CreateChatCompletionRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -76,22 +79,43 @@ partial void ProcessCreateChatCompletionResponseContent(
securityRequirements: s_CreateChatCompletionSecurityRequirements,
operationName: "CreateChatCompletionAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: "/chat/completions",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,118 +125,277 @@ partial void ProcessCreateChatCompletionResponseContent(
__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);
- PrepareCreateChatCompletionRequest(
- 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::tryAGI.OpenAI.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);
+ PrepareCreateChatCompletionRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCreateChatCompletionResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateChatCompletion",
+ methodName: "CreateChatCompletionAsync",
+ pathTemplate: "\"/chat/completions\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateChatCompletion",
+ methodName: "CreateChatCompletionAsync",
+ pathTemplate: "\"/chat/completions\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessCreateChatCompletionResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateChatCompletion",
+ methodName: "CreateChatCompletionAsync",
+ pathTemplate: "\"/chat/completions\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.CreateChatCompletionResponse.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.CreateChatCompletionResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessCreateChatCompletionResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateChatCompletion",
+ methodName: "CreateChatCompletionAsync",
+ pathTemplate: "\"/chat/completions\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateChatCompletion",
+ methodName: "CreateChatCompletionAsync",
+ pathTemplate: "\"/chat/completions\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessCreateChatCompletionResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.CreateChatCompletionResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.CreateChatCompletionResponse.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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();
+ }
}
///
/// **Starting a new project?** We recommend trying [Responses](/docs/api-reference/responses)
@@ -230,9 +413,11 @@ partial void ProcessCreateChatCompletionResponseContent(
/// Returns a chat completion object, or a streamed sequence of chat completion
/// chunk objects if the request is streamed.
///
+ /// 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 CreateChatCompletionAsync(
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.CreateChatCompletionRequest
@@ -241,6 +426,7 @@ partial void ProcessCreateChatCompletionResponseContent(
return await CreateChatCompletionAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.CreateChatCompletionAsStream.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.CreateChatCompletionAsStream.g.cs
index 38964f005..7541f6940 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.CreateChatCompletionAsStream.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.CreateChatCompletionAsStream.g.cs
@@ -14,6 +14,7 @@ public partial class ChatClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -52,11 +53,13 @@ partial void ProcessCreateChatCompletionAsStreamResponse(
/// chunk objects if the request is streamed.
///
///
+ /// 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 CreateChatCompletionAsStreamAsync(
global::tryAGI.OpenAI.CreateChatCompletionRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
[global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -71,22 +74,43 @@ partial void ProcessCreateChatCompletionAsStreamResponse(
securityRequirements: s_CreateChatCompletionAsStreamSecurityRequirements,
operationName: "CreateChatCompletionAsStreamAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: "/chat/completions",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,95 +120,254 @@ partial void ProcessCreateChatCompletionAsStreamResponse(
__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);
- PrepareCreateChatCompletionAsStreamRequest(
- 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::tryAGI.OpenAI.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);
+ PrepareCreateChatCompletionAsStreamRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCreateChatCompletionAsStreamResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateChatCompletionAsStream",
+ methodName: "CreateChatCompletionAsStreamAsync",
+ pathTemplate: "\"/chat/completions\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateChatCompletionAsStream",
+ methodName: "CreateChatCompletionAsStreamAsync",
+ pathTemplate: "\"/chat/completions\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateChatCompletionAsStream",
+ methodName: "CreateChatCompletionAsStreamAsync",
+ pathTemplate: "\"/chat/completions\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception)
+
+ if (__response == null)
{
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::tryAGI.OpenAI.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);
+ ProcessCreateChatCompletionAsStreamResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateChatCompletionAsStream",
+ methodName: "CreateChatCompletionAsStreamAsync",
+ pathTemplate: "\"/chat/completions\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
{
- yield break;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateChatCompletionAsStream",
+ methodName: "CreateChatCompletionAsStreamAsync",
+ pathTemplate: "\"/chat/completions\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- var __streamedResponse = global::tryAGI.OpenAI.CreateChatCompletionStreamResponse.FromJson(__content, JsonSerializerContext) ??
- throw new global::tryAGI.OpenAI.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.CreateChatCompletionStreamResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::tryAGI.OpenAI.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();
}
}
///
@@ -203,9 +386,11 @@ partial void ProcessCreateChatCompletionAsStreamResponse(
/// Returns a chat completion object, or a streamed sequence of chat completion
/// chunk objects if the request is streamed.
///
+ /// 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 CreateChatCompletionAsStreamAsync(
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
[global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.CreateChatCompletionRequest
@@ -214,6 +399,7 @@ partial void ProcessCreateChatCompletionAsStreamResponse(
var __enumerable = CreateChatCompletionAsStreamAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken);
await foreach (var __response in __enumerable)
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.DeleteChatCompletion.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.DeleteChatCompletion.g.cs
index ef3f6907c..b92b1edbc 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.DeleteChatCompletion.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.DeleteChatCompletion.g.cs
@@ -14,6 +14,7 @@ public partial class ChatClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -45,10 +46,12 @@ partial void ProcessDeleteChatCompletionResponseContent(
/// created with the `store` parameter set to `true` can be deleted.
///
///
+ /// 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 DeleteChatCompletionAsync(
string completionId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -63,22 +66,43 @@ partial void ProcessDeleteChatCompletionResponseContent(
securityRequirements: s_DeleteChatCompletionSecurityRequirements,
operationName: "DeleteChatCompletionAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/chat/completions/{completionId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/chat/completions/{completionId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -88,112 +112,271 @@ partial void ProcessDeleteChatCompletionResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareDeleteChatCompletionRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- completionId: completionId);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareDeleteChatCompletionRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ completionId: completionId);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessDeleteChatCompletionResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteChatCompletion",
+ methodName: "DeleteChatCompletionAsync",
+ pathTemplate: "$\"/chat/completions/{completionId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteChatCompletion",
+ methodName: "DeleteChatCompletionAsync",
+ pathTemplate: "$\"/chat/completions/{completionId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessDeleteChatCompletionResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteChatCompletion",
+ methodName: "DeleteChatCompletionAsync",
+ pathTemplate: "$\"/chat/completions/{completionId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.ChatCompletionDeleted.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.ChatCompletionDeleted.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessDeleteChatCompletionResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteChatCompletion",
+ methodName: "DeleteChatCompletionAsync",
+ pathTemplate: "$\"/chat/completions/{completionId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteChatCompletion",
+ methodName: "DeleteChatCompletionAsync",
+ pathTemplate: "$\"/chat/completions/{completionId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessDeleteChatCompletionResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.ChatCompletionDeleted.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ChatCompletionDeleted.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.GetChatCompletion.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.GetChatCompletion.g.cs
index f9751309f..89d053194 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.GetChatCompletion.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.GetChatCompletion.g.cs
@@ -14,6 +14,7 @@ public partial class ChatClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -45,10 +46,12 @@ partial void ProcessGetChatCompletionResponseContent(
/// with the `store` parameter set to `true` will be returned.
///
///
+ /// 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 GetChatCompletionAsync(
string completionId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -63,22 +66,43 @@ partial void ProcessGetChatCompletionResponseContent(
securityRequirements: s_GetChatCompletionSecurityRequirements,
operationName: "GetChatCompletionAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/chat/completions/{completionId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/chat/completions/{completionId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,112 +112,271 @@ partial void ProcessGetChatCompletionResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareGetChatCompletionRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- completionId: completionId);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareGetChatCompletionRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ completionId: completionId);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessGetChatCompletionResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetChatCompletion",
+ methodName: "GetChatCompletionAsync",
+ pathTemplate: "$\"/chat/completions/{completionId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetChatCompletion",
+ methodName: "GetChatCompletionAsync",
+ pathTemplate: "$\"/chat/completions/{completionId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessGetChatCompletionResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetChatCompletion",
+ methodName: "GetChatCompletionAsync",
+ pathTemplate: "$\"/chat/completions/{completionId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.CreateChatCompletionResponse.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.CreateChatCompletionResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessGetChatCompletionResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetChatCompletion",
+ methodName: "GetChatCompletionAsync",
+ pathTemplate: "$\"/chat/completions/{completionId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetChatCompletion",
+ methodName: "GetChatCompletionAsync",
+ pathTemplate: "$\"/chat/completions/{completionId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessGetChatCompletionResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.CreateChatCompletionResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.CreateChatCompletionResponse.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.GetChatMessages.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.GetChatMessages.g.cs
index 46f402317..dbcc264fa 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.GetChatMessages.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.GetChatMessages.g.cs
@@ -14,6 +14,7 @@ public partial class ChatClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -59,6 +60,7 @@ partial void ProcessGetChatMessagesResponseContent(
///
/// Default Value: asc
///
+ /// 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 GetChatMessagesAsync(
@@ -66,6 +68,7 @@ partial void ProcessGetChatMessagesResponseContent(
string? after = default,
int? limit = default,
global::tryAGI.OpenAI.GetChatCompletionMessagesOrder? order = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -83,27 +86,48 @@ partial void ProcessGetChatMessagesResponseContent(
securityRequirements: s_GetChatMessagesSecurityRequirements,
operationName: "GetChatMessagesAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/chat/completions/{completionId}/messages",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("after", after)
- .AddOptionalParameter("limit", limit?.ToString())
- .AddOptionalParameter("order", order?.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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/chat/completions/{completionId}/messages",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("after", after)
+ .AddOptionalParameter("limit", limit?.ToString())
+ .AddOptionalParameter("order", order?.ToValueString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -113,115 +137,274 @@ partial void ProcessGetChatMessagesResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareGetChatMessagesRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- completionId: completionId,
- after: after,
- limit: limit,
- order: order);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareGetChatMessagesRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ completionId: completionId,
+ after: after,
+ limit: limit,
+ order: order);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessGetChatMessagesResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetChatMessages",
+ methodName: "GetChatMessagesAsync",
+ pathTemplate: "$\"/chat/completions/{completionId}/messages\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetChatMessages",
+ methodName: "GetChatMessagesAsync",
+ pathTemplate: "$\"/chat/completions/{completionId}/messages\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessGetChatMessagesResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetChatMessages",
+ methodName: "GetChatMessagesAsync",
+ pathTemplate: "$\"/chat/completions/{completionId}/messages\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.ChatCompletionMessageList.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.ChatCompletionMessageList.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessGetChatMessagesResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetChatMessages",
+ methodName: "GetChatMessagesAsync",
+ pathTemplate: "$\"/chat/completions/{completionId}/messages\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetChatMessages",
+ methodName: "GetChatMessagesAsync",
+ pathTemplate: "$\"/chat/completions/{completionId}/messages\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessGetChatMessagesResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.ChatCompletionMessageList.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ChatCompletionMessageList.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.ListChatCompletions.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.ListChatCompletions.g.cs
index 0c7631be2..733e3ce60 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.ListChatCompletions.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.ListChatCompletions.g.cs
@@ -14,6 +14,7 @@ public partial class ChatClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -61,6 +62,7 @@ partial void ProcessListChatCompletionsResponseContent(
///
/// Default Value: asc
///
+ /// 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 ListChatCompletionsAsync(
@@ -69,6 +71,7 @@ partial void ProcessListChatCompletionsResponseContent(
string? after = default,
int? limit = default,
global::tryAGI.OpenAI.ListChatCompletionsOrder? order = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -87,29 +90,50 @@ partial void ProcessListChatCompletionsResponseContent(
securityRequirements: s_ListChatCompletionsSecurityRequirements,
operationName: "ListChatCompletionsAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: "/chat/completions",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("model", model)
- .AddOptionalParameter("metadata", metadata?.ToString())
- .AddOptionalParameter("after", after)
- .AddOptionalParameter("limit", limit?.ToString())
- .AddOptionalParameter("order", order?.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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: "/chat/completions",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("model", model)
+ .AddOptionalParameter("metadata", metadata?.ToString())
+ .AddOptionalParameter("after", after)
+ .AddOptionalParameter("limit", limit?.ToString())
+ .AddOptionalParameter("order", order?.ToValueString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -119,116 +143,275 @@ partial void ProcessListChatCompletionsResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareListChatCompletionsRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- model: model,
- metadata: metadata,
- after: after,
- limit: limit,
- order: order);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareListChatCompletionsRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ model: model,
+ metadata: metadata,
+ after: after,
+ limit: limit,
+ order: order);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessListChatCompletionsResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListChatCompletions",
+ methodName: "ListChatCompletionsAsync",
+ pathTemplate: "\"/chat/completions\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListChatCompletions",
+ methodName: "ListChatCompletionsAsync",
+ pathTemplate: "\"/chat/completions\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessListChatCompletionsResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListChatCompletions",
+ methodName: "ListChatCompletionsAsync",
+ pathTemplate: "\"/chat/completions\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.ChatCompletionList.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.ChatCompletionList.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessListChatCompletionsResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListChatCompletions",
+ methodName: "ListChatCompletionsAsync",
+ pathTemplate: "\"/chat/completions\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListChatCompletions",
+ methodName: "ListChatCompletionsAsync",
+ pathTemplate: "\"/chat/completions\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessListChatCompletionsResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.ChatCompletionList.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ChatCompletionList.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.UpdateChatCompletion.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.UpdateChatCompletion.g.cs
index 57d2fcf7d..344868a26 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.UpdateChatCompletion.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.UpdateChatCompletion.g.cs
@@ -14,6 +14,7 @@ public partial class ChatClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -49,12 +50,14 @@ partial void ProcessUpdateChatCompletionResponseContent(
///
///
///
+ /// 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 UpdateChatCompletionAsync(
string completionId,
global::tryAGI.OpenAI.UpdateChatCompletionRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -72,22 +75,43 @@ partial void ProcessUpdateChatCompletionResponseContent(
securityRequirements: s_UpdateChatCompletionSecurityRequirements,
operationName: "UpdateChatCompletionAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/chat/completions/{completionId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/chat/completions/{completionId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,119 +121,278 @@ partial void ProcessUpdateChatCompletionResponseContent(
__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);
- PrepareUpdateChatCompletionRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- completionId: completionId,
- 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::tryAGI.OpenAI.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);
+ PrepareUpdateChatCompletionRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ completionId: completionId,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessUpdateChatCompletionResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UpdateChatCompletion",
+ methodName: "UpdateChatCompletionAsync",
+ pathTemplate: "$\"/chat/completions/{completionId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UpdateChatCompletion",
+ methodName: "UpdateChatCompletionAsync",
+ pathTemplate: "$\"/chat/completions/{completionId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessUpdateChatCompletionResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UpdateChatCompletion",
+ methodName: "UpdateChatCompletionAsync",
+ pathTemplate: "$\"/chat/completions/{completionId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.CreateChatCompletionResponse.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.CreateChatCompletionResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessUpdateChatCompletionResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UpdateChatCompletion",
+ methodName: "UpdateChatCompletionAsync",
+ pathTemplate: "$\"/chat/completions/{completionId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UpdateChatCompletion",
+ methodName: "UpdateChatCompletionAsync",
+ pathTemplate: "$\"/chat/completions/{completionId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessUpdateChatCompletionResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.CreateChatCompletionResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.CreateChatCompletionResponse.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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();
+ }
}
///
/// Modify a stored chat completion. Only Chat Completions that have been
@@ -218,11 +401,13 @@ partial void ProcessUpdateChatCompletionResponseContent(
///
///
///
+ /// 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 UpdateChatCompletionAsync(
string completionId,
global::System.Collections.Generic.Dictionary? metadata = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.UpdateChatCompletionRequest
@@ -233,6 +418,7 @@ partial void ProcessUpdateChatCompletionResponseContent(
return await UpdateChatCompletionAsync(
completionId: completionId,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.g.cs
index ade1fbfeb..d719b3938 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ChatClient.g.cs
@@ -31,6 +31,9 @@ public sealed partial class ChatClient : global::tryAGI.OpenAI.IChatClient, glob
#if DEBUG
= true;
#endif
+
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
///
///
///
@@ -50,11 +53,37 @@ 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.
+ /// 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 = null,
+ global::System.Uri? baseUri = null,
+ global::System.Collections.Generic.List? authorizations = null,
+ global::tryAGI.OpenAI.AutoSDKClientOptions? options = null,
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::tryAGI.OpenAI.AutoSDKClientOptions();
_disposeHttpClient = disposeHttpClient;
Initialized(HttpClient);
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CompletionsClient.CreateCompletion.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CompletionsClient.CreateCompletion.g.cs
index 0fcd5b393..072477617 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CompletionsClient.CreateCompletion.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CompletionsClient.CreateCompletion.g.cs
@@ -14,6 +14,7 @@ public partial class CompletionsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -45,11 +46,13 @@ partial void ProcessCreateCompletionResponseContent(
/// Returns a completion object, or a sequence of completion objects if the request is streamed.
///
///
+ /// 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 CreateCompletionAsync(
global::tryAGI.OpenAI.CreateCompletionRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -66,22 +69,43 @@ partial void ProcessCreateCompletionResponseContent(
securityRequirements: s_CreateCompletionSecurityRequirements,
operationName: "CreateCompletionAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: "/completions",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,118 +115,277 @@ partial void ProcessCreateCompletionResponseContent(
__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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareCreateCompletionRequest(
- 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);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareCreateCompletionRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCreateCompletionResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateCompletion",
+ methodName: "CreateCompletionAsync",
+ pathTemplate: "\"/completions\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateCompletion",
+ methodName: "CreateCompletionAsync",
+ pathTemplate: "\"/completions\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessCreateCompletionResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateCompletion",
+ methodName: "CreateCompletionAsync",
+ pathTemplate: "\"/completions\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.CreateCompletionResponse.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.CreateCompletionResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessCreateCompletionResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateCompletion",
+ methodName: "CreateCompletionAsync",
+ pathTemplate: "\"/completions\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateCompletion",
+ methodName: "CreateCompletionAsync",
+ pathTemplate: "\"/completions\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessCreateCompletionResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.CreateCompletionResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.CreateCompletionResponse.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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();
+ }
}
///
/// Creates a completion for the provided prompt and parameters.
@@ -296,6 +479,7 @@ partial void ProcessCreateCompletionResponseContent(
/// A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids).
/// Example: user-1234
///
+ /// 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 CreateCompletionAsync(
@@ -317,6 +501,7 @@ partial void ProcessCreateCompletionResponseContent(
double? temperature = default,
double? topP = default,
string? user = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.CreateCompletionRequest
@@ -343,6 +528,7 @@ partial void ProcessCreateCompletionResponseContent(
return await CreateCompletionAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CompletionsClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CompletionsClient.g.cs
index c0e74566a..79b421e8c 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CompletionsClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.CompletionsClient.g.cs
@@ -31,6 +31,9 @@ public sealed partial class CompletionsClient : global::tryAGI.OpenAI.ICompletio
#if DEBUG
= true;
#endif
+
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
///
///
///
@@ -50,11 +53,37 @@ public CompletionsClient(
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 CompletionsClient.
+ /// 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 CompletionsClient(
+ global::System.Net.Http.HttpClient? httpClient = null,
+ global::System.Uri? baseUri = null,
+ global::System.Collections.Generic.List? authorizations = null,
+ global::tryAGI.OpenAI.AutoSDKClientOptions? options = null,
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::tryAGI.OpenAI.AutoSDKClientOptions();
_disposeHttpClient = disposeHttpClient;
Initialized(HttpClient);
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.CreateAConversation.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.CreateAConversation.g.cs
index 7c4a35a71..07703ac8b 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.CreateAConversation.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.CreateAConversation.g.cs
@@ -14,6 +14,7 @@ public partial class ConversationsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -44,11 +45,13 @@ partial void ProcessCreateAConversationResponseContent(
/// Create a conversation.
///
///
+ /// 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 CreateAConversationAsync(
global::tryAGI.OpenAI.CreateConversationBody request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -65,22 +68,43 @@ partial void ProcessCreateAConversationResponseContent(
securityRequirements: s_CreateAConversationSecurityRequirements,
operationName: "CreateAConversationAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: "/conversations",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: "/conversations",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,129 +114,290 @@ partial void ProcessCreateAConversationResponseContent(
__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);
- PrepareCreateAConversationRequest(
- 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::tryAGI.OpenAI.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);
+ PrepareCreateAConversationRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCreateAConversationResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateAConversation",
+ methodName: "CreateAConversationAsync",
+ pathTemplate: "\"/conversations\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateAConversation",
+ methodName: "CreateAConversationAsync",
+ pathTemplate: "\"/conversations\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessCreateAConversationResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateAConversation",
+ methodName: "CreateAConversationAsync",
+ pathTemplate: "\"/conversations\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.ConversationResource.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.ConversationResource.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessCreateAConversationResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateAConversation",
+ methodName: "CreateAConversationAsync",
+ pathTemplate: "\"/conversations\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateAConversation",
+ methodName: "CreateAConversationAsync",
+ pathTemplate: "\"/conversations\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessCreateAConversationResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.ConversationResource.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ConversationResource.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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 conversation.
///
///
///
+ /// 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 CreateAConversationAsync(
global::System.Collections.Generic.Dictionary? metadata = default,
global::System.Collections.Generic.IList? items = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.CreateConversationBody
@@ -223,6 +408,7 @@ partial void ProcessCreateAConversationResponseContent(
return await CreateAConversationAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.CreateItems.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.CreateItems.g.cs
index b3bc6ffc7..3d59f49fd 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.CreateItems.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.CreateItems.g.cs
@@ -14,6 +14,7 @@ public partial class ConversationsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -52,6 +53,7 @@ partial void ProcessCreateItemsResponseContent(
///
///
///
+ /// 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 CreateItemsAsync(
@@ -59,6 +61,7 @@ partial void ProcessCreateItemsResponseContent(
global::tryAGI.OpenAI.CreateConversationItemsRequest request,
global::System.Collections.Generic.IList? include = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -77,25 +80,46 @@ partial void ProcessCreateItemsResponseContent(
securityRequirements: s_CreateItemsSecurityRequirements,
operationName: "CreateItemsAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/conversations/{conversationId}/items",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("include", include, selector: static x => x.ToValueString(), delimiter: ",", explode: true)
- ;
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/conversations/{conversationId}/items",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("include", include, selector: static x => x.ToValueString(), delimiter: ",", explode: true)
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,120 +129,279 @@ partial void ProcessCreateItemsResponseContent(
__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);
- PrepareCreateItemsRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- conversationId: conversationId,
- include: include,
- 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::tryAGI.OpenAI.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);
+ PrepareCreateItemsRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ conversationId: conversationId,
+ include: include,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCreateItemsResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateItems",
+ methodName: "CreateItemsAsync",
+ pathTemplate: "$\"/conversations/{conversationId}/items\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateItems",
+ methodName: "CreateItemsAsync",
+ pathTemplate: "$\"/conversations/{conversationId}/items\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessCreateItemsResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateItems",
+ methodName: "CreateItemsAsync",
+ pathTemplate: "$\"/conversations/{conversationId}/items\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.ConversationItemList.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.ConversationItemList.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessCreateItemsResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateItems",
+ methodName: "CreateItemsAsync",
+ pathTemplate: "$\"/conversations/{conversationId}/items\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateItems",
+ methodName: "CreateItemsAsync",
+ pathTemplate: "$\"/conversations/{conversationId}/items\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessCreateItemsResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.ConversationItemList.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ConversationItemList.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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 items in a conversation with the given ID.
@@ -230,12 +413,14 @@ partial void ProcessCreateItemsResponseContent(
///
/// The items to add to the conversation. You may add up to 20 items at a time.
///
+ /// 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 CreateItemsAsync(
string conversationId,
global::System.Collections.Generic.IList items,
global::System.Collections.Generic.IList? include = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.CreateConversationItemsRequest
@@ -247,6 +432,7 @@ partial void ProcessCreateItemsResponseContent(
conversationId: conversationId,
include: include,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.DeleteAConversation.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.DeleteAConversation.g.cs
index 18b44cabf..bcea8b8b6 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.DeleteAConversation.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.DeleteAConversation.g.cs
@@ -14,6 +14,7 @@ public partial class ConversationsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -46,10 +47,12 @@ partial void ProcessDeleteAConversationResponseContent(
///
/// Example: conv_123
///
+ /// 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 DeleteAConversationAsync(
string conversationId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -64,22 +67,43 @@ partial void ProcessDeleteAConversationResponseContent(
securityRequirements: s_DeleteAConversationSecurityRequirements,
operationName: "DeleteAConversationAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/conversations/{conversationId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/conversations/{conversationId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -89,112 +113,271 @@ partial void ProcessDeleteAConversationResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareDeleteAConversationRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- conversationId: conversationId);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareDeleteAConversationRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ conversationId: conversationId);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessDeleteAConversationResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAConversation",
+ methodName: "DeleteAConversationAsync",
+ pathTemplate: "$\"/conversations/{conversationId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAConversation",
+ methodName: "DeleteAConversationAsync",
+ pathTemplate: "$\"/conversations/{conversationId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessDeleteAConversationResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAConversation",
+ methodName: "DeleteAConversationAsync",
+ pathTemplate: "$\"/conversations/{conversationId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.DeletedConversationResource.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.DeletedConversationResource.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessDeleteAConversationResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAConversation",
+ methodName: "DeleteAConversationAsync",
+ pathTemplate: "$\"/conversations/{conversationId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAConversation",
+ methodName: "DeleteAConversationAsync",
+ pathTemplate: "$\"/conversations/{conversationId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessDeleteAConversationResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.DeletedConversationResource.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.DeletedConversationResource.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.DeleteAnItem.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.DeleteAnItem.g.cs
index c89567867..4881bd7e6 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.DeleteAnItem.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.DeleteAnItem.g.cs
@@ -14,6 +14,7 @@ public partial class ConversationsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -51,11 +52,13 @@ partial void ProcessDeleteAnItemResponseContent(
///
/// Example: msg_abc
///
+ /// 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 DeleteAnItemAsync(
string conversationId,
string itemId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -71,22 +74,43 @@ partial void ProcessDeleteAnItemResponseContent(
securityRequirements: s_DeleteAnItemSecurityRequirements,
operationName: "DeleteAnItemAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/conversations/{conversationId}/items/{itemId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/conversations/{conversationId}/items/{itemId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,113 +120,272 @@ partial void ProcessDeleteAnItemResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareDeleteAnItemRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- conversationId: conversationId,
- itemId: itemId);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareDeleteAnItemRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ conversationId: conversationId,
+ itemId: itemId);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessDeleteAnItemResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAnItem",
+ methodName: "DeleteAnItemAsync",
+ pathTemplate: "$\"/conversations/{conversationId}/items/{itemId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAnItem",
+ methodName: "DeleteAnItemAsync",
+ pathTemplate: "$\"/conversations/{conversationId}/items/{itemId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessDeleteAnItemResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAnItem",
+ methodName: "DeleteAnItemAsync",
+ pathTemplate: "$\"/conversations/{conversationId}/items/{itemId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.ConversationResource.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.ConversationResource.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessDeleteAnItemResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAnItem",
+ methodName: "DeleteAnItemAsync",
+ pathTemplate: "$\"/conversations/{conversationId}/items/{itemId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAnItem",
+ methodName: "DeleteAnItemAsync",
+ pathTemplate: "$\"/conversations/{conversationId}/items/{itemId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessDeleteAnItemResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.ConversationResource.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ConversationResource.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.ListItems.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.ListItems.g.cs
index 96e6141ca..dd6da0cc7 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.ListItems.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.ListItems.g.cs
@@ -14,6 +14,7 @@ public partial class ConversationsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -60,6 +61,7 @@ partial void ProcessListItemsResponseContent(
///
///
///
+ /// 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 ListItemsAsync(
@@ -68,6 +70,7 @@ partial void ProcessListItemsResponseContent(
global::tryAGI.OpenAI.ListConversationItemsOrder? order = default,
string? after = default,
global::System.Collections.Generic.IList? include = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -86,28 +89,49 @@ partial void ProcessListItemsResponseContent(
securityRequirements: s_ListItemsSecurityRequirements,
operationName: "ListItemsAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/conversations/{conversationId}/items",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("limit", limit?.ToString())
- .AddOptionalParameter("order", order?.ToValueString())
- .AddOptionalParameter("after", after)
- .AddOptionalParameter("include", include, selector: static x => x.ToValueString(), delimiter: ",", explode: true)
- ;
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/conversations/{conversationId}/items",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("limit", limit?.ToString())
+ .AddOptionalParameter("order", order?.ToValueString())
+ .AddOptionalParameter("after", after)
+ .AddOptionalParameter("include", include, selector: static x => x.ToValueString(), delimiter: ",", explode: true)
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -117,116 +141,275 @@ partial void ProcessListItemsResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareListItemsRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- conversationId: conversationId,
- limit: limit,
- order: order,
- after: after,
- include: include);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareListItemsRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ conversationId: conversationId,
+ limit: limit,
+ order: order,
+ after: after,
+ include: include);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessListItemsResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListItems",
+ methodName: "ListItemsAsync",
+ pathTemplate: "$\"/conversations/{conversationId}/items\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListItems",
+ methodName: "ListItemsAsync",
+ pathTemplate: "$\"/conversations/{conversationId}/items\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessListItemsResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListItems",
+ methodName: "ListItemsAsync",
+ pathTemplate: "$\"/conversations/{conversationId}/items\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.ConversationItemList.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.ConversationItemList.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessListItemsResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListItems",
+ methodName: "ListItemsAsync",
+ pathTemplate: "$\"/conversations/{conversationId}/items\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListItems",
+ methodName: "ListItemsAsync",
+ pathTemplate: "$\"/conversations/{conversationId}/items\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessListItemsResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.ConversationItemList.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ConversationItemList.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.RetrieveAConversation.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.RetrieveAConversation.g.cs
index 1e5c7979b..6b0451870 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.RetrieveAConversation.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.RetrieveAConversation.g.cs
@@ -14,6 +14,7 @@ public partial class ConversationsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -46,10 +47,12 @@ partial void ProcessRetrieveAConversationResponseContent(
///
/// Example: conv_123
///
+ /// 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 RetrieveAConversationAsync(
string conversationId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -64,22 +67,43 @@ partial void ProcessRetrieveAConversationResponseContent(
securityRequirements: s_RetrieveAConversationSecurityRequirements,
operationName: "RetrieveAConversationAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/conversations/{conversationId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/conversations/{conversationId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,112 +113,271 @@ partial void ProcessRetrieveAConversationResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareRetrieveAConversationRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- conversationId: conversationId);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareRetrieveAConversationRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ conversationId: conversationId);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessRetrieveAConversationResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveAConversation",
+ methodName: "RetrieveAConversationAsync",
+ pathTemplate: "$\"/conversations/{conversationId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveAConversation",
+ methodName: "RetrieveAConversationAsync",
+ pathTemplate: "$\"/conversations/{conversationId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessRetrieveAConversationResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveAConversation",
+ methodName: "RetrieveAConversationAsync",
+ pathTemplate: "$\"/conversations/{conversationId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.ConversationResource.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.ConversationResource.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessRetrieveAConversationResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveAConversation",
+ methodName: "RetrieveAConversationAsync",
+ pathTemplate: "$\"/conversations/{conversationId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveAConversation",
+ methodName: "RetrieveAConversationAsync",
+ pathTemplate: "$\"/conversations/{conversationId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessRetrieveAConversationResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.ConversationResource.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ConversationResource.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.RetrieveAnItem.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.RetrieveAnItem.g.cs
index b1ce42b4c..17904fca9 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.RetrieveAnItem.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.RetrieveAnItem.g.cs
@@ -14,6 +14,7 @@ public partial class ConversationsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -54,12 +55,14 @@ partial void ProcessRetrieveAnItemResponseContent(
/// Example: msg_abc
///
///
+ /// 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 RetrieveAnItemAsync(
string conversationId,
string itemId,
global::System.Collections.Generic.IList? include = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -76,25 +79,46 @@ partial void ProcessRetrieveAnItemResponseContent(
securityRequirements: s_RetrieveAnItemSecurityRequirements,
operationName: "RetrieveAnItemAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/conversations/{conversationId}/items/{itemId}",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("include", include, selector: static x => x.ToValueString(), delimiter: ",", explode: true)
- ;
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/conversations/{conversationId}/items/{itemId}",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("include", include, selector: static x => x.ToValueString(), delimiter: ",", explode: true)
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,114 +128,273 @@ partial void ProcessRetrieveAnItemResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareRetrieveAnItemRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- conversationId: conversationId,
- itemId: itemId,
- include: include);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareRetrieveAnItemRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ conversationId: conversationId,
+ itemId: itemId,
+ include: include);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessRetrieveAnItemResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveAnItem",
+ methodName: "RetrieveAnItemAsync",
+ pathTemplate: "$\"/conversations/{conversationId}/items/{itemId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveAnItem",
+ methodName: "RetrieveAnItemAsync",
+ pathTemplate: "$\"/conversations/{conversationId}/items/{itemId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessRetrieveAnItemResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveAnItem",
+ methodName: "RetrieveAnItemAsync",
+ pathTemplate: "$\"/conversations/{conversationId}/items/{itemId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.ConversationItem.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.ConversationItem.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessRetrieveAnItemResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveAnItem",
+ methodName: "RetrieveAnItemAsync",
+ pathTemplate: "$\"/conversations/{conversationId}/items/{itemId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveAnItem",
+ methodName: "RetrieveAnItemAsync",
+ pathTemplate: "$\"/conversations/{conversationId}/items/{itemId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessRetrieveAnItemResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.ConversationItem.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ConversationItem.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.UpdateAConversation.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.UpdateAConversation.g.cs
index 416efd72b..f9772426d 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.UpdateAConversation.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.UpdateAConversation.g.cs
@@ -14,6 +14,7 @@ public partial class ConversationsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -49,12 +50,14 @@ partial void ProcessUpdateAConversationResponseContent(
/// Example: conv_123
///
///
+ /// 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 UpdateAConversationAsync(
string conversationId,
global::tryAGI.OpenAI.UpdateConversationBody request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -72,22 +75,43 @@ partial void ProcessUpdateAConversationResponseContent(
securityRequirements: s_UpdateAConversationSecurityRequirements,
operationName: "UpdateAConversationAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/conversations/{conversationId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/conversations/{conversationId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,119 +121,278 @@ partial void ProcessUpdateAConversationResponseContent(
__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);
- PrepareUpdateAConversationRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- conversationId: conversationId,
- 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::tryAGI.OpenAI.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);
+ PrepareUpdateAConversationRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ conversationId: conversationId,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessUpdateAConversationResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UpdateAConversation",
+ methodName: "UpdateAConversationAsync",
+ pathTemplate: "$\"/conversations/{conversationId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UpdateAConversation",
+ methodName: "UpdateAConversationAsync",
+ pathTemplate: "$\"/conversations/{conversationId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessUpdateAConversationResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UpdateAConversation",
+ methodName: "UpdateAConversationAsync",
+ pathTemplate: "$\"/conversations/{conversationId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.ConversationResource.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.ConversationResource.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessUpdateAConversationResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UpdateAConversation",
+ methodName: "UpdateAConversationAsync",
+ pathTemplate: "$\"/conversations/{conversationId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UpdateAConversation",
+ methodName: "UpdateAConversationAsync",
+ pathTemplate: "$\"/conversations/{conversationId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessUpdateAConversationResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.ConversationResource.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ConversationResource.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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 conversation
@@ -221,11 +404,13 @@ partial void ProcessUpdateAConversationResponseContent(
/// Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.
/// Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
///
+ /// 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 UpdateAConversationAsync(
string conversationId,
global::System.Collections.Generic.Dictionary? metadata = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.UpdateConversationBody
@@ -236,6 +421,7 @@ partial void ProcessUpdateAConversationResponseContent(
return await UpdateAConversationAsync(
conversationId: conversationId,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.g.cs
index ee4daf8b8..facab2cd2 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ConversationsClient.g.cs
@@ -31,6 +31,9 @@ public sealed partial class ConversationsClient : global::tryAGI.OpenAI.IConvers
#if DEBUG
= true;
#endif
+
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
///
///
///
@@ -50,11 +53,37 @@ public ConversationsClient(
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 ConversationsClient.
+ /// 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 ConversationsClient(
+ global::System.Net.Http.HttpClient? httpClient = null,
+ global::System.Uri? baseUri = null,
+ global::System.Collections.Generic.List? authorizations = null,
+ global::tryAGI.OpenAI.AutoSDKClientOptions? options = null,
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::tryAGI.OpenAI.AutoSDKClientOptions();
_disposeHttpClient = disposeHttpClient;
Initialized(HttpClient);
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EmbeddingsClient.CreateEmbeddings.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EmbeddingsClient.CreateEmbeddings.g.cs
index c20affdfd..ce4e1dbf4 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EmbeddingsClient.CreateEmbeddings.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EmbeddingsClient.CreateEmbeddings.g.cs
@@ -14,6 +14,7 @@ public partial class EmbeddingsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -44,11 +45,13 @@ partial void ProcessCreateEmbeddingsResponseContent(
/// Creates an embedding vector representing the input 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 CreateEmbeddingsAsync(
global::tryAGI.OpenAI.CreateEmbeddingRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -65,22 +68,43 @@ partial void ProcessCreateEmbeddingsResponseContent(
securityRequirements: s_CreateEmbeddingsSecurityRequirements,
operationName: "CreateEmbeddingsAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: "/embeddings",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,118 +114,277 @@ partial void ProcessCreateEmbeddingsResponseContent(
__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);
- PrepareCreateEmbeddingsRequest(
- 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::tryAGI.OpenAI.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);
+ PrepareCreateEmbeddingsRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCreateEmbeddingsResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateEmbeddings",
+ methodName: "CreateEmbeddingsAsync",
+ pathTemplate: "\"/embeddings\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateEmbeddings",
+ methodName: "CreateEmbeddingsAsync",
+ pathTemplate: "\"/embeddings\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessCreateEmbeddingsResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateEmbeddings",
+ methodName: "CreateEmbeddingsAsync",
+ pathTemplate: "\"/embeddings\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.CreateEmbeddingResponse.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.CreateEmbeddingResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessCreateEmbeddingsResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateEmbeddings",
+ methodName: "CreateEmbeddingsAsync",
+ pathTemplate: "\"/embeddings\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateEmbeddings",
+ methodName: "CreateEmbeddingsAsync",
+ pathTemplate: "\"/embeddings\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessCreateEmbeddingsResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.CreateEmbeddingResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.CreateEmbeddingResponse.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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();
+ }
}
///
/// Creates an embedding vector representing the input text.
@@ -226,6 +409,7 @@ partial void ProcessCreateEmbeddingsResponseContent(
/// A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids).
/// Example: user-1234
///
+ /// 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 CreateEmbeddingsAsync(
@@ -234,6 +418,7 @@ partial void ProcessCreateEmbeddingsResponseContent(
global::tryAGI.OpenAI.CreateEmbeddingRequestEncodingFormat? encodingFormat = default,
int? dimensions = default,
string? user = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.CreateEmbeddingRequest
@@ -247,6 +432,7 @@ partial void ProcessCreateEmbeddingsResponseContent(
return await CreateEmbeddingsAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EmbeddingsClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EmbeddingsClient.g.cs
index c407fc554..63ebde2cf 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EmbeddingsClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EmbeddingsClient.g.cs
@@ -31,6 +31,9 @@ public sealed partial class EmbeddingsClient : global::tryAGI.OpenAI.IEmbeddings
#if DEBUG
= true;
#endif
+
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
///
///
///
@@ -50,11 +53,37 @@ 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.
+ /// 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 = null,
+ global::System.Uri? baseUri = null,
+ global::System.Collections.Generic.List? authorizations = null,
+ global::tryAGI.OpenAI.AutoSDKClientOptions? options = null,
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::tryAGI.OpenAI.AutoSDKClientOptions();
_disposeHttpClient = disposeHttpClient;
Initialized(HttpClient);
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.CancelEvalRun.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.CancelEvalRun.g.cs
index 6b3d250d9..834e8aad8 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.CancelEvalRun.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.CancelEvalRun.g.cs
@@ -14,6 +14,7 @@ public partial class EvalsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -47,11 +48,13 @@ partial void ProcessCancelEvalRunResponseContent(
///
///
///
+ /// 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 CancelEvalRunAsync(
string evalId,
string runId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -67,22 +70,43 @@ partial void ProcessCancelEvalRunResponseContent(
securityRequirements: s_CancelEvalRunSecurityRequirements,
operationName: "CancelEvalRunAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/evals/{evalId}/runs/{runId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/evals/{evalId}/runs/{runId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -92,113 +116,272 @@ partial void ProcessCancelEvalRunResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareCancelEvalRunRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- evalId: evalId,
- runId: runId);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareCancelEvalRunRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ evalId: evalId,
+ runId: runId);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCancelEvalRunResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CancelEvalRun",
+ methodName: "CancelEvalRunAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs/{runId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CancelEvalRun",
+ methodName: "CancelEvalRunAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs/{runId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessCancelEvalRunResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CancelEvalRun",
+ methodName: "CancelEvalRunAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs/{runId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.EvalRun.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.EvalRun.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessCancelEvalRunResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CancelEvalRun",
+ methodName: "CancelEvalRunAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs/{runId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CancelEvalRun",
+ methodName: "CancelEvalRunAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs/{runId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessCancelEvalRunResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.EvalRun.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.EvalRun.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.CreateEval.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.CreateEval.g.cs
index 0daf504d0..350017128 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.CreateEval.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.CreateEval.g.cs
@@ -16,6 +16,7 @@ public partial class EvalsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -48,11 +49,13 @@ partial void ProcessCreateEvalResponseContent(
/// For more information, see the [Evals guide](/docs/guides/evals).
///
///
+ /// 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 CreateEvalAsync(
global::tryAGI.OpenAI.CreateEvalRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -69,22 +72,43 @@ partial void ProcessCreateEvalResponseContent(
securityRequirements: s_CreateEvalSecurityRequirements,
operationName: "CreateEvalAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: "/evals",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: "/evals",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,118 +118,277 @@ partial void ProcessCreateEvalResponseContent(
__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);
- PrepareCreateEvalRequest(
- 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::tryAGI.OpenAI.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);
+ PrepareCreateEvalRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCreateEvalResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateEval",
+ methodName: "CreateEvalAsync",
+ pathTemplate: "\"/evals\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateEval",
+ methodName: "CreateEvalAsync",
+ pathTemplate: "\"/evals\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessCreateEvalResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateEval",
+ methodName: "CreateEvalAsync",
+ pathTemplate: "\"/evals\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.Eval.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.Eval.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessCreateEvalResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateEval",
+ methodName: "CreateEvalAsync",
+ pathTemplate: "\"/evals\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateEval",
+ methodName: "CreateEvalAsync",
+ pathTemplate: "\"/evals\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessCreateEvalResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.Eval.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.Eval.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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 the structure of an evaluation that can be used to test a model's performance.
@@ -222,6 +405,7 @@ partial void ProcessCreateEvalResponseContent(
///
/// A list of graders for all eval runs in this group. Graders can reference variables in the data source using double curly braces notation, like `{{item.variable_name}}`. To reference the model's output, use the `sample` namespace (ie, `{{sample.output_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 CreateEvalAsync(
@@ -231,6 +415,7 @@ partial void ProcessCreateEvalResponseContent(
global::System.Collections.Generic.IList> testingCriteria,
string? name = default,
global::System.Collections.Generic.Dictionary? metadata = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.CreateEvalRequest
@@ -243,6 +428,7 @@ partial void ProcessCreateEvalResponseContent(
return await CreateEvalAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.CreateEvalRun.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.CreateEvalRun.g.cs
index c4e224a78..57d6b94a1 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.CreateEvalRun.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.CreateEvalRun.g.cs
@@ -14,6 +14,7 @@ public partial class EvalsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -47,12 +48,14 @@ partial void ProcessCreateEvalRunResponseContent(
///
///
///
+ /// 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 CreateEvalRunAsync(
string evalId,
global::tryAGI.OpenAI.CreateEvalRunRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -70,22 +73,43 @@ partial void ProcessCreateEvalRunResponseContent(
securityRequirements: s_CreateEvalRunSecurityRequirements,
operationName: "CreateEvalRunAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/evals/{evalId}/runs",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/evals/{evalId}/runs",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -95,157 +119,316 @@ partial void ProcessCreateEvalRunResponseContent(
__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);
- PrepareCreateEvalRunRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- evalId: evalId,
- 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::tryAGI.OpenAI.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);
+ PrepareCreateEvalRunRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ evalId: evalId,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCreateEvalRunResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Bad request (for example, missing eval object)
- 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::tryAGI.OpenAI.Error? __value_400 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateEvalRun",
+ methodName: "CreateEvalRunAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_400 = global::tryAGI.OpenAI.Error.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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateEvalRun",
+ methodName: "CreateEvalRunAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_400 = global::tryAGI.OpenAI.Error.FromJson(__content_400, JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateEvalRun",
+ methodName: "CreateEvalRunAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ 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::tryAGI.OpenAI.ApiException(
- message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_400,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_400,
- ResponseObject = __value_400,
- 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);
- ProcessCreateEvalRunResponseContent(
+ response: __response);
+ ProcessCreateEvalRunResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- global::tryAGI.OpenAI.EvalRun.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateEvalRun",
+ methodName: "CreateEvalRunAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateEvalRun",
+ methodName: "CreateEvalRunAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Bad request (for example, missing eval object)
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ global::tryAGI.OpenAI.Error? __value_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_400 = global::tryAGI.OpenAI.Error.FromJson(__content_400, JsonSerializerContext);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- await global::tryAGI.OpenAI.EvalRun.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::tryAGI.OpenAI.Error.FromJson(__content_400, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+ throw new global::tryAGI.OpenAI.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 (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessCreateEvalRunResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.EvalRun.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.EvalRun.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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();
+ }
}
///
/// Kicks off a new run for a given evaluation, specifying the data source, and what model configuration to use to test. The datasource will be validated against the schema specified in the config of the evaluation.
@@ -258,6 +441,7 @@ partial void ProcessCreateEvalRunResponseContent(
///
/// Details about the run's data source.
///
+ /// 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 CreateEvalRunAsync(
@@ -265,6 +449,7 @@ partial void ProcessCreateEvalRunResponseContent(
global::tryAGI.OpenAI.OneOf dataSource,
string? name = default,
global::System.Collections.Generic.Dictionary? metadata = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.CreateEvalRunRequest
@@ -277,6 +462,7 @@ partial void ProcessCreateEvalRunResponseContent(
return await CreateEvalRunAsync(
evalId: evalId,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.DeleteAnEval.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.DeleteAnEval.g.cs
index 000e7ec48..e2d96abca 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.DeleteAnEval.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.DeleteAnEval.g.cs
@@ -14,6 +14,7 @@ public partial class EvalsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -44,10 +45,12 @@ partial void ProcessDeleteAnEvalResponseContent(
/// Delete an 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 DeleteAnEvalAsync(
string evalId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -62,22 +65,43 @@ partial void ProcessDeleteAnEvalResponseContent(
securityRequirements: s_DeleteAnEvalSecurityRequirements,
operationName: "DeleteAnEvalAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/evals/{evalId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/evals/{evalId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -87,150 +111,309 @@ partial void ProcessDeleteAnEvalResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareDeleteAnEvalRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- evalId: evalId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareDeleteAnEvalRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ evalId: evalId);
- 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);
- ProcessDeleteAnEvalResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Evaluation 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::tryAGI.OpenAI.Error? __value_404 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAnEval",
+ methodName: "DeleteAnEvalAsync",
+ pathTemplate: "$\"/evals/{evalId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_404 = global::tryAGI.OpenAI.Error.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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAnEval",
+ methodName: "DeleteAnEvalAsync",
+ pathTemplate: "$\"/evals/{evalId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_404 = global::tryAGI.OpenAI.Error.FromJson(__content_404, JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAnEval",
+ methodName: "DeleteAnEvalAsync",
+ pathTemplate: "$\"/evals/{evalId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ 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::tryAGI.OpenAI.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);
- ProcessDeleteAnEvalResponseContent(
+ response: __response);
+ ProcessDeleteAnEvalResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- global::tryAGI.OpenAI.DeleteEvalResponse.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAnEval",
+ methodName: "DeleteAnEvalAsync",
+ pathTemplate: "$\"/evals/{evalId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAnEval",
+ methodName: "DeleteAnEvalAsync",
+ pathTemplate: "$\"/evals/{evalId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 not found.
+ if ((int)__response.StatusCode == 404)
+ {
+ string? __content_404 = null;
+ global::System.Exception? __exception_404 = null;
+ global::tryAGI.OpenAI.Error? __value_404 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_404 = global::tryAGI.OpenAI.Error.FromJson(__content_404, JsonSerializerContext);
+ }
+ else
+ {
+ __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- await global::tryAGI.OpenAI.DeleteEvalResponse.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::tryAGI.OpenAI.Error.FromJson(__content_404, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_404 = __ex;
+ }
+
+ throw new global::tryAGI.OpenAI.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);
+ ProcessDeleteAnEvalResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.DeleteEvalResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.DeleteEvalResponse.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.DeleteEvalRun.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.DeleteEvalRun.g.cs
index 6602bf4fa..c77379db2 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.DeleteEvalRun.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.DeleteEvalRun.g.cs
@@ -14,6 +14,7 @@ public partial class EvalsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -47,11 +48,13 @@ partial void ProcessDeleteEvalRunResponseContent(
///
///
///
+ /// 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 DeleteEvalRunAsync(
string evalId,
string runId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -67,22 +70,43 @@ partial void ProcessDeleteEvalRunResponseContent(
securityRequirements: s_DeleteEvalRunSecurityRequirements,
operationName: "DeleteEvalRunAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/evals/{evalId}/runs/{runId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/evals/{evalId}/runs/{runId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -92,151 +116,310 @@ partial void ProcessDeleteEvalRunResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareDeleteEvalRunRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- evalId: evalId,
- runId: runId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareDeleteEvalRunRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ evalId: evalId,
+ runId: runId);
- 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);
- ProcessDeleteEvalRunResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Run 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::tryAGI.OpenAI.Error? __value_404 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteEvalRun",
+ methodName: "DeleteEvalRunAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs/{runId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_404 = global::tryAGI.OpenAI.Error.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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteEvalRun",
+ methodName: "DeleteEvalRunAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs/{runId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_404 = global::tryAGI.OpenAI.Error.FromJson(__content_404, JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteEvalRun",
+ methodName: "DeleteEvalRunAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs/{runId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ 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::tryAGI.OpenAI.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);
- ProcessDeleteEvalRunResponseContent(
+ response: __response);
+ ProcessDeleteEvalRunResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- global::tryAGI.OpenAI.DeleteEvalRunResponse.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteEvalRun",
+ methodName: "DeleteEvalRunAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs/{runId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteEvalRun",
+ methodName: "DeleteEvalRunAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs/{runId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Run not found
+ if ((int)__response.StatusCode == 404)
+ {
+ string? __content_404 = null;
+ global::System.Exception? __exception_404 = null;
+ global::tryAGI.OpenAI.Error? __value_404 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_404 = global::tryAGI.OpenAI.Error.FromJson(__content_404, JsonSerializerContext);
+ }
+ else
+ {
+ __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- await global::tryAGI.OpenAI.DeleteEvalRunResponse.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::tryAGI.OpenAI.Error.FromJson(__content_404, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_404 = __ex;
+ }
+
+ throw new global::tryAGI.OpenAI.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);
+ ProcessDeleteEvalRunResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.DeleteEvalRunResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.DeleteEvalRunResponse.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.GetAnEval.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.GetAnEval.g.cs
index 1d7f5e8ab..f7c5599d6 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.GetAnEval.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.GetAnEval.g.cs
@@ -14,6 +14,7 @@ public partial class EvalsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -44,10 +45,12 @@ partial void ProcessGetAnEvalResponseContent(
/// Get an evaluation by 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 GetAnEvalAsync(
string evalId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -62,22 +65,43 @@ partial void ProcessGetAnEvalResponseContent(
securityRequirements: s_GetAnEvalSecurityRequirements,
operationName: "GetAnEvalAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/evals/{evalId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/evals/{evalId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,112 +111,271 @@ partial void ProcessGetAnEvalResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareGetAnEvalRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- evalId: evalId);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareGetAnEvalRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ evalId: evalId);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessGetAnEvalResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAnEval",
+ methodName: "GetAnEvalAsync",
+ pathTemplate: "$\"/evals/{evalId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAnEval",
+ methodName: "GetAnEvalAsync",
+ pathTemplate: "$\"/evals/{evalId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessGetAnEvalResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAnEval",
+ methodName: "GetAnEvalAsync",
+ pathTemplate: "$\"/evals/{evalId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.Eval.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.Eval.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessGetAnEvalResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAnEval",
+ methodName: "GetAnEvalAsync",
+ pathTemplate: "$\"/evals/{evalId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAnEval",
+ methodName: "GetAnEvalAsync",
+ pathTemplate: "$\"/evals/{evalId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessGetAnEvalResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.Eval.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.Eval.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.GetAnEvalRun.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.GetAnEvalRun.g.cs
index 343bfbe62..6d0afd97d 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.GetAnEvalRun.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.GetAnEvalRun.g.cs
@@ -14,6 +14,7 @@ public partial class EvalsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -47,11 +48,13 @@ partial void ProcessGetAnEvalRunResponseContent(
///
///
///
+ /// 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 GetAnEvalRunAsync(
string evalId,
string runId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -67,22 +70,43 @@ partial void ProcessGetAnEvalRunResponseContent(
securityRequirements: s_GetAnEvalRunSecurityRequirements,
operationName: "GetAnEvalRunAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/evals/{evalId}/runs/{runId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/evals/{evalId}/runs/{runId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,113 +116,272 @@ partial void ProcessGetAnEvalRunResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareGetAnEvalRunRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- evalId: evalId,
- runId: runId);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareGetAnEvalRunRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ evalId: evalId,
+ runId: runId);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessGetAnEvalRunResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAnEvalRun",
+ methodName: "GetAnEvalRunAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs/{runId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAnEvalRun",
+ methodName: "GetAnEvalRunAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs/{runId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessGetAnEvalRunResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAnEvalRun",
+ methodName: "GetAnEvalRunAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs/{runId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.EvalRun.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.EvalRun.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessGetAnEvalRunResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAnEvalRun",
+ methodName: "GetAnEvalRunAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs/{runId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAnEvalRun",
+ methodName: "GetAnEvalRunAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs/{runId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessGetAnEvalRunResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.EvalRun.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.EvalRun.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.GetAnOutputItemOfAnEvalRun.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.GetAnOutputItemOfAnEvalRun.g.cs
index 40f3a8ee0..53746df93 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.GetAnOutputItemOfAnEvalRun.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.GetAnOutputItemOfAnEvalRun.g.cs
@@ -14,6 +14,7 @@ public partial class EvalsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -50,12 +51,14 @@ partial void ProcessGetAnOutputItemOfAnEvalRunResponseContent(
///
///
///
+ /// 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 GetAnOutputItemOfAnEvalRunAsync(
string evalId,
string runId,
string outputItemId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -72,22 +75,43 @@ partial void ProcessGetAnOutputItemOfAnEvalRunResponseContent(
securityRequirements: s_GetAnOutputItemOfAnEvalRunSecurityRequirements,
operationName: "GetAnOutputItemOfAnEvalRunAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/evals/{evalId}/runs/{runId}/output_items/{outputItemId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/evals/{evalId}/runs/{runId}/output_items/{outputItemId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,114 +121,273 @@ partial void ProcessGetAnOutputItemOfAnEvalRunResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareGetAnOutputItemOfAnEvalRunRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- evalId: evalId,
- runId: runId,
- outputItemId: outputItemId);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareGetAnOutputItemOfAnEvalRunRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ evalId: evalId,
+ runId: runId,
+ outputItemId: outputItemId);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessGetAnOutputItemOfAnEvalRunResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAnOutputItemOfAnEvalRun",
+ methodName: "GetAnOutputItemOfAnEvalRunAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs/{runId}/output_items/{outputItemId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAnOutputItemOfAnEvalRun",
+ methodName: "GetAnOutputItemOfAnEvalRunAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs/{runId}/output_items/{outputItemId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessGetAnOutputItemOfAnEvalRunResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAnOutputItemOfAnEvalRun",
+ methodName: "GetAnOutputItemOfAnEvalRunAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs/{runId}/output_items/{outputItemId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.EvalRunOutputItem.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.EvalRunOutputItem.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessGetAnOutputItemOfAnEvalRunResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAnOutputItemOfAnEvalRun",
+ methodName: "GetAnOutputItemOfAnEvalRunAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs/{runId}/output_items/{outputItemId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetAnOutputItemOfAnEvalRun",
+ methodName: "GetAnOutputItemOfAnEvalRunAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs/{runId}/output_items/{outputItemId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessGetAnOutputItemOfAnEvalRunResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.EvalRunOutputItem.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.EvalRunOutputItem.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.GetEvalRunOutputItems.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.GetEvalRunOutputItems.g.cs
index 1c8d1dcde..613ffc919 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.GetEvalRunOutputItems.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.GetEvalRunOutputItems.g.cs
@@ -14,6 +14,7 @@ public partial class EvalsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -63,6 +64,7 @@ partial void ProcessGetEvalRunOutputItemsResponseContent(
///
/// Default Value: asc
///
+ /// 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 GetEvalRunOutputItemsAsync(
@@ -72,6 +74,7 @@ partial void ProcessGetEvalRunOutputItemsResponseContent(
int? limit = default,
global::tryAGI.OpenAI.GetEvalRunOutputItemsStatus? status = default,
global::tryAGI.OpenAI.GetEvalRunOutputItemsOrder? order = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -91,28 +94,49 @@ partial void ProcessGetEvalRunOutputItemsResponseContent(
securityRequirements: s_GetEvalRunOutputItemsSecurityRequirements,
operationName: "GetEvalRunOutputItemsAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/evals/{evalId}/runs/{runId}/output_items",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("after", after)
- .AddOptionalParameter("limit", limit?.ToString())
- .AddOptionalParameter("status", status?.ToValueString())
- .AddOptionalParameter("order", order?.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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/evals/{evalId}/runs/{runId}/output_items",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("after", after)
+ .AddOptionalParameter("limit", limit?.ToString())
+ .AddOptionalParameter("status", status?.ToValueString())
+ .AddOptionalParameter("order", order?.ToValueString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,117 +146,276 @@ partial void ProcessGetEvalRunOutputItemsResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareGetEvalRunOutputItemsRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- evalId: evalId,
- runId: runId,
- after: after,
- limit: limit,
- status: status,
- order: order);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareGetEvalRunOutputItemsRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ evalId: evalId,
+ runId: runId,
+ after: after,
+ limit: limit,
+ status: status,
+ order: order);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessGetEvalRunOutputItemsResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetEvalRunOutputItems",
+ methodName: "GetEvalRunOutputItemsAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs/{runId}/output_items\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetEvalRunOutputItems",
+ methodName: "GetEvalRunOutputItemsAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs/{runId}/output_items\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessGetEvalRunOutputItemsResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetEvalRunOutputItems",
+ methodName: "GetEvalRunOutputItemsAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs/{runId}/output_items\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.EvalRunOutputItemList.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.EvalRunOutputItemList.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessGetEvalRunOutputItemsResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetEvalRunOutputItems",
+ methodName: "GetEvalRunOutputItemsAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs/{runId}/output_items\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetEvalRunOutputItems",
+ methodName: "GetEvalRunOutputItemsAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs/{runId}/output_items\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessGetEvalRunOutputItemsResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.EvalRunOutputItemList.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.EvalRunOutputItemList.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.GetEvalRuns.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.GetEvalRuns.g.cs
index 06792b7c2..6e158fb19 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.GetEvalRuns.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.GetEvalRuns.g.cs
@@ -14,6 +14,7 @@ public partial class EvalsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -60,6 +61,7 @@ partial void ProcessGetEvalRunsResponseContent(
/// Default Value: asc
///
///
+ /// 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 GetEvalRunsAsync(
@@ -68,6 +70,7 @@ partial void ProcessGetEvalRunsResponseContent(
int? limit = default,
global::tryAGI.OpenAI.GetEvalRunsOrder? order = default,
global::tryAGI.OpenAI.GetEvalRunsStatus? status = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -86,28 +89,49 @@ partial void ProcessGetEvalRunsResponseContent(
securityRequirements: s_GetEvalRunsSecurityRequirements,
operationName: "GetEvalRunsAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/evals/{evalId}/runs",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("after", after)
- .AddOptionalParameter("limit", limit?.ToString())
- .AddOptionalParameter("order", order?.ToValueString())
- .AddOptionalParameter("status", status?.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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/evals/{evalId}/runs",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("after", after)
+ .AddOptionalParameter("limit", limit?.ToString())
+ .AddOptionalParameter("order", order?.ToValueString())
+ .AddOptionalParameter("status", status?.ToValueString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -117,116 +141,275 @@ partial void ProcessGetEvalRunsResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareGetEvalRunsRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- evalId: evalId,
- after: after,
- limit: limit,
- order: order,
- status: status);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareGetEvalRunsRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ evalId: evalId,
+ after: after,
+ limit: limit,
+ order: order,
+ status: status);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessGetEvalRunsResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetEvalRuns",
+ methodName: "GetEvalRunsAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetEvalRuns",
+ methodName: "GetEvalRunsAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessGetEvalRunsResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetEvalRuns",
+ methodName: "GetEvalRunsAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.EvalRunList.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.EvalRunList.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessGetEvalRunsResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetEvalRuns",
+ methodName: "GetEvalRunsAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GetEvalRuns",
+ methodName: "GetEvalRunsAsync",
+ pathTemplate: "$\"/evals/{evalId}/runs\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessGetEvalRunsResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.EvalRunList.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.EvalRunList.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.ListEvals.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.ListEvals.g.cs
index 5d5fbc736..50e804dc0 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.ListEvals.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.ListEvals.g.cs
@@ -14,6 +14,7 @@ public partial class EvalsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -59,6 +60,7 @@ partial void ProcessListEvalsResponseContent(
///
/// Default Value: created_at
///
+ /// 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 ListEvalsAsync(
@@ -66,6 +68,7 @@ partial void ProcessListEvalsResponseContent(
int? limit = default,
global::tryAGI.OpenAI.ListEvalsOrder? order = default,
global::tryAGI.OpenAI.ListEvalsOrderBy? orderBy = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -83,28 +86,49 @@ partial void ProcessListEvalsResponseContent(
securityRequirements: s_ListEvalsSecurityRequirements,
operationName: "ListEvalsAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: "/evals",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("after", after)
- .AddOptionalParameter("limit", limit?.ToString())
- .AddOptionalParameter("order", order?.ToValueString())
- .AddOptionalParameter("order_by", orderBy?.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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: "/evals",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("after", after)
+ .AddOptionalParameter("limit", limit?.ToString())
+ .AddOptionalParameter("order", order?.ToValueString())
+ .AddOptionalParameter("order_by", orderBy?.ToValueString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -114,115 +138,274 @@ partial void ProcessListEvalsResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareListEvalsRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- after: after,
- limit: limit,
- order: order,
- orderBy: orderBy);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareListEvalsRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ after: after,
+ limit: limit,
+ order: order,
+ orderBy: orderBy);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessListEvalsResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListEvals",
+ methodName: "ListEvalsAsync",
+ pathTemplate: "\"/evals\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListEvals",
+ methodName: "ListEvalsAsync",
+ pathTemplate: "\"/evals\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessListEvalsResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListEvals",
+ methodName: "ListEvalsAsync",
+ pathTemplate: "\"/evals\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.EvalList.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.EvalList.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessListEvalsResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListEvals",
+ methodName: "ListEvalsAsync",
+ pathTemplate: "\"/evals\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListEvals",
+ methodName: "ListEvalsAsync",
+ pathTemplate: "\"/evals\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessListEvalsResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.EvalList.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.EvalList.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.UpdateAnEval.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.UpdateAnEval.g.cs
index 8bd0c1d5c..772e05ca0 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.UpdateAnEval.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.UpdateAnEval.g.cs
@@ -14,6 +14,7 @@ public partial class EvalsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -47,12 +48,14 @@ partial void ProcessUpdateAnEvalResponseContent(
///
///
///
+ /// 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 UpdateAnEvalAsync(
string evalId,
global::tryAGI.OpenAI.UpdateEvalRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -70,22 +73,43 @@ partial void ProcessUpdateAnEvalResponseContent(
securityRequirements: s_UpdateAnEvalSecurityRequirements,
operationName: "UpdateAnEvalAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/evals/{evalId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/evals/{evalId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -95,119 +119,278 @@ partial void ProcessUpdateAnEvalResponseContent(
__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);
- PrepareUpdateAnEvalRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- evalId: evalId,
- 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::tryAGI.OpenAI.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);
+ PrepareUpdateAnEvalRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ evalId: evalId,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessUpdateAnEvalResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UpdateAnEval",
+ methodName: "UpdateAnEvalAsync",
+ pathTemplate: "$\"/evals/{evalId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UpdateAnEval",
+ methodName: "UpdateAnEvalAsync",
+ pathTemplate: "$\"/evals/{evalId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessUpdateAnEvalResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UpdateAnEval",
+ methodName: "UpdateAnEvalAsync",
+ pathTemplate: "$\"/evals/{evalId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.Eval.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.Eval.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessUpdateAnEvalResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UpdateAnEval",
+ methodName: "UpdateAnEvalAsync",
+ pathTemplate: "$\"/evals/{evalId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UpdateAnEval",
+ methodName: "UpdateAnEvalAsync",
+ pathTemplate: "$\"/evals/{evalId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessUpdateAnEvalResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.Eval.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.Eval.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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 certain properties of an evaluation.
@@ -217,12 +400,14 @@ partial void ProcessUpdateAnEvalResponseContent(
/// Rename 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 UpdateAnEvalAsync(
string evalId,
string? name = default,
global::System.Collections.Generic.Dictionary? metadata = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.UpdateEvalRequest
@@ -234,6 +419,7 @@ partial void ProcessUpdateAnEvalResponseContent(
return await UpdateAnEvalAsync(
evalId: evalId,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.g.cs
index dbb44bf28..fe4cde641 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.EvalsClient.g.cs
@@ -31,6 +31,9 @@ public sealed partial class EvalsClient : global::tryAGI.OpenAI.IEvalsClient, gl
#if DEBUG
= true;
#endif
+
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
///
///
///
@@ -50,11 +53,37 @@ public EvalsClient(
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 EvalsClient.
+ /// 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 EvalsClient(
+ global::System.Net.Http.HttpClient? httpClient = null,
+ global::System.Uri? baseUri = null,
+ global::System.Collections.Generic.List? authorizations = null,
+ global::tryAGI.OpenAI.AutoSDKClientOptions? options = null,
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::tryAGI.OpenAI.AutoSDKClientOptions();
_disposeHttpClient = disposeHttpClient;
Initialized(HttpClient);
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FilesClient.DeleteFile.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FilesClient.DeleteFile.g.cs
index af8fa9245..b9f29a2c5 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FilesClient.DeleteFile.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FilesClient.DeleteFile.g.cs
@@ -14,6 +14,7 @@ public partial class FilesClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -44,10 +45,12 @@ partial void ProcessDeleteFileResponseContent(
/// Delete a file and remove it from all vector stores.
///
///
+ /// 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 DeleteFileAsync(
string fileId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -62,22 +65,43 @@ partial void ProcessDeleteFileResponseContent(
securityRequirements: s_DeleteFileSecurityRequirements,
operationName: "DeleteFileAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/files/{fileId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/files/{fileId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -87,112 +111,271 @@ partial void ProcessDeleteFileResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareDeleteFileRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- fileId: fileId);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareDeleteFileRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ fileId: fileId);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessDeleteFileResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteFile",
+ methodName: "DeleteFileAsync",
+ pathTemplate: "$\"/files/{fileId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteFile",
+ methodName: "DeleteFileAsync",
+ pathTemplate: "$\"/files/{fileId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessDeleteFileResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteFile",
+ methodName: "DeleteFileAsync",
+ pathTemplate: "$\"/files/{fileId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.DeleteFileResponse.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.DeleteFileResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessDeleteFileResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteFile",
+ methodName: "DeleteFileAsync",
+ pathTemplate: "$\"/files/{fileId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteFile",
+ methodName: "DeleteFileAsync",
+ pathTemplate: "$\"/files/{fileId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessDeleteFileResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.DeleteFileResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.DeleteFileResponse.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FilesClient.ListFiles.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FilesClient.ListFiles.g.cs
index 6e3b28fc9..d2c6b8a0f 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FilesClient.ListFiles.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FilesClient.ListFiles.g.cs
@@ -14,6 +14,7 @@ public partial class FilesClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -57,6 +58,7 @@ partial void ProcessListFilesResponseContent(
/// Default Value: desc
///
///
+ /// 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 ListFilesAsync(
@@ -64,6 +66,7 @@ partial void ProcessListFilesResponseContent(
int? limit = default,
global::tryAGI.OpenAI.ListFilesOrder? order = default,
string? after = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -81,28 +84,49 @@ partial void ProcessListFilesResponseContent(
securityRequirements: s_ListFilesSecurityRequirements,
operationName: "ListFilesAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: "/files",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("purpose", purpose)
- .AddOptionalParameter("limit", limit?.ToString())
- .AddOptionalParameter("order", order?.ToValueString())
- .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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: "/files",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("purpose", purpose)
+ .AddOptionalParameter("limit", limit?.ToString())
+ .AddOptionalParameter("order", order?.ToValueString())
+ .AddOptionalParameter("after", after)
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,115 +136,274 @@ partial void ProcessListFilesResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareListFilesRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- purpose: purpose,
- limit: limit,
- order: order,
- after: after);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareListFilesRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ purpose: purpose,
+ limit: limit,
+ order: order,
+ after: after);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessListFilesResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListFiles",
+ methodName: "ListFilesAsync",
+ pathTemplate: "\"/files\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListFiles",
+ methodName: "ListFilesAsync",
+ pathTemplate: "\"/files\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessListFilesResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListFiles",
+ methodName: "ListFilesAsync",
+ pathTemplate: "\"/files\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.ListFilesResponse.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.ListFilesResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessListFilesResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListFiles",
+ methodName: "ListFilesAsync",
+ pathTemplate: "\"/files\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListFiles",
+ methodName: "ListFilesAsync",
+ pathTemplate: "\"/files\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessListFilesResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.ListFilesResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ListFilesResponse.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FilesClient.RetrieveFile.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FilesClient.RetrieveFile.g.cs
index a4ad05c41..cc23b166c 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FilesClient.RetrieveFile.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FilesClient.RetrieveFile.g.cs
@@ -14,6 +14,7 @@ public partial class FilesClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -44,10 +45,12 @@ partial void ProcessRetrieveFileResponseContent(
/// Returns information about a specific file.
///
///
+ /// 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 RetrieveFileAsync(
string fileId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -62,22 +65,43 @@ partial void ProcessRetrieveFileResponseContent(
securityRequirements: s_RetrieveFileSecurityRequirements,
operationName: "RetrieveFileAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/files/{fileId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/files/{fileId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,112 +111,271 @@ partial void ProcessRetrieveFileResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareRetrieveFileRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- fileId: fileId);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareRetrieveFileRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ fileId: fileId);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessRetrieveFileResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveFile",
+ methodName: "RetrieveFileAsync",
+ pathTemplate: "$\"/files/{fileId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveFile",
+ methodName: "RetrieveFileAsync",
+ pathTemplate: "$\"/files/{fileId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessRetrieveFileResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveFile",
+ methodName: "RetrieveFileAsync",
+ pathTemplate: "$\"/files/{fileId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.OpenAIFile.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.OpenAIFile.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessRetrieveFileResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveFile",
+ methodName: "RetrieveFileAsync",
+ pathTemplate: "$\"/files/{fileId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveFile",
+ methodName: "RetrieveFileAsync",
+ pathTemplate: "$\"/files/{fileId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessRetrieveFileResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.OpenAIFile.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.OpenAIFile.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FilesClient.RetrieveFileContent.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FilesClient.RetrieveFileContent.g.cs
index 38f8b5bce..c1c6e5224 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FilesClient.RetrieveFileContent.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FilesClient.RetrieveFileContent.g.cs
@@ -14,6 +14,7 @@ public partial class FilesClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -44,10 +45,12 @@ partial void ProcessRetrieveFileContentResponseContent(
/// Returns the contents of the specified file.
///
///
+ /// 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 RetrieveFileContentAsync(
string fileId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -62,22 +65,43 @@ partial void ProcessRetrieveFileContentResponseContent(
securityRequirements: s_RetrieveFileContentSecurityRequirements,
operationName: "RetrieveFileContentAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/files/{fileId}/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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/files/{fileId}/content",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,108 +111,267 @@ partial void ProcessRetrieveFileContentResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareRetrieveFileContentRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- fileId: fileId);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareRetrieveFileContentRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ fileId: fileId);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessRetrieveFileContentResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveFileContent",
+ methodName: "RetrieveFileContentAsync",
+ pathTemplate: "$\"/files/{fileId}/content\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveFileContent",
+ methodName: "RetrieveFileContentAsync",
+ pathTemplate: "$\"/files/{fileId}/content\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessRetrieveFileContentResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveFileContent",
+ methodName: "RetrieveFileContentAsync",
+ pathTemplate: "$\"/files/{fileId}/content\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return __content;
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- throw new global::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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();
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- return __content;
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessRetrieveFileContentResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveFileContent",
+ methodName: "RetrieveFileContentAsync",
+ pathTemplate: "$\"/files/{fileId}/content\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveFileContent",
+ methodName: "RetrieveFileContentAsync",
+ pathTemplate: "$\"/files/{fileId}/content\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessRetrieveFileContentResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return __content;
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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 __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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FilesClient.UploadFile.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FilesClient.UploadFile.g.cs
index b39fa2da8..f9ea92b98 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FilesClient.UploadFile.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FilesClient.UploadFile.g.cs
@@ -14,6 +14,7 @@ public partial class FilesClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -58,11 +59,13 @@ partial void ProcessUploadFileResponseContent(
/// storage limits.
///
///
+ /// 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 UploadFileAsync(
global::tryAGI.OpenAI.CreateFileRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -79,22 +82,43 @@ partial void ProcessUploadFileResponseContent(
securityRequirements: s_UploadFileSecurityRequirements,
operationName: "UploadFileAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.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.Post,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: "/files",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,133 +128,292 @@ partial void ProcessUploadFileResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
- }
- using var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
- 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;
- }
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"{request.Purpose.ToValueString()}"),
- name: "\"purpose\"");
- if (request.ExpiresAfter != default)
- {
-
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"{request.ExpiresAfter}"),
- name: "\"expires_after\"");
+ }
}
- __httpRequest.Content = __httpRequestContent;
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ 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;
+ }
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"{request.Purpose.ToValueString()}"),
+ name: "\"purpose\"");
+ if (request.ExpiresAfter != default)
+ {
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareUploadFileRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- request: request);
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"{request.ExpiresAfter}"),
+ name: "\"expires_after\"");
+ }
+ __httpRequest.Content = __httpRequestContent;
+ global::tryAGI.OpenAI.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);
+ PrepareUploadFileRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessUploadFileResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UploadFile",
+ methodName: "UploadFileAsync",
+ pathTemplate: "\"/files\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UploadFile",
+ methodName: "UploadFileAsync",
+ pathTemplate: "\"/files\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessUploadFileResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UploadFile",
+ methodName: "UploadFileAsync",
+ pathTemplate: "\"/files\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.OpenAIFile.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.OpenAIFile.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessUploadFileResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UploadFile",
+ methodName: "UploadFileAsync",
+ pathTemplate: "\"/files\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UploadFile",
+ methodName: "UploadFileAsync",
+ pathTemplate: "\"/files\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessUploadFileResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.OpenAIFile.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.OpenAIFile.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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 that can be used across various endpoints. Individual files
@@ -267,6 +450,7 @@ partial void ProcessUploadFileResponseContent(
///
/// The expiration policy for a file. By default, files with `purpose=batch` expire after 30 days and all other files are persisted until they are manually deleted.
///
+ /// 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 UploadFileAsync(
@@ -274,6 +458,7 @@ partial void ProcessUploadFileResponseContent(
string filename,
global::tryAGI.OpenAI.CreateFileRequestPurpose purpose,
global::tryAGI.OpenAI.FileExpirationAfter? expiresAfter = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.CreateFileRequest
@@ -286,6 +471,7 @@ partial void ProcessUploadFileResponseContent(
return await UploadFileAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FilesClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FilesClient.g.cs
index e5d8828f7..afdd3baa9 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FilesClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FilesClient.g.cs
@@ -31,6 +31,9 @@ public sealed partial class FilesClient : global::tryAGI.OpenAI.IFilesClient, gl
#if DEBUG
= true;
#endif
+
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
///
///
///
@@ -50,11 +53,37 @@ 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.
+ /// 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 = null,
+ global::System.Uri? baseUri = null,
+ global::System.Collections.Generic.List? authorizations = null,
+ global::tryAGI.OpenAI.AutoSDKClientOptions? options = null,
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::tryAGI.OpenAI.AutoSDKClientOptions();
_disposeHttpClient = disposeHttpClient;
Initialized(HttpClient);
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.CancelFineTuning.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.CancelFineTuning.g.cs
index 808d7a823..377432d5a 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.CancelFineTuning.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.CancelFineTuning.g.cs
@@ -14,6 +14,7 @@ public partial class FineTuningClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -46,10 +47,12 @@ partial void ProcessCancelFineTuningResponseContent(
///
/// Example: ft-AF1WoRqd3aJAHsqc9NY7iL8F
///
+ /// 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 CancelFineTuningAsync(
string fineTuningJobId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -64,22 +67,43 @@ partial void ProcessCancelFineTuningResponseContent(
securityRequirements: s_CancelFineTuningSecurityRequirements,
operationName: "CancelFineTuningAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/fine_tuning/jobs/{fineTuningJobId}/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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/fine_tuning/jobs/{fineTuningJobId}/cancel",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -89,112 +113,271 @@ partial void ProcessCancelFineTuningResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareCancelFineTuningRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- fineTuningJobId: fineTuningJobId);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareCancelFineTuningRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ fineTuningJobId: fineTuningJobId);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCancelFineTuningResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CancelFineTuning",
+ methodName: "CancelFineTuningAsync",
+ pathTemplate: "$\"/fine_tuning/jobs/{fineTuningJobId}/cancel\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CancelFineTuning",
+ methodName: "CancelFineTuningAsync",
+ pathTemplate: "$\"/fine_tuning/jobs/{fineTuningJobId}/cancel\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessCancelFineTuningResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CancelFineTuning",
+ methodName: "CancelFineTuningAsync",
+ pathTemplate: "$\"/fine_tuning/jobs/{fineTuningJobId}/cancel\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.FineTuningJob.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.FineTuningJob.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessCancelFineTuningResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CancelFineTuning",
+ methodName: "CancelFineTuningAsync",
+ pathTemplate: "$\"/fine_tuning/jobs/{fineTuningJobId}/cancel\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CancelFineTuning",
+ methodName: "CancelFineTuningAsync",
+ pathTemplate: "$\"/fine_tuning/jobs/{fineTuningJobId}/cancel\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessCancelFineTuningResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.FineTuningJob.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.FineTuningJob.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.CreateCheckpointPermissions.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.CreateCheckpointPermissions.g.cs
index 515348ae6..70c8c7b50 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.CreateCheckpointPermissions.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.CreateCheckpointPermissions.g.cs
@@ -14,6 +14,7 @@ public partial class FineTuningClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -50,12 +51,14 @@ partial void ProcessCreateCheckpointPermissionsResponseContent(
/// Example: ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd
///
///
+ /// 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 CreateCheckpointPermissionsAsync(
string fineTunedModelCheckpoint,
global::tryAGI.OpenAI.CreateFineTuningCheckpointPermissionRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -73,22 +76,43 @@ partial void ProcessCreateCheckpointPermissionsResponseContent(
securityRequirements: s_CreateCheckpointPermissionsSecurityRequirements,
operationName: "CreateCheckpointPermissionsAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/fine_tuning/checkpoints/{fineTunedModelCheckpoint}/permissions",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/fine_tuning/checkpoints/{fineTunedModelCheckpoint}/permissions",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,119 +122,278 @@ partial void ProcessCreateCheckpointPermissionsResponseContent(
__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);
- PrepareCreateCheckpointPermissionsRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- fineTunedModelCheckpoint: fineTunedModelCheckpoint,
- 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::tryAGI.OpenAI.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);
+ PrepareCreateCheckpointPermissionsRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ fineTunedModelCheckpoint: fineTunedModelCheckpoint,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCreateCheckpointPermissionsResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateCheckpointPermissions",
+ methodName: "CreateCheckpointPermissionsAsync",
+ pathTemplate: "$\"/fine_tuning/checkpoints/{fineTunedModelCheckpoint}/permissions\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateCheckpointPermissions",
+ methodName: "CreateCheckpointPermissionsAsync",
+ pathTemplate: "$\"/fine_tuning/checkpoints/{fineTunedModelCheckpoint}/permissions\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessCreateCheckpointPermissionsResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateCheckpointPermissions",
+ methodName: "CreateCheckpointPermissionsAsync",
+ pathTemplate: "$\"/fine_tuning/checkpoints/{fineTunedModelCheckpoint}/permissions\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.ListFineTuningCheckpointPermissionResponse.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.ListFineTuningCheckpointPermissionResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessCreateCheckpointPermissionsResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateCheckpointPermissions",
+ methodName: "CreateCheckpointPermissionsAsync",
+ pathTemplate: "$\"/fine_tuning/checkpoints/{fineTunedModelCheckpoint}/permissions\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateCheckpointPermissions",
+ methodName: "CreateCheckpointPermissionsAsync",
+ pathTemplate: "$\"/fine_tuning/checkpoints/{fineTunedModelCheckpoint}/permissions\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessCreateCheckpointPermissionsResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.ListFineTuningCheckpointPermissionResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ListFineTuningCheckpointPermissionResponse.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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();
+ }
}
///
/// **NOTE:** Calling this endpoint requires an [admin API key](../admin-api-keys).
@@ -222,11 +405,13 @@ partial void ProcessCreateCheckpointPermissionsResponseContent(
///
/// The project identifiers to grant access 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 CreateCheckpointPermissionsAsync(
string fineTunedModelCheckpoint,
global::System.Collections.Generic.IList projectIds,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.CreateFineTuningCheckpointPermissionRequest
@@ -237,6 +422,7 @@ partial void ProcessCreateCheckpointPermissionsResponseContent(
return await CreateCheckpointPermissionsAsync(
fineTunedModelCheckpoint: fineTunedModelCheckpoint,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.CreateFineTuningJob.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.CreateFineTuningJob.g.cs
index 2e2ec00ec..4831a9052 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.CreateFineTuningJob.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.CreateFineTuningJob.g.cs
@@ -16,6 +16,7 @@ public partial class FineTuningClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -48,11 +49,13 @@ partial void ProcessCreateFineTuningJobResponseContent(
/// [Learn more about fine-tuning](/docs/guides/model-optimization)
///
///
+ /// 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 CreateFineTuningJobAsync(
global::tryAGI.OpenAI.CreateFineTuningJobRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -69,22 +72,43 @@ partial void ProcessCreateFineTuningJobResponseContent(
securityRequirements: s_CreateFineTuningJobSecurityRequirements,
operationName: "CreateFineTuningJobAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: "/fine_tuning/jobs",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: "/fine_tuning/jobs",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,118 +118,277 @@ partial void ProcessCreateFineTuningJobResponseContent(
__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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareCreateFineTuningJobRequest(
- 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);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareCreateFineTuningJobRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCreateFineTuningJobResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateFineTuningJob",
+ methodName: "CreateFineTuningJobAsync",
+ pathTemplate: "\"/fine_tuning/jobs\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateFineTuningJob",
+ methodName: "CreateFineTuningJobAsync",
+ pathTemplate: "\"/fine_tuning/jobs\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessCreateFineTuningJobResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateFineTuningJob",
+ methodName: "CreateFineTuningJobAsync",
+ pathTemplate: "\"/fine_tuning/jobs\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.FineTuningJob.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.FineTuningJob.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessCreateFineTuningJobResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateFineTuningJob",
+ methodName: "CreateFineTuningJobAsync",
+ pathTemplate: "\"/fine_tuning/jobs\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateFineTuningJob",
+ methodName: "CreateFineTuningJobAsync",
+ pathTemplate: "\"/fine_tuning/jobs\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessCreateFineTuningJobResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.FineTuningJob.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.FineTuningJob.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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();
+ }
}
///
/// Creates a fine-tuning job which begins the process of creating a new model from a given dataset.
@@ -252,6 +435,7 @@ partial void ProcessCreateFineTuningJobResponseContent(
/// The method used for fine-tuning.
///
///
+ /// 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 CreateFineTuningJobAsync(
@@ -263,6 +447,7 @@ partial void ProcessCreateFineTuningJobResponseContent(
int? seed = default,
global::tryAGI.OpenAI.FineTuneMethod? method = default,
global::System.Collections.Generic.Dictionary? metadata = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.CreateFineTuningJobRequest
@@ -279,6 +464,7 @@ partial void ProcessCreateFineTuningJobResponseContent(
return await CreateFineTuningJobAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.DeleteCheckpointPermission.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.DeleteCheckpointPermission.g.cs
index 87d3db8d0..f01614275 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.DeleteCheckpointPermission.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.DeleteCheckpointPermission.g.cs
@@ -14,6 +14,7 @@ public partial class FineTuningClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -52,11 +53,13 @@ partial void ProcessDeleteCheckpointPermissionResponseContent(
///
/// Example: cp_zc4Q7MP6XxulcVzj4MZdwsAB
///
+ /// 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 DeleteCheckpointPermissionAsync(
string fineTunedModelCheckpoint,
string permissionId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -72,22 +75,43 @@ partial void ProcessDeleteCheckpointPermissionResponseContent(
securityRequirements: s_DeleteCheckpointPermissionSecurityRequirements,
operationName: "DeleteCheckpointPermissionAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/fine_tuning/checkpoints/{fineTunedModelCheckpoint}/permissions/{permissionId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/fine_tuning/checkpoints/{fineTunedModelCheckpoint}/permissions/{permissionId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -97,113 +121,272 @@ partial void ProcessDeleteCheckpointPermissionResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareDeleteCheckpointPermissionRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- fineTunedModelCheckpoint: fineTunedModelCheckpoint,
- permissionId: permissionId);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareDeleteCheckpointPermissionRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ fineTunedModelCheckpoint: fineTunedModelCheckpoint,
+ permissionId: permissionId);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessDeleteCheckpointPermissionResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteCheckpointPermission",
+ methodName: "DeleteCheckpointPermissionAsync",
+ pathTemplate: "$\"/fine_tuning/checkpoints/{fineTunedModelCheckpoint}/permissions/{permissionId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteCheckpointPermission",
+ methodName: "DeleteCheckpointPermissionAsync",
+ pathTemplate: "$\"/fine_tuning/checkpoints/{fineTunedModelCheckpoint}/permissions/{permissionId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessDeleteCheckpointPermissionResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteCheckpointPermission",
+ methodName: "DeleteCheckpointPermissionAsync",
+ pathTemplate: "$\"/fine_tuning/checkpoints/{fineTunedModelCheckpoint}/permissions/{permissionId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.DeleteFineTuningCheckpointPermissionResponse.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.DeleteFineTuningCheckpointPermissionResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessDeleteCheckpointPermissionResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteCheckpointPermission",
+ methodName: "DeleteCheckpointPermissionAsync",
+ pathTemplate: "$\"/fine_tuning/checkpoints/{fineTunedModelCheckpoint}/permissions/{permissionId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteCheckpointPermission",
+ methodName: "DeleteCheckpointPermissionAsync",
+ pathTemplate: "$\"/fine_tuning/checkpoints/{fineTunedModelCheckpoint}/permissions/{permissionId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessDeleteCheckpointPermissionResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.DeleteFineTuningCheckpointPermissionResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.DeleteFineTuningCheckpointPermissionResponse.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.ListCheckpointPermissions.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.ListCheckpointPermissions.g.cs
index 001b1cafc..982d33f0d 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.ListCheckpointPermissions.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.ListCheckpointPermissions.g.cs
@@ -14,6 +14,7 @@ public partial class FineTuningClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -63,6 +64,7 @@ partial void ProcessListCheckpointPermissionsResponseContent(
///
/// Default Value: descending
///
+ /// 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 ListCheckpointPermissionsAsync(
@@ -71,6 +73,7 @@ partial void ProcessListCheckpointPermissionsResponseContent(
string? after = default,
int? limit = default,
global::tryAGI.OpenAI.ListFineTuningCheckpointPermissionsOrder? order = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -89,28 +92,49 @@ partial void ProcessListCheckpointPermissionsResponseContent(
securityRequirements: s_ListCheckpointPermissionsSecurityRequirements,
operationName: "ListCheckpointPermissionsAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/fine_tuning/checkpoints/{fineTunedModelCheckpoint}/permissions",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("project_id", projectId)
- .AddOptionalParameter("after", after)
- .AddOptionalParameter("limit", limit?.ToString())
- .AddOptionalParameter("order", order?.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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/fine_tuning/checkpoints/{fineTunedModelCheckpoint}/permissions",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("project_id", projectId)
+ .AddOptionalParameter("after", after)
+ .AddOptionalParameter("limit", limit?.ToString())
+ .AddOptionalParameter("order", order?.ToValueString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,116 +144,275 @@ partial void ProcessListCheckpointPermissionsResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareListCheckpointPermissionsRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- fineTunedModelCheckpoint: fineTunedModelCheckpoint,
- projectId: projectId,
- after: after,
- limit: limit,
- order: order);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareListCheckpointPermissionsRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ fineTunedModelCheckpoint: fineTunedModelCheckpoint,
+ projectId: projectId,
+ after: after,
+ limit: limit,
+ order: order);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessListCheckpointPermissionsResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListCheckpointPermissions",
+ methodName: "ListCheckpointPermissionsAsync",
+ pathTemplate: "$\"/fine_tuning/checkpoints/{fineTunedModelCheckpoint}/permissions\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListCheckpointPermissions",
+ methodName: "ListCheckpointPermissionsAsync",
+ pathTemplate: "$\"/fine_tuning/checkpoints/{fineTunedModelCheckpoint}/permissions\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessListCheckpointPermissionsResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListCheckpointPermissions",
+ methodName: "ListCheckpointPermissionsAsync",
+ pathTemplate: "$\"/fine_tuning/checkpoints/{fineTunedModelCheckpoint}/permissions\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.ListFineTuningCheckpointPermissionResponse.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.ListFineTuningCheckpointPermissionResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessListCheckpointPermissionsResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListCheckpointPermissions",
+ methodName: "ListCheckpointPermissionsAsync",
+ pathTemplate: "$\"/fine_tuning/checkpoints/{fineTunedModelCheckpoint}/permissions\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListCheckpointPermissions",
+ methodName: "ListCheckpointPermissionsAsync",
+ pathTemplate: "$\"/fine_tuning/checkpoints/{fineTunedModelCheckpoint}/permissions\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessListCheckpointPermissionsResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.ListFineTuningCheckpointPermissionResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ListFineTuningCheckpointPermissionResponse.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.ListFineTuningCheckpoints.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.ListFineTuningCheckpoints.g.cs
index a2020483b..cac796cc1 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.ListFineTuningCheckpoints.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.ListFineTuningCheckpoints.g.cs
@@ -14,6 +14,7 @@ public partial class FineTuningClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -54,12 +55,14 @@ partial void ProcessListFineTuningCheckpointsResponseContent(
///
/// Default Value: 10
///
+ /// 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 ListFineTuningCheckpointsAsync(
string fineTuningJobId,
string? after = default,
int? limit = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -76,26 +79,47 @@ partial void ProcessListFineTuningCheckpointsResponseContent(
securityRequirements: s_ListFineTuningCheckpointsSecurityRequirements,
operationName: "ListFineTuningCheckpointsAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/fine_tuning/jobs/{fineTuningJobId}/checkpoints",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("after", after)
- .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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/fine_tuning/jobs/{fineTuningJobId}/checkpoints",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("after", after)
+ .AddOptionalParameter("limit", limit?.ToString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -105,114 +129,273 @@ partial void ProcessListFineTuningCheckpointsResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareListFineTuningCheckpointsRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- fineTuningJobId: fineTuningJobId,
- after: after,
- limit: limit);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareListFineTuningCheckpointsRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ fineTuningJobId: fineTuningJobId,
+ after: after,
+ limit: limit);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessListFineTuningCheckpointsResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListFineTuningCheckpoints",
+ methodName: "ListFineTuningCheckpointsAsync",
+ pathTemplate: "$\"/fine_tuning/jobs/{fineTuningJobId}/checkpoints\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListFineTuningCheckpoints",
+ methodName: "ListFineTuningCheckpointsAsync",
+ pathTemplate: "$\"/fine_tuning/jobs/{fineTuningJobId}/checkpoints\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessListFineTuningCheckpointsResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListFineTuningCheckpoints",
+ methodName: "ListFineTuningCheckpointsAsync",
+ pathTemplate: "$\"/fine_tuning/jobs/{fineTuningJobId}/checkpoints\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.ListFineTuningJobCheckpointsResponse.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.ListFineTuningJobCheckpointsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessListFineTuningCheckpointsResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListFineTuningCheckpoints",
+ methodName: "ListFineTuningCheckpointsAsync",
+ pathTemplate: "$\"/fine_tuning/jobs/{fineTuningJobId}/checkpoints\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListFineTuningCheckpoints",
+ methodName: "ListFineTuningCheckpointsAsync",
+ pathTemplate: "$\"/fine_tuning/jobs/{fineTuningJobId}/checkpoints\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessListFineTuningCheckpointsResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.ListFineTuningJobCheckpointsResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ListFineTuningJobCheckpointsResponse.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.ListFineTuningEvents.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.ListFineTuningEvents.g.cs
index 86c3410e7..530ed7a8e 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.ListFineTuningEvents.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.ListFineTuningEvents.g.cs
@@ -14,6 +14,7 @@ public partial class FineTuningClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -54,12 +55,14 @@ partial void ProcessListFineTuningEventsResponseContent(
///
/// Default Value: 20
///
+ /// 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 ListFineTuningEventsAsync(
string fineTuningJobId,
string? after = default,
int? limit = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -76,26 +79,47 @@ partial void ProcessListFineTuningEventsResponseContent(
securityRequirements: s_ListFineTuningEventsSecurityRequirements,
operationName: "ListFineTuningEventsAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/fine_tuning/jobs/{fineTuningJobId}/events",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("after", after)
- .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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/fine_tuning/jobs/{fineTuningJobId}/events",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("after", after)
+ .AddOptionalParameter("limit", limit?.ToString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -105,114 +129,273 @@ partial void ProcessListFineTuningEventsResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareListFineTuningEventsRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- fineTuningJobId: fineTuningJobId,
- after: after,
- limit: limit);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareListFineTuningEventsRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ fineTuningJobId: fineTuningJobId,
+ after: after,
+ limit: limit);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessListFineTuningEventsResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListFineTuningEvents",
+ methodName: "ListFineTuningEventsAsync",
+ pathTemplate: "$\"/fine_tuning/jobs/{fineTuningJobId}/events\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListFineTuningEvents",
+ methodName: "ListFineTuningEventsAsync",
+ pathTemplate: "$\"/fine_tuning/jobs/{fineTuningJobId}/events\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessListFineTuningEventsResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListFineTuningEvents",
+ methodName: "ListFineTuningEventsAsync",
+ pathTemplate: "$\"/fine_tuning/jobs/{fineTuningJobId}/events\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.ListFineTuningJobEventsResponse.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.ListFineTuningJobEventsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessListFineTuningEventsResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListFineTuningEvents",
+ methodName: "ListFineTuningEventsAsync",
+ pathTemplate: "$\"/fine_tuning/jobs/{fineTuningJobId}/events\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListFineTuningEvents",
+ methodName: "ListFineTuningEventsAsync",
+ pathTemplate: "$\"/fine_tuning/jobs/{fineTuningJobId}/events\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessListFineTuningEventsResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.ListFineTuningJobEventsResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ListFineTuningJobEventsResponse.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.ListFineTuningJobs.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.ListFineTuningJobs.g.cs
index 9284a0ad8..8586254e7 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.ListFineTuningJobs.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.ListFineTuningJobs.g.cs
@@ -14,6 +14,7 @@ public partial class FineTuningClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -52,12 +53,14 @@ partial void ProcessListFineTuningJobsResponseContent(
/// Default Value: 20
///
///
+ /// 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 ListFineTuningJobsAsync(
string? after = default,
int? limit = default,
global::System.Collections.Generic.Dictionary? metadata = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -74,27 +77,48 @@ partial void ProcessListFineTuningJobsResponseContent(
securityRequirements: s_ListFineTuningJobsSecurityRequirements,
operationName: "ListFineTuningJobsAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: "/fine_tuning/jobs",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("after", after)
- .AddOptionalParameter("limit", limit?.ToString())
- .AddOptionalParameter("metadata", metadata?.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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: "/fine_tuning/jobs",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("after", after)
+ .AddOptionalParameter("limit", limit?.ToString())
+ .AddOptionalParameter("metadata", metadata?.ToString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,114 +128,273 @@ partial void ProcessListFineTuningJobsResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareListFineTuningJobsRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- after: after,
- limit: limit,
- metadata: metadata);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareListFineTuningJobsRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ after: after,
+ limit: limit,
+ metadata: metadata);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessListFineTuningJobsResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListFineTuningJobs",
+ methodName: "ListFineTuningJobsAsync",
+ pathTemplate: "\"/fine_tuning/jobs\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListFineTuningJobs",
+ methodName: "ListFineTuningJobsAsync",
+ pathTemplate: "\"/fine_tuning/jobs\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessListFineTuningJobsResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListFineTuningJobs",
+ methodName: "ListFineTuningJobsAsync",
+ pathTemplate: "\"/fine_tuning/jobs\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.ListPaginatedFineTuningJobsResponse.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.ListPaginatedFineTuningJobsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessListFineTuningJobsResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListFineTuningJobs",
+ methodName: "ListFineTuningJobsAsync",
+ pathTemplate: "\"/fine_tuning/jobs\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListFineTuningJobs",
+ methodName: "ListFineTuningJobsAsync",
+ pathTemplate: "\"/fine_tuning/jobs\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessListFineTuningJobsResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.ListPaginatedFineTuningJobsResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ListPaginatedFineTuningJobsResponse.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.PauseFineTuning.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.PauseFineTuning.g.cs
index d75d526ed..561ab16ed 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.PauseFineTuning.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.PauseFineTuning.g.cs
@@ -14,6 +14,7 @@ public partial class FineTuningClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -46,10 +47,12 @@ partial void ProcessPauseFineTuningResponseContent(
///
/// Example: ft-AF1WoRqd3aJAHsqc9NY7iL8F
///
+ /// 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 PauseFineTuningAsync(
string fineTuningJobId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -64,22 +67,43 @@ partial void ProcessPauseFineTuningResponseContent(
securityRequirements: s_PauseFineTuningSecurityRequirements,
operationName: "PauseFineTuningAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/fine_tuning/jobs/{fineTuningJobId}/pause",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/fine_tuning/jobs/{fineTuningJobId}/pause",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -89,112 +113,271 @@ partial void ProcessPauseFineTuningResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PreparePauseFineTuningRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- fineTuningJobId: fineTuningJobId);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePauseFineTuningRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ fineTuningJobId: fineTuningJobId);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessPauseFineTuningResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PauseFineTuning",
+ methodName: "PauseFineTuningAsync",
+ pathTemplate: "$\"/fine_tuning/jobs/{fineTuningJobId}/pause\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PauseFineTuning",
+ methodName: "PauseFineTuningAsync",
+ pathTemplate: "$\"/fine_tuning/jobs/{fineTuningJobId}/pause\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessPauseFineTuningResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PauseFineTuning",
+ methodName: "PauseFineTuningAsync",
+ pathTemplate: "$\"/fine_tuning/jobs/{fineTuningJobId}/pause\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.FineTuningJob.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.FineTuningJob.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessPauseFineTuningResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PauseFineTuning",
+ methodName: "PauseFineTuningAsync",
+ pathTemplate: "$\"/fine_tuning/jobs/{fineTuningJobId}/pause\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PauseFineTuning",
+ methodName: "PauseFineTuningAsync",
+ pathTemplate: "$\"/fine_tuning/jobs/{fineTuningJobId}/pause\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessPauseFineTuningResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.FineTuningJob.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.FineTuningJob.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.ResumeFineTuning.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.ResumeFineTuning.g.cs
index 148962650..cb8a6d2ac 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.ResumeFineTuning.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.ResumeFineTuning.g.cs
@@ -14,6 +14,7 @@ public partial class FineTuningClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -46,10 +47,12 @@ partial void ProcessResumeFineTuningResponseContent(
///
/// Example: ft-AF1WoRqd3aJAHsqc9NY7iL8F
///
+ /// 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 ResumeFineTuningAsync(
string fineTuningJobId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -64,22 +67,43 @@ partial void ProcessResumeFineTuningResponseContent(
securityRequirements: s_ResumeFineTuningSecurityRequirements,
operationName: "ResumeFineTuningAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/fine_tuning/jobs/{fineTuningJobId}/resume",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/fine_tuning/jobs/{fineTuningJobId}/resume",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -89,112 +113,271 @@ partial void ProcessResumeFineTuningResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareResumeFineTuningRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- fineTuningJobId: fineTuningJobId);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareResumeFineTuningRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ fineTuningJobId: fineTuningJobId);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessResumeFineTuningResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ResumeFineTuning",
+ methodName: "ResumeFineTuningAsync",
+ pathTemplate: "$\"/fine_tuning/jobs/{fineTuningJobId}/resume\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ResumeFineTuning",
+ methodName: "ResumeFineTuningAsync",
+ pathTemplate: "$\"/fine_tuning/jobs/{fineTuningJobId}/resume\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessResumeFineTuningResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ResumeFineTuning",
+ methodName: "ResumeFineTuningAsync",
+ pathTemplate: "$\"/fine_tuning/jobs/{fineTuningJobId}/resume\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.FineTuningJob.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.FineTuningJob.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessResumeFineTuningResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ResumeFineTuning",
+ methodName: "ResumeFineTuningAsync",
+ pathTemplate: "$\"/fine_tuning/jobs/{fineTuningJobId}/resume\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ResumeFineTuning",
+ methodName: "ResumeFineTuningAsync",
+ pathTemplate: "$\"/fine_tuning/jobs/{fineTuningJobId}/resume\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessResumeFineTuningResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.FineTuningJob.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.FineTuningJob.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.RetrieveFineTuningJob.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.RetrieveFineTuningJob.g.cs
index ca2083706..315cc9306 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.RetrieveFineTuningJob.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.RetrieveFineTuningJob.g.cs
@@ -14,6 +14,7 @@ public partial class FineTuningClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -47,10 +48,12 @@ partial void ProcessRetrieveFineTuningJobResponseContent(
///
/// Example: ft-AF1WoRqd3aJAHsqc9NY7iL8F
///
+ /// 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 RetrieveFineTuningJobAsync(
string fineTuningJobId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -65,22 +68,43 @@ partial void ProcessRetrieveFineTuningJobResponseContent(
securityRequirements: s_RetrieveFineTuningJobSecurityRequirements,
operationName: "RetrieveFineTuningJobAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/fine_tuning/jobs/{fineTuningJobId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/fine_tuning/jobs/{fineTuningJobId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,112 +114,271 @@ partial void ProcessRetrieveFineTuningJobResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareRetrieveFineTuningJobRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- fineTuningJobId: fineTuningJobId);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareRetrieveFineTuningJobRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ fineTuningJobId: fineTuningJobId);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessRetrieveFineTuningJobResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveFineTuningJob",
+ methodName: "RetrieveFineTuningJobAsync",
+ pathTemplate: "$\"/fine_tuning/jobs/{fineTuningJobId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveFineTuningJob",
+ methodName: "RetrieveFineTuningJobAsync",
+ pathTemplate: "$\"/fine_tuning/jobs/{fineTuningJobId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessRetrieveFineTuningJobResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveFineTuningJob",
+ methodName: "RetrieveFineTuningJobAsync",
+ pathTemplate: "$\"/fine_tuning/jobs/{fineTuningJobId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.FineTuningJob.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.FineTuningJob.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessRetrieveFineTuningJobResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveFineTuningJob",
+ methodName: "RetrieveFineTuningJobAsync",
+ pathTemplate: "$\"/fine_tuning/jobs/{fineTuningJobId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveFineTuningJob",
+ methodName: "RetrieveFineTuningJobAsync",
+ pathTemplate: "$\"/fine_tuning/jobs/{fineTuningJobId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessRetrieveFineTuningJobResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.FineTuningJob.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.FineTuningJob.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.RunGrader.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.RunGrader.g.cs
index 04379f8a0..cfcd67709 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.RunGrader.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.RunGrader.g.cs
@@ -14,6 +14,7 @@ public partial class FineTuningClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -44,11 +45,13 @@ partial void ProcessRunGraderResponseContent(
/// Run a grader.
///
///
+ /// 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 RunGraderAsync(
global::tryAGI.OpenAI.RunGraderRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -65,22 +68,43 @@ partial void ProcessRunGraderResponseContent(
securityRequirements: s_RunGraderSecurityRequirements,
operationName: "RunGraderAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: "/fine_tuning/alpha/graders/run",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: "/fine_tuning/alpha/graders/run",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,118 +114,277 @@ partial void ProcessRunGraderResponseContent(
__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);
- PrepareRunGraderRequest(
- 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::tryAGI.OpenAI.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);
+ PrepareRunGraderRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessRunGraderResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RunGrader",
+ methodName: "RunGraderAsync",
+ pathTemplate: "\"/fine_tuning/alpha/graders/run\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RunGrader",
+ methodName: "RunGraderAsync",
+ pathTemplate: "\"/fine_tuning/alpha/graders/run\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessRunGraderResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RunGrader",
+ methodName: "RunGraderAsync",
+ pathTemplate: "\"/fine_tuning/alpha/graders/run\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.RunGraderResponse.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.RunGraderResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessRunGraderResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RunGrader",
+ methodName: "RunGraderAsync",
+ pathTemplate: "\"/fine_tuning/alpha/graders/run\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RunGrader",
+ methodName: "RunGraderAsync",
+ pathTemplate: "\"/fine_tuning/alpha/graders/run\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessRunGraderResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.RunGraderResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.RunGraderResponse.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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();
+ }
}
///
/// Run a grader.
@@ -220,12 +403,14 @@ partial void ProcessRunGraderResponseContent(
/// valid JSON string.
///
///
+ /// 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 RunGraderAsync(
global::tryAGI.OpenAI.OneOf grader,
string modelSample,
object? item = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.RunGraderRequest
@@ -237,6 +422,7 @@ partial void ProcessRunGraderResponseContent(
return await RunGraderAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.ValidateGrader.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.ValidateGrader.g.cs
index ee5a3c131..63f9d2194 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.ValidateGrader.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.ValidateGrader.g.cs
@@ -14,6 +14,7 @@ public partial class FineTuningClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -44,11 +45,13 @@ partial void ProcessValidateGraderResponseContent(
/// Validate a grader.
///
///
+ /// 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 ValidateGraderAsync(
global::tryAGI.OpenAI.ValidateGraderRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -65,22 +68,43 @@ partial void ProcessValidateGraderResponseContent(
securityRequirements: s_ValidateGraderSecurityRequirements,
operationName: "ValidateGraderAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: "/fine_tuning/alpha/graders/validate",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: "/fine_tuning/alpha/graders/validate",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,118 +114,277 @@ partial void ProcessValidateGraderResponseContent(
__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);
- PrepareValidateGraderRequest(
- 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::tryAGI.OpenAI.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);
+ PrepareValidateGraderRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessValidateGraderResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ValidateGrader",
+ methodName: "ValidateGraderAsync",
+ pathTemplate: "\"/fine_tuning/alpha/graders/validate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ValidateGrader",
+ methodName: "ValidateGraderAsync",
+ pathTemplate: "\"/fine_tuning/alpha/graders/validate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessValidateGraderResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ValidateGrader",
+ methodName: "ValidateGraderAsync",
+ pathTemplate: "\"/fine_tuning/alpha/graders/validate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.ValidateGraderResponse.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.ValidateGraderResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessValidateGraderResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ValidateGrader",
+ methodName: "ValidateGraderAsync",
+ pathTemplate: "\"/fine_tuning/alpha/graders/validate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ValidateGrader",
+ methodName: "ValidateGraderAsync",
+ pathTemplate: "\"/fine_tuning/alpha/graders/validate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessValidateGraderResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.ValidateGraderResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ValidateGraderResponse.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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();
+ }
}
///
/// Validate a grader.
@@ -209,10 +392,12 @@ partial void ProcessValidateGraderResponseContent(
///
/// The grader used for the 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 ValidateGraderAsync(
global::tryAGI.OpenAI.OneOf grader,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.ValidateGraderRequest
@@ -222,6 +407,7 @@ partial void ProcessValidateGraderResponseContent(
return await ValidateGraderAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.g.cs
index 30b27ddd3..2a6b81138 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.FineTuningClient.g.cs
@@ -31,6 +31,9 @@ public sealed partial class FineTuningClient : global::tryAGI.OpenAI.IFineTuning
#if DEBUG
= true;
#endif
+
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
///
///
///
@@ -50,11 +53,37 @@ 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.
+ /// 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 = null,
+ global::System.Uri? baseUri = null,
+ global::System.Collections.Generic.List? authorizations = null,
+ global::tryAGI.OpenAI.AutoSDKClientOptions? options = null,
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::tryAGI.OpenAI.AutoSDKClientOptions();
_disposeHttpClient = disposeHttpClient;
Initialized(HttpClient);
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupOrganizationRoleAssignmentsClient.AssignOrganizationRoleToGroup.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupOrganizationRoleAssignmentsClient.AssignOrganizationRoleToGroup.g.cs
index 896870bb4..288cb5f00 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupOrganizationRoleAssignmentsClient.AssignOrganizationRoleToGroup.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupOrganizationRoleAssignmentsClient.AssignOrganizationRoleToGroup.g.cs
@@ -14,6 +14,7 @@ public partial class GroupOrganizationRoleAssignmentsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -47,12 +48,14 @@ partial void ProcessAssignOrganizationRoleToGroupResponseContent(
///
///
///
+ /// 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 AssignOrganizationRoleToGroupAsync(
string groupId,
global::tryAGI.OpenAI.PublicAssignOrganizationGroupRoleBody request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -70,22 +73,43 @@ partial void ProcessAssignOrganizationRoleToGroupResponseContent(
securityRequirements: s_AssignOrganizationRoleToGroupSecurityRequirements,
operationName: "AssignOrganizationRoleToGroupAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/organization/groups/{groupId}/roles",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/organization/groups/{groupId}/roles",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -95,119 +119,278 @@ partial void ProcessAssignOrganizationRoleToGroupResponseContent(
__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);
- PrepareAssignOrganizationRoleToGroupRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- groupId: groupId,
- 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::tryAGI.OpenAI.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);
+ PrepareAssignOrganizationRoleToGroupRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ groupId: groupId,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessAssignOrganizationRoleToGroupResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AssignOrganizationRoleToGroup",
+ methodName: "AssignOrganizationRoleToGroupAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}/roles\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AssignOrganizationRoleToGroup",
+ methodName: "AssignOrganizationRoleToGroupAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}/roles\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessAssignOrganizationRoleToGroupResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AssignOrganizationRoleToGroup",
+ methodName: "AssignOrganizationRoleToGroupAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}/roles\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.GroupRoleAssignment.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.GroupRoleAssignment.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessAssignOrganizationRoleToGroupResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AssignOrganizationRoleToGroup",
+ methodName: "AssignOrganizationRoleToGroupAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}/roles\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AssignOrganizationRoleToGroup",
+ methodName: "AssignOrganizationRoleToGroupAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}/roles\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessAssignOrganizationRoleToGroupResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.GroupRoleAssignment.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.GroupRoleAssignment.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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();
+ }
}
///
/// Assigns an organization role to a group within the organization.
@@ -216,11 +399,13 @@ partial void ProcessAssignOrganizationRoleToGroupResponseContent(
///
/// Identifier of the role to assign.
///
+ /// 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 AssignOrganizationRoleToGroupAsync(
string groupId,
string roleId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.PublicAssignOrganizationGroupRoleBody
@@ -231,6 +416,7 @@ partial void ProcessAssignOrganizationRoleToGroupResponseContent(
return await AssignOrganizationRoleToGroupAsync(
groupId: groupId,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupOrganizationRoleAssignmentsClient.ListGroupOrganizationRoleAssignments.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupOrganizationRoleAssignmentsClient.ListGroupOrganizationRoleAssignments.g.cs
index fe0ae0005..d6f20b5b1 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupOrganizationRoleAssignmentsClient.ListGroupOrganizationRoleAssignments.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupOrganizationRoleAssignmentsClient.ListGroupOrganizationRoleAssignments.g.cs
@@ -14,6 +14,7 @@ public partial class GroupOrganizationRoleAssignmentsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -53,6 +54,7 @@ partial void ProcessListGroupOrganizationRoleAssignmentsResponseContent(
///
///
///
+ /// 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 ListGroupOrganizationRoleAssignmentsAsync(
@@ -60,6 +62,7 @@ partial void ProcessListGroupOrganizationRoleAssignmentsResponseContent(
int? limit = default,
string? after = default,
global::tryAGI.OpenAI.ListGroupRoleAssignmentsOrder? order = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -77,27 +80,48 @@ partial void ProcessListGroupOrganizationRoleAssignmentsResponseContent(
securityRequirements: s_ListGroupOrganizationRoleAssignmentsSecurityRequirements,
operationName: "ListGroupOrganizationRoleAssignmentsAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/organization/groups/{groupId}/roles",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("limit", limit?.ToString())
- .AddOptionalParameter("after", after)
- .AddOptionalParameter("order", order?.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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/organization/groups/{groupId}/roles",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("limit", limit?.ToString())
+ .AddOptionalParameter("after", after)
+ .AddOptionalParameter("order", order?.ToValueString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,115 +131,274 @@ partial void ProcessListGroupOrganizationRoleAssignmentsResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareListGroupOrganizationRoleAssignmentsRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- groupId: groupId,
- limit: limit,
- after: after,
- order: order);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareListGroupOrganizationRoleAssignmentsRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ groupId: groupId,
+ limit: limit,
+ after: after,
+ order: order);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessListGroupOrganizationRoleAssignmentsResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListGroupOrganizationRoleAssignments",
+ methodName: "ListGroupOrganizationRoleAssignmentsAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}/roles\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListGroupOrganizationRoleAssignments",
+ methodName: "ListGroupOrganizationRoleAssignmentsAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}/roles\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessListGroupOrganizationRoleAssignmentsResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListGroupOrganizationRoleAssignments",
+ methodName: "ListGroupOrganizationRoleAssignmentsAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}/roles\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.RoleListResource.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.RoleListResource.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessListGroupOrganizationRoleAssignmentsResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListGroupOrganizationRoleAssignments",
+ methodName: "ListGroupOrganizationRoleAssignmentsAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}/roles\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListGroupOrganizationRoleAssignments",
+ methodName: "ListGroupOrganizationRoleAssignmentsAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}/roles\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessListGroupOrganizationRoleAssignmentsResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.RoleListResource.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.RoleListResource.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupOrganizationRoleAssignmentsClient.UnassignOrganizationRoleFromGroup.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupOrganizationRoleAssignmentsClient.UnassignOrganizationRoleFromGroup.g.cs
index 1e9a8a4b5..38b1e8a13 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupOrganizationRoleAssignmentsClient.UnassignOrganizationRoleFromGroup.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupOrganizationRoleAssignmentsClient.UnassignOrganizationRoleFromGroup.g.cs
@@ -14,6 +14,7 @@ public partial class GroupOrganizationRoleAssignmentsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -47,11 +48,13 @@ partial void ProcessUnassignOrganizationRoleFromGroupResponseContent(
///
///
///
+ /// 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 UnassignOrganizationRoleFromGroupAsync(
string groupId,
string roleId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -67,22 +70,43 @@ partial void ProcessUnassignOrganizationRoleFromGroupResponseContent(
securityRequirements: s_UnassignOrganizationRoleFromGroupSecurityRequirements,
operationName: "UnassignOrganizationRoleFromGroupAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/organization/groups/{groupId}/roles/{roleId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/organization/groups/{groupId}/roles/{roleId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -92,113 +116,272 @@ partial void ProcessUnassignOrganizationRoleFromGroupResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareUnassignOrganizationRoleFromGroupRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- groupId: groupId,
- roleId: roleId);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareUnassignOrganizationRoleFromGroupRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ groupId: groupId,
+ roleId: roleId);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessUnassignOrganizationRoleFromGroupResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UnassignOrganizationRoleFromGroup",
+ methodName: "UnassignOrganizationRoleFromGroupAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}/roles/{roleId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UnassignOrganizationRoleFromGroup",
+ methodName: "UnassignOrganizationRoleFromGroupAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}/roles/{roleId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessUnassignOrganizationRoleFromGroupResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UnassignOrganizationRoleFromGroup",
+ methodName: "UnassignOrganizationRoleFromGroupAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}/roles/{roleId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.DeletedRoleAssignmentResource.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.DeletedRoleAssignmentResource.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessUnassignOrganizationRoleFromGroupResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UnassignOrganizationRoleFromGroup",
+ methodName: "UnassignOrganizationRoleFromGroupAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}/roles/{roleId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UnassignOrganizationRoleFromGroup",
+ methodName: "UnassignOrganizationRoleFromGroupAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}/roles/{roleId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessUnassignOrganizationRoleFromGroupResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.DeletedRoleAssignmentResource.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.DeletedRoleAssignmentResource.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupOrganizationRoleAssignmentsClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupOrganizationRoleAssignmentsClient.g.cs
index e8a4c1962..cab675b25 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupOrganizationRoleAssignmentsClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupOrganizationRoleAssignmentsClient.g.cs
@@ -30,6 +30,9 @@ public sealed partial class GroupOrganizationRoleAssignmentsClient : global::try
#if DEBUG
= true;
#endif
+
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
///
///
///
@@ -49,11 +52,37 @@ public GroupOrganizationRoleAssignmentsClient(
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 GroupOrganizationRoleAssignmentsClient.
+ /// 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 GroupOrganizationRoleAssignmentsClient(
+ global::System.Net.Http.HttpClient? httpClient = null,
+ global::System.Uri? baseUri = null,
+ global::System.Collections.Generic.List? authorizations = null,
+ global::tryAGI.OpenAI.AutoSDKClientOptions? options = null,
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::tryAGI.OpenAI.AutoSDKClientOptions();
_disposeHttpClient = disposeHttpClient;
Initialized(HttpClient);
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupUsersClient.AddGroupUser.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupUsersClient.AddGroupUser.g.cs
index 97f7ce81a..5ff802136 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupUsersClient.AddGroupUser.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupUsersClient.AddGroupUser.g.cs
@@ -14,6 +14,7 @@ public partial class GroupUsersClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -47,12 +48,14 @@ partial void ProcessAddGroupUserResponseContent(
///
///
///
+ /// 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 AddGroupUserAsync(
string groupId,
global::tryAGI.OpenAI.CreateGroupUserBody request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -70,22 +73,43 @@ partial void ProcessAddGroupUserResponseContent(
securityRequirements: s_AddGroupUserSecurityRequirements,
operationName: "AddGroupUserAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/organization/groups/{groupId}/users",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/organization/groups/{groupId}/users",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -95,119 +119,278 @@ partial void ProcessAddGroupUserResponseContent(
__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);
- PrepareAddGroupUserRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- groupId: groupId,
- 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::tryAGI.OpenAI.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);
+ PrepareAddGroupUserRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ groupId: groupId,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessAddGroupUserResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AddGroupUser",
+ methodName: "AddGroupUserAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}/users\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AddGroupUser",
+ methodName: "AddGroupUserAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}/users\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessAddGroupUserResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AddGroupUser",
+ methodName: "AddGroupUserAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}/users\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.GroupUserAssignment.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.GroupUserAssignment.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessAddGroupUserResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AddGroupUser",
+ methodName: "AddGroupUserAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}/users\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AddGroupUser",
+ methodName: "AddGroupUserAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}/users\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessAddGroupUserResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.GroupUserAssignment.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.GroupUserAssignment.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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();
+ }
}
///
/// Adds a user to a group.
@@ -216,11 +399,13 @@ partial void ProcessAddGroupUserResponseContent(
///
/// Identifier of the user to add to the group.
///
+ /// 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 AddGroupUserAsync(
string groupId,
string userId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.CreateGroupUserBody
@@ -231,6 +416,7 @@ partial void ProcessAddGroupUserResponseContent(
return await AddGroupUserAsync(
groupId: groupId,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupUsersClient.ListGroupUsers.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupUsersClient.ListGroupUsers.g.cs
index 1384a17b9..cd6a3dbd5 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupUsersClient.ListGroupUsers.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupUsersClient.ListGroupUsers.g.cs
@@ -14,6 +14,7 @@ public partial class GroupUsersClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -57,6 +58,7 @@ partial void ProcessListGroupUsersResponseContent(
///
/// Default Value: desc
///
+ /// 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 ListGroupUsersAsync(
@@ -64,6 +66,7 @@ partial void ProcessListGroupUsersResponseContent(
int? limit = default,
string? after = default,
global::tryAGI.OpenAI.ListGroupUsersOrder? order = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -81,27 +84,48 @@ partial void ProcessListGroupUsersResponseContent(
securityRequirements: s_ListGroupUsersSecurityRequirements,
operationName: "ListGroupUsersAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/organization/groups/{groupId}/users",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("limit", limit?.ToString())
- .AddOptionalParameter("after", after)
- .AddOptionalParameter("order", order?.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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/organization/groups/{groupId}/users",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("limit", limit?.ToString())
+ .AddOptionalParameter("after", after)
+ .AddOptionalParameter("order", order?.ToValueString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,115 +135,274 @@ partial void ProcessListGroupUsersResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareListGroupUsersRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- groupId: groupId,
- limit: limit,
- after: after,
- order: order);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareListGroupUsersRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ groupId: groupId,
+ limit: limit,
+ after: after,
+ order: order);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessListGroupUsersResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListGroupUsers",
+ methodName: "ListGroupUsersAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}/users\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListGroupUsers",
+ methodName: "ListGroupUsersAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}/users\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessListGroupUsersResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListGroupUsers",
+ methodName: "ListGroupUsersAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}/users\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.UserListResource.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.UserListResource.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessListGroupUsersResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListGroupUsers",
+ methodName: "ListGroupUsersAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}/users\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListGroupUsers",
+ methodName: "ListGroupUsersAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}/users\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessListGroupUsersResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.UserListResource.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.UserListResource.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupUsersClient.RemoveGroupUser.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupUsersClient.RemoveGroupUser.g.cs
index 47c36e0f2..4ded5de8c 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupUsersClient.RemoveGroupUser.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupUsersClient.RemoveGroupUser.g.cs
@@ -14,6 +14,7 @@ public partial class GroupUsersClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -47,11 +48,13 @@ partial void ProcessRemoveGroupUserResponseContent(
///
///
///
+ /// 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 RemoveGroupUserAsync(
string groupId,
string userId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -67,22 +70,43 @@ partial void ProcessRemoveGroupUserResponseContent(
securityRequirements: s_RemoveGroupUserSecurityRequirements,
operationName: "RemoveGroupUserAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/organization/groups/{groupId}/users/{userId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/organization/groups/{groupId}/users/{userId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -92,113 +116,272 @@ partial void ProcessRemoveGroupUserResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareRemoveGroupUserRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- groupId: groupId,
- userId: userId);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareRemoveGroupUserRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ groupId: groupId,
+ userId: userId);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessRemoveGroupUserResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RemoveGroupUser",
+ methodName: "RemoveGroupUserAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}/users/{userId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RemoveGroupUser",
+ methodName: "RemoveGroupUserAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}/users/{userId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessRemoveGroupUserResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RemoveGroupUser",
+ methodName: "RemoveGroupUserAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}/users/{userId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.GroupUserDeletedResource.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.GroupUserDeletedResource.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessRemoveGroupUserResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RemoveGroupUser",
+ methodName: "RemoveGroupUserAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}/users/{userId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RemoveGroupUser",
+ methodName: "RemoveGroupUserAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}/users/{userId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessRemoveGroupUserResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.GroupUserDeletedResource.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.GroupUserDeletedResource.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupUsersClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupUsersClient.g.cs
index c636eddeb..3290e45d7 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupUsersClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupUsersClient.g.cs
@@ -30,6 +30,9 @@ public sealed partial class GroupUsersClient : global::tryAGI.OpenAI.IGroupUsers
#if DEBUG
= true;
#endif
+
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
///
///
///
@@ -49,11 +52,37 @@ public GroupUsersClient(
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 GroupUsersClient.
+ /// 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 GroupUsersClient(
+ global::System.Net.Http.HttpClient? httpClient = null,
+ global::System.Uri? baseUri = null,
+ global::System.Collections.Generic.List? authorizations = null,
+ global::tryAGI.OpenAI.AutoSDKClientOptions? options = null,
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::tryAGI.OpenAI.AutoSDKClientOptions();
_disposeHttpClient = disposeHttpClient;
Initialized(HttpClient);
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupsClient.CreateGroup.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupsClient.CreateGroup.g.cs
index 61caf5470..229693f22 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupsClient.CreateGroup.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupsClient.CreateGroup.g.cs
@@ -14,6 +14,7 @@ public partial class GroupsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -44,11 +45,13 @@ partial void ProcessCreateGroupResponseContent(
/// Creates a new group in the organization.
///
///
+ /// 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 CreateGroupAsync(
global::tryAGI.OpenAI.CreateGroupBody request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -65,22 +68,43 @@ partial void ProcessCreateGroupResponseContent(
securityRequirements: s_CreateGroupSecurityRequirements,
operationName: "CreateGroupAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: "/organization/groups",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: "/organization/groups",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,118 +114,277 @@ partial void ProcessCreateGroupResponseContent(
__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);
- PrepareCreateGroupRequest(
- 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::tryAGI.OpenAI.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);
+ PrepareCreateGroupRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCreateGroupResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateGroup",
+ methodName: "CreateGroupAsync",
+ pathTemplate: "\"/organization/groups\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateGroup",
+ methodName: "CreateGroupAsync",
+ pathTemplate: "\"/organization/groups\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessCreateGroupResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateGroup",
+ methodName: "CreateGroupAsync",
+ pathTemplate: "\"/organization/groups\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.GroupResponse.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.GroupResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessCreateGroupResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateGroup",
+ methodName: "CreateGroupAsync",
+ pathTemplate: "\"/organization/groups\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateGroup",
+ methodName: "CreateGroupAsync",
+ pathTemplate: "\"/organization/groups\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessCreateGroupResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.GroupResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.GroupResponse.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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();
+ }
}
///
/// Creates a new group in the organization.
@@ -209,10 +392,12 @@ partial void ProcessCreateGroupResponseContent(
///
/// Human readable name for the group.
///
+ /// 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 CreateGroupAsync(
string name,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.CreateGroupBody
@@ -222,6 +407,7 @@ partial void ProcessCreateGroupResponseContent(
return await CreateGroupAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupsClient.DeleteGroup.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupsClient.DeleteGroup.g.cs
index 543904e4d..105c2b9d5 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupsClient.DeleteGroup.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupsClient.DeleteGroup.g.cs
@@ -14,6 +14,7 @@ public partial class GroupsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -44,10 +45,12 @@ partial void ProcessDeleteGroupResponseContent(
/// Deletes a group from the organization.
///
///
+ /// 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 DeleteGroupAsync(
string groupId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -62,22 +65,43 @@ partial void ProcessDeleteGroupResponseContent(
securityRequirements: s_DeleteGroupSecurityRequirements,
operationName: "DeleteGroupAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/organization/groups/{groupId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/organization/groups/{groupId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -87,112 +111,271 @@ partial void ProcessDeleteGroupResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareDeleteGroupRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- groupId: groupId);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareDeleteGroupRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ groupId: groupId);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessDeleteGroupResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteGroup",
+ methodName: "DeleteGroupAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteGroup",
+ methodName: "DeleteGroupAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessDeleteGroupResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteGroup",
+ methodName: "DeleteGroupAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.GroupDeletedResource.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.GroupDeletedResource.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessDeleteGroupResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteGroup",
+ methodName: "DeleteGroupAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteGroup",
+ methodName: "DeleteGroupAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessDeleteGroupResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.GroupDeletedResource.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.GroupDeletedResource.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupsClient.ListGroups.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupsClient.ListGroups.g.cs
index fb3f8565a..48f0ae30c 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupsClient.ListGroups.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupsClient.ListGroups.g.cs
@@ -14,6 +14,7 @@ public partial class GroupsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -54,12 +55,14 @@ partial void ProcessListGroupsResponseContent(
///
/// Default Value: asc
///
+ /// 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 ListGroupsAsync(
int? limit = default,
string? after = default,
global::tryAGI.OpenAI.ListGroupsOrder? order = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -76,27 +79,48 @@ partial void ProcessListGroupsResponseContent(
securityRequirements: s_ListGroupsSecurityRequirements,
operationName: "ListGroupsAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: "/organization/groups",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("limit", limit?.ToString())
- .AddOptionalParameter("after", after)
- .AddOptionalParameter("order", order?.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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: "/organization/groups",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("limit", limit?.ToString())
+ .AddOptionalParameter("after", after)
+ .AddOptionalParameter("order", order?.ToValueString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,114 +130,273 @@ partial void ProcessListGroupsResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareListGroupsRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- limit: limit,
- after: after,
- order: order);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareListGroupsRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ limit: limit,
+ after: after,
+ order: order);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessListGroupsResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListGroups",
+ methodName: "ListGroupsAsync",
+ pathTemplate: "\"/organization/groups\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListGroups",
+ methodName: "ListGroupsAsync",
+ pathTemplate: "\"/organization/groups\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessListGroupsResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListGroups",
+ methodName: "ListGroupsAsync",
+ pathTemplate: "\"/organization/groups\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.GroupListResource.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.GroupListResource.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessListGroupsResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListGroups",
+ methodName: "ListGroupsAsync",
+ pathTemplate: "\"/organization/groups\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListGroups",
+ methodName: "ListGroupsAsync",
+ pathTemplate: "\"/organization/groups\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessListGroupsResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.GroupListResource.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.GroupListResource.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupsClient.UpdateGroup.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupsClient.UpdateGroup.g.cs
index 980804ed9..3686c8787 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupsClient.UpdateGroup.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupsClient.UpdateGroup.g.cs
@@ -14,6 +14,7 @@ public partial class GroupsClient
{ new global::tryAGI.OpenAI.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "ApiKeyAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -47,12 +48,14 @@ partial void ProcessUpdateGroupResponseContent(
///
///
///
+ /// 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 UpdateGroupAsync(
string groupId,
global::tryAGI.OpenAI.UpdateGroupBody request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -70,22 +73,43 @@ partial void ProcessUpdateGroupResponseContent(
securityRequirements: s_UpdateGroupSecurityRequirements,
operationName: "UpdateGroupAsync");
- var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
- path: $"/organization/groups/{groupId}",
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
+ path: $"/organization/groups/{groupId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::tryAGI.OpenAI.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,
@@ -95,119 +119,278 @@ partial void ProcessUpdateGroupResponseContent(
__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);
- PrepareUpdateGroupRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- groupId: groupId,
- 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::tryAGI.OpenAI.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);
+ PrepareUpdateGroupRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ groupId: groupId,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessUpdateGroupResponse(
- 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UpdateGroup",
+ methodName: "UpdateGroupAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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 __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UpdateGroup",
+ methodName: "UpdateGroupAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessUpdateGroupResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UpdateGroup",
+ methodName: "UpdateGroupAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::tryAGI.OpenAI.GroupResourceWithSuccess.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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::tryAGI.OpenAI.GroupResourceWithSuccess.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessUpdateGroupResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UpdateGroup",
+ methodName: "UpdateGroupAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UpdateGroup",
+ methodName: "UpdateGroupAsync",
+ pathTemplate: "$\"/organization/groups/{groupId}\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ 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);
+ ProcessUpdateGroupResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::tryAGI.OpenAI.GroupResourceWithSuccess.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.GroupResourceWithSuccess.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::tryAGI.OpenAI.ApiException(
+ message: __content ?? __response.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::tryAGI.OpenAI.ApiException(
- message: __content ?? __response.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();
+ }
}
///
/// Updates a group's information.
@@ -216,11 +399,13 @@ partial void ProcessUpdateGroupResponseContent(
///
/// New display name for the group.
///
+ /// 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 UpdateGroupAsync(
string groupId,
string name,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::tryAGI.OpenAI.UpdateGroupBody
@@ -231,6 +416,7 @@ partial void ProcessUpdateGroupResponseContent(
return await UpdateGroupAsync(
groupId: groupId,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupsClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupsClient.g.cs
index be6e34e7d..638a3bd46 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupsClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.GroupsClient.g.cs
@@ -30,6 +30,9 @@ public sealed partial class GroupsClient : global::tryAGI.OpenAI.IGroupsClient,
#if DEBUG
= true;
#endif
+
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
///
///
///
@@ -49,11 +52,37 @@ public GroupsClient(
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 GroupsClient.
+ /// 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 GroupsClient(
+ global::System.Net.Http.HttpClient? httpClient = null,
+ global::System.Uri? baseUri = null,
+ global::System.Collections.Generic.List? authorizations = null,
+ global::tryAGI.OpenAI.AutoSDKClientOptions? options = null,
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::tryAGI.OpenAI.AutoSDKClientOptions();
_disposeHttpClient = disposeHttpClient;
Initialized(HttpClient);
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.CancelARun.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.CancelARun.g.cs
index a9f3b2457..895c253aa 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.CancelARun.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.CancelARun.g.cs
@@ -9,11 +9,13 @@ public partial interface IAssistantsClient
///
///
///
+ /// 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 CancelARunAsync(
string threadId,
string runId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.CreateMessage.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.CreateMessage.g.cs
index 6f9029688..32b084f7e 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.CreateMessage.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.CreateMessage.g.cs
@@ -9,12 +9,14 @@ public partial interface IAssistantsClient
///
///
///
+ /// 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 CreateMessageAsync(
string threadId,
global::tryAGI.OpenAI.CreateMessageRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Create a message.
@@ -28,6 +30,7 @@ public partial interface IAssistantsClient
///
///
///
+ /// 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 CreateMessageAsync(
@@ -36,6 +39,7 @@ public partial interface IAssistantsClient
global::tryAGI.OpenAI.OneOf>> content,
global::System.Collections.Generic.IList? attachments = default,
global::System.Collections.Generic.Dictionary? metadata = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.CreateRun.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.CreateRun.g.cs
index 4013f90b1..2c62a58c5 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.CreateRun.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.CreateRun.g.cs
@@ -10,6 +10,7 @@ public partial interface IAssistantsClient
///
///
///
+ /// 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 CreateRunAsync(
@@ -17,6 +18,7 @@ public partial interface IAssistantsClient
global::tryAGI.OpenAI.CreateRunRequest request,
global::System.Collections.Generic.IList? include = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Create a run.
@@ -76,6 +78,7 @@ public partial interface IAssistantsClient
/// Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON.
/// **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.
///
+ /// 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 CreateRunAsync(
@@ -98,6 +101,7 @@ public partial interface IAssistantsClient
global::tryAGI.OpenAI.AllOf? toolChoice = default,
bool? parallelToolCalls = default,
global::tryAGI.OpenAI.AssistantsApiResponseFormatOption? responseFormat = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.CreateThread.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.CreateThread.g.cs
index 6ad9a2adf..82a3231f2 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.CreateThread.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.CreateThread.g.cs
@@ -8,11 +8,13 @@ public partial interface IAssistantsClient
/// Create a thread.
///
///
+ /// 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 CreateThreadAsync(
global::tryAGI.OpenAI.CreateThreadRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Create a thread.
@@ -22,12 +24,14 @@ public partial interface IAssistantsClient
///
///
///
+ /// 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 CreateThreadAsync(
global::System.Collections.Generic.IList? messages = default,
global::tryAGI.OpenAI.CreateThreadRequestToolResources2? toolResources = default,
global::System.Collections.Generic.Dictionary? metadata = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.CreateThreadAndRun.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.CreateThreadAndRun.g.cs
index 7bdccc267..f82ce2ba3 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.CreateThreadAndRun.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.CreateThreadAndRun.g.cs
@@ -8,11 +8,13 @@ public partial interface IAssistantsClient
/// Create a thread and run it in one request.
///
///
+ /// 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 CreateThreadAndRunAsync(
global::tryAGI.OpenAI.CreateThreadAndRunRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Create a thread and run it in one request.
@@ -70,6 +72,7 @@ public partial interface IAssistantsClient
/// Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON.
/// **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.
///
+ /// 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 CreateThreadAndRunAsync(
@@ -89,6 +92,7 @@ public partial interface IAssistantsClient
global::tryAGI.OpenAI.AllOf? toolChoice = default,
bool? parallelToolCalls = default,
global::tryAGI.OpenAI.AssistantsApiResponseFormatOption? responseFormat = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.DeleteMessage.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.DeleteMessage.g.cs
index fa90d0dd7..ae9af35b9 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.DeleteMessage.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.DeleteMessage.g.cs
@@ -9,11 +9,13 @@ public partial interface IAssistantsClient
///
///
///
+ /// 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 DeleteMessageAsync(
string threadId,
string messageId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.DeleteThread.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.DeleteThread.g.cs
index 806ef2633..a6e271bf5 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.DeleteThread.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.DeleteThread.g.cs
@@ -8,10 +8,12 @@ public partial interface IAssistantsClient
/// Delete a thread.
///
///
+ /// 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 DeleteThreadAsync(
string threadId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.ListMessages.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.ListMessages.g.cs
index df1f6d228..9af8d470a 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.ListMessages.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.ListMessages.g.cs
@@ -17,6 +17,7 @@ public partial interface IAssistantsClient
///
///
///
+ /// 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 ListMessagesAsync(
@@ -26,6 +27,7 @@ public partial interface IAssistantsClient
string? after = default,
string? before = default,
string? runId = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.ListRunSteps.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.ListRunSteps.g.cs
index 1f1002fd6..1477ac597 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.ListRunSteps.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.ListRunSteps.g.cs
@@ -18,6 +18,7 @@ public partial interface IAssistantsClient
///
///
///
+ /// 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 ListRunStepsAsync(
@@ -28,6 +29,7 @@ public partial interface IAssistantsClient
string? after = default,
string? before = default,
global::System.Collections.Generic.IList? include = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.ListRuns.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.ListRuns.g.cs
index 9e3291279..c2e091421 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.ListRuns.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.ListRuns.g.cs
@@ -16,6 +16,7 @@ public partial interface IAssistantsClient
///
///
///
+ /// 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 ListRunsAsync(
@@ -24,6 +25,7 @@ public partial interface IAssistantsClient
global::tryAGI.OpenAI.ListRunsOrder? order = default,
string? after = default,
string? before = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.ModifyMessage.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.ModifyMessage.g.cs
index af8c06df7..ec9b7b2e9 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.ModifyMessage.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.ModifyMessage.g.cs
@@ -10,6 +10,7 @@ public partial interface IAssistantsClient
///
///
///
+ /// 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 ModifyMessageAsync(
@@ -17,6 +18,7 @@ public partial interface IAssistantsClient
string messageId,
global::tryAGI.OpenAI.ModifyMessageRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Modifies a message.
@@ -24,12 +26,14 @@ public partial interface IAssistantsClient
///
///
///
+ /// 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 ModifyMessageAsync(
string threadId,
string messageId,
global::System.Collections.Generic.Dictionary? metadata = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.ModifyRun.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.ModifyRun.g.cs
index acaf730d7..46b7b4fa9 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.ModifyRun.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.ModifyRun.g.cs
@@ -10,6 +10,7 @@ public partial interface IAssistantsClient
///
///
///
+ /// 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 ModifyRunAsync(
@@ -17,6 +18,7 @@ public partial interface IAssistantsClient
string runId,
global::tryAGI.OpenAI.ModifyRunRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Modifies a run.
@@ -24,12 +26,14 @@ public partial interface IAssistantsClient
///
///
///
+ /// 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 ModifyRunAsync(
string threadId,
string runId,
global::System.Collections.Generic.Dictionary? metadata = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.ModifyThread.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.ModifyThread.g.cs
index 418c0dbb6..b0a4d8d23 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.ModifyThread.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.ModifyThread.g.cs
@@ -9,12 +9,14 @@ public partial interface IAssistantsClient
///
///
///
+ /// 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 ModifyThreadAsync(
string threadId,
global::tryAGI.OpenAI.ModifyThreadRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Modifies a thread.
@@ -22,12 +24,14 @@ public partial interface IAssistantsClient
///
///
///
+ /// 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 ModifyThreadAsync(
string threadId,
global::tryAGI.OpenAI.ModifyThreadRequestToolResources2? toolResources = default,
global::System.Collections.Generic.Dictionary? metadata = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.RetrieveMessage.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.RetrieveMessage.g.cs
index dc72eb3ab..7eb64e048 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.RetrieveMessage.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.RetrieveMessage.g.cs
@@ -9,11 +9,13 @@ public partial interface IAssistantsClient
///
///
///
+ /// 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 RetrieveMessageAsync(
string threadId,
string messageId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.RetrieveRun.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.RetrieveRun.g.cs
index b035c7d0e..d64bdd790 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.RetrieveRun.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.RetrieveRun.g.cs
@@ -9,11 +9,13 @@ public partial interface IAssistantsClient
///
///
///
+ /// 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 RetrieveRunAsync(
string threadId,
string runId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.RetrieveRunStep.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.RetrieveRunStep.g.cs
index 5eed3bf3e..77dc4dc72 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.RetrieveRunStep.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.RetrieveRunStep.g.cs
@@ -11,6 +11,7 @@ public partial interface IAssistantsClient
///
///
///
+ /// 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 RetrieveRunStepAsync(
@@ -18,6 +19,7 @@ public partial interface IAssistantsClient
string runId,
string stepId,
global::System.Collections.Generic.IList? include = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.RetrieveThread.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.RetrieveThread.g.cs
index f783204f2..c425f5a68 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.RetrieveThread.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.RetrieveThread.g.cs
@@ -8,10 +8,12 @@ public partial interface IAssistantsClient
/// Retrieves a thread.
///
///
+ /// 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 RetrieveThreadAsync(
string threadId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.SubmitToolOutputsToRun.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.SubmitToolOutputsToRun.g.cs
index 19bafdce4..4efa0e23b 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.SubmitToolOutputsToRun.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.SubmitToolOutputsToRun.g.cs
@@ -10,6 +10,7 @@ public partial interface IAssistantsClient
///
///
///
+ /// 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 SubmitToolOutputsToRunAsync(
@@ -17,6 +18,7 @@ public partial interface IAssistantsClient
string runId,
global::tryAGI.OpenAI.SubmitToolOutputsRunRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// When a run has the `status: "requires_action"` and `required_action.type` is `submit_tool_outputs`, this endpoint can be used to submit the outputs from the tool calls once they're all completed. All outputs must be submitted in a single request.
@@ -27,6 +29,7 @@ public partial interface IAssistantsClient
/// A list of tools for which the outputs are being submitted.
///
///
+ /// 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 SubmitToolOutputsToRunAsync(
@@ -34,6 +37,7 @@ public partial interface IAssistantsClient
string runId,
global::System.Collections.Generic.IList toolOutputs,
bool? stream = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.g.cs
index fd59cb8d9..226d7095b 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAssistantsClient.g.cs
@@ -34,6 +34,11 @@ public partial interface IAssistantsClient : global::System.IDisposable
///
public bool ReadResponseAsString { get; set; }
+ ///
+ /// Client-wide request defaults such as headers, query parameters, retries, and timeout.
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
+
///
///
///
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateSpeech.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateSpeech.g.cs
index 7bb98a8f8..0b5fd16ca 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateSpeech.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateSpeech.g.cs
@@ -9,11 +9,13 @@ public partial interface IAudioClient
/// Returns the audio file content, or a stream of audio events.
///
///
+ /// 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 CreateSpeechAsync(
global::tryAGI.OpenAI.CreateSpeechRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Generates audio from the input text.
@@ -43,6 +45,7 @@ public partial interface IAudioClient
/// The format to stream the audio in. Supported formats are `sse` and `audio`. `sse` is not supported for `tts-1` or `tts-1-hd`.
/// Default Value: audio
///
+ /// 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 CreateSpeechAsync(
@@ -53,6 +56,7 @@ public partial interface IAudioClient
global::tryAGI.OpenAI.CreateSpeechRequestResponseFormat? responseFormat = default,
double? speed = default,
global::tryAGI.OpenAI.CreateSpeechRequestStreamFormat? streamFormat = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateTranscription.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateTranscription.g.cs
index ef8fce30d..bf170d7e6 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateTranscription.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateTranscription.g.cs
@@ -10,11 +10,13 @@ public partial interface IAudioClient
/// format, or a stream of transcript events.
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
global::System.Threading.Tasks.Task> CreateTranscriptionAsync(
global::tryAGI.OpenAI.CreateTranscriptionRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Transcribes audio into the input language.
@@ -64,6 +66,7 @@ public partial interface IAudioClient
///
/// Optional list of audio samples (as [data URLs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs)) that contain known speaker references matching `known_speaker_names[]`. Each sample must be between 2 and 10 seconds, and can use any of the same input audio formats supported by `file`.
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
global::System.Threading.Tasks.Task> CreateTranscriptionAsync(
@@ -79,6 +82,7 @@ public partial interface IAudioClient
global::tryAGI.OpenAI.AnyOf? chunkingStrategy = default,
global::System.Collections.Generic.IList? knownSpeakerNames = default,
global::System.Collections.Generic.IList? knownSpeakerReferences = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateTranscriptionAsStream.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateTranscriptionAsStream.g.cs
index 95782ea72..921b61fd0 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateTranscriptionAsStream.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateTranscriptionAsStream.g.cs
@@ -10,11 +10,13 @@ public partial interface IAudioClient
/// format, or a stream of transcript events.
///
///
+ /// 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 CreateTranscriptionAsStreamAsync(
global::tryAGI.OpenAI.CreateTranscriptionRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Transcribes audio into the input language.
@@ -64,6 +66,7 @@ public partial interface IAudioClient
///
/// Optional list of audio samples (as [data URLs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs)) that contain known speaker references matching `known_speaker_names[]`. Each sample must be between 2 and 10 seconds, and can use any of the same input audio formats supported by `file`.
///
+ /// 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 CreateTranscriptionAsStreamAsync(
@@ -79,6 +82,7 @@ public partial interface IAudioClient
global::tryAGI.OpenAI.AnyOf? chunkingStrategy = default,
global::System.Collections.Generic.IList? knownSpeakerNames = default,
global::System.Collections.Generic.IList? knownSpeakerReferences = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateTranslation.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateTranslation.g.cs
index 689ea85a5..3a3990ae1 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateTranslation.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateTranslation.g.cs
@@ -8,11 +8,13 @@ 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
///
global::System.Threading.Tasks.Task> CreateTranslationAsync(
global::tryAGI.OpenAI.CreateTranslationRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Translates audio into English.
@@ -38,6 +40,7 @@ public partial interface IAudioClient
/// The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.
/// 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> CreateTranslationAsync(
@@ -47,6 +50,7 @@ public partial interface IAudioClient
string? prompt = default,
global::tryAGI.OpenAI.CreateTranslationRequestResponseFormat? responseFormat = default,
double? temperature = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateVoice.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateVoice.g.cs
index 9f3a0da7d..43d3b3e6d 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateVoice.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateVoice.g.cs
@@ -10,11 +10,13 @@ public partial interface IAudioClient
/// See the [custom voices guide](/docs/guides/text-to-speech#custom-voices) for requirements and best practices. Custom voices are limited to eligible customers.
///
///
+ /// 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 CreateVoiceAsync(
global::tryAGI.OpenAI.CreateVoiceRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Creates a custom voice.
@@ -37,6 +39,7 @@ public partial interface IAudioClient
///
/// The consent recording ID (for example, `cons_1234`).
///
+ /// 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 CreateVoiceAsync(
@@ -44,6 +47,7 @@ public partial interface IAudioClient
byte[] audioSample,
string audioSamplename,
string consent,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateVoiceConsent.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateVoiceConsent.g.cs
index f0d20c327..7c90e526f 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateVoiceConsent.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.CreateVoiceConsent.g.cs
@@ -10,11 +10,13 @@ public partial interface IAudioClient
/// See the [custom voices guide](/docs/guides/text-to-speech#custom-voices) for requirements and best practices. Custom voices are limited to eligible customers.
///
///
+ /// 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 CreateVoiceConsentAsync(
global::tryAGI.OpenAI.CreateVoiceConsentRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Upload a voice consent recording.
@@ -37,6 +39,7 @@ public partial interface IAudioClient
///
/// The BCP 47 language tag for the consent phrase (for example, `en-US`).
///
+ /// 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 CreateVoiceConsentAsync(
@@ -44,6 +47,7 @@ public partial interface IAudioClient
byte[] recording,
string recordingname,
string language,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.DeleteVoiceConsent.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.DeleteVoiceConsent.g.cs
index 888e0c99c..0321b2a0e 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.DeleteVoiceConsent.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.DeleteVoiceConsent.g.cs
@@ -10,10 +10,12 @@ public partial interface IAudioClient
/// See the [custom voices guide](/docs/guides/text-to-speech#custom-voices). Custom voices are limited to eligible customers.
///
///
+ /// 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 DeleteVoiceConsentAsync(
string consentId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.ListVoiceConsents.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.ListVoiceConsents.g.cs
index fb9e88959..c0ada6ff7 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.ListVoiceConsents.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.ListVoiceConsents.g.cs
@@ -13,11 +13,13 @@ public partial interface IAudioClient
///
/// Default Value: 20
///
+ /// 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 ListVoiceConsentsAsync(
string? after = default,
int? limit = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.RetrieveVoiceConsent.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.RetrieveVoiceConsent.g.cs
index 78c603d5f..997ac2a39 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.RetrieveVoiceConsent.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.RetrieveVoiceConsent.g.cs
@@ -10,10 +10,12 @@ public partial interface IAudioClient
/// See the [custom voices guide](/docs/guides/text-to-speech#custom-voices). Custom voices are limited to eligible customers.
///
///
+ /// 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 RetrieveVoiceConsentAsync(
string consentId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.UpdateVoiceConsent.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.UpdateVoiceConsent.g.cs
index ed24063fb..2d45a7e7e 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.UpdateVoiceConsent.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.UpdateVoiceConsent.g.cs
@@ -11,12 +11,14 @@ public partial interface IAudioClient
///
///
///
+ /// 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 UpdateVoiceConsentAsync(
string consentId,
global::tryAGI.OpenAI.UpdateVoiceConsentRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Updates a voice consent recording (metadata only).
@@ -27,11 +29,13 @@ public partial interface IAudioClient
///
/// The updated label for this consent recording.
///
+ /// 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 UpdateVoiceConsentAsync(
string consentId,
string name,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.g.cs
index 4fd6c5073..8fa4f90ca 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAudioClient.g.cs
@@ -34,6 +34,11 @@ public partial interface IAudioClient : global::System.IDisposable
///
public bool ReadResponseAsString { get; set; }
+ ///
+ /// Client-wide request defaults such as headers, query parameters, retries, and timeout.
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
+
///
///
///
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAuditLogsClient.ListAuditLogs.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAuditLogsClient.ListAuditLogs.g.cs
index 313ead568..4e046b052 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAuditLogsClient.ListAuditLogs.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAuditLogsClient.ListAuditLogs.g.cs
@@ -18,6 +18,7 @@ public partial interface IAuditLogsClient
///
///
///
+ /// 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 ListAuditLogsAsync(
@@ -30,6 +31,7 @@ public partial interface IAuditLogsClient
int? limit = default,
string? after = default,
string? before = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAuditLogsClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAuditLogsClient.g.cs
index f5bb24397..1880886b7 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAuditLogsClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IAuditLogsClient.g.cs
@@ -34,6 +34,11 @@ public partial interface IAuditLogsClient : global::System.IDisposable
///
public bool ReadResponseAsString { get; set; }
+ ///
+ /// Client-wide request defaults such as headers, query parameters, retries, and timeout.
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
+
///
///
///
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IBatchClient.CancelBatch.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IBatchClient.CancelBatch.g.cs
index 8380df4ba..b5f40d464 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IBatchClient.CancelBatch.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IBatchClient.CancelBatch.g.cs
@@ -8,10 +8,12 @@ public partial interface IBatchClient
/// Cancels an in-progress batch. The batch will be in status `cancelling` for up to 10 minutes, before changing to `cancelled`, where it will have partial results (if any) available in the output file.
///
///
+ /// 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 CancelBatchAsync(
string batchId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IBatchClient.CreateBatch.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IBatchClient.CreateBatch.g.cs
index b5719261f..06fc40b70 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IBatchClient.CreateBatch.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IBatchClient.CreateBatch.g.cs
@@ -8,11 +8,13 @@ public partial interface IBatchClient
/// Creates and executes a batch from an uploaded file of requests
///
///
+ /// 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 CreateBatchAsync(
global::tryAGI.OpenAI.CreateBatchRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Creates and executes a batch from an uploaded file of requests
@@ -32,6 +34,7 @@ public partial interface IBatchClient
///
/// The expiration policy for the output and/or error file that are generated for a batch.
///
+ /// 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 CreateBatchAsync(
@@ -40,6 +43,7 @@ public partial interface IBatchClient
global::tryAGI.OpenAI.CreateBatchRequestCompletionWindow completionWindow = default,
global::System.Collections.Generic.Dictionary? metadata = default,
global::tryAGI.OpenAI.BatchFileExpirationAfter? outputExpiresAfter = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IBatchClient.ListBatches.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IBatchClient.ListBatches.g.cs
index c03d20fbb..3996110b5 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IBatchClient.ListBatches.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IBatchClient.ListBatches.g.cs
@@ -11,11 +11,13 @@ public partial interface IBatchClient
///
/// Default Value: 20
///
+ /// 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 ListBatchesAsync(
string? after = default,
int? limit = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IBatchClient.RetrieveBatch.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IBatchClient.RetrieveBatch.g.cs
index 29d43e58c..fa3d628d9 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IBatchClient.RetrieveBatch.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IBatchClient.RetrieveBatch.g.cs
@@ -8,10 +8,12 @@ public partial interface IBatchClient
/// Retrieves a batch.
///
///
+ /// 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 RetrieveBatchAsync(
string batchId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IBatchClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IBatchClient.g.cs
index 78e8675c2..4075ad334 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IBatchClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IBatchClient.g.cs
@@ -34,6 +34,11 @@ public partial interface IBatchClient : global::System.IDisposable
///
public bool ReadResponseAsString { get; set; }
+ ///
+ /// Client-wide request defaults such as headers, query parameters, retries, and timeout.
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
+
///
///
///
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.ActivateCertificatesForOrganization.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.ActivateCertificatesForOrganization.g.cs
index 57c7e6355..0929e3480 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.ActivateCertificatesForOrganization.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.ActivateCertificatesForOrganization.g.cs
@@ -9,21 +9,25 @@ public partial interface ICertificatesClient
/// You can atomically and idempotently activate up to 10 certificates at a time.
///
///
+ /// 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 ActivateCertificatesForOrganizationAsync(
global::tryAGI.OpenAI.ToggleCertificatesRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Activate certificates at the organization level.
/// You can atomically and idempotently activate up to 10 certificates at a time.
///
///
+ /// 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 ActivateCertificatesForOrganizationAsync(
global::System.Collections.Generic.IList certificateIds,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.ActivateCertificatesForProject.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.ActivateCertificatesForProject.g.cs
index bea3d40e9..2187b7b0f 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.ActivateCertificatesForProject.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.ActivateCertificatesForProject.g.cs
@@ -10,12 +10,14 @@ public partial interface ICertificatesClient
///
///
///
+ /// 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 ActivateCertificatesForProjectAsync(
string projectId,
global::tryAGI.OpenAI.ToggleCertificatesRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Activate certificates at the project level.
@@ -23,11 +25,13 @@ public partial interface ICertificatesClient
///
///
///
+ /// 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 ActivateCertificatesForProjectAsync(
string projectId,
global::System.Collections.Generic.IList certificateIds,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.DeactivateCertificatesForOrganization.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.DeactivateCertificatesForOrganization.g.cs
index 2627d6d9c..3a1e345b9 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.DeactivateCertificatesForOrganization.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.DeactivateCertificatesForOrganization.g.cs
@@ -9,21 +9,25 @@ public partial interface ICertificatesClient
/// You can atomically and idempotently deactivate up to 10 certificates at a time.
///
///
+ /// 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 DeactivateCertificatesForOrganizationAsync(
global::tryAGI.OpenAI.ToggleCertificatesRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Deactivate certificates at the organization level.
/// You can atomically and idempotently deactivate up to 10 certificates at a time.
///
///
+ /// 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 DeactivateCertificatesForOrganizationAsync(
global::System.Collections.Generic.IList certificateIds,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.DeactivateCertificatesForProject.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.DeactivateCertificatesForProject.g.cs
index 06d03e35a..35461f27c 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.DeactivateCertificatesForProject.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.DeactivateCertificatesForProject.g.cs
@@ -10,12 +10,14 @@ public partial interface ICertificatesClient
///
///
///
+ /// 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 DeactivateCertificatesForProjectAsync(
string projectId,
global::tryAGI.OpenAI.ToggleCertificatesRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Deactivate certificates at the project level. You can atomically and
@@ -23,11 +25,13 @@ public partial interface ICertificatesClient
///
///
///
+ /// 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 DeactivateCertificatesForProjectAsync(
string projectId,
global::System.Collections.Generic.IList certificateIds,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.DeleteCertificate.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.DeleteCertificate.g.cs
index a986fbf9c..1d82f9569 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.DeleteCertificate.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.DeleteCertificate.g.cs
@@ -9,10 +9,12 @@ public partial interface ICertificatesClient
/// The certificate must be inactive for the organization and all projects.
///
///
+ /// 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 DeleteCertificateAsync(
string certificateId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.GetCertificate.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.GetCertificate.g.cs
index 697926563..131b79724 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.GetCertificate.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.GetCertificate.g.cs
@@ -10,11 +10,13 @@ public partial interface ICertificatesClient
///
///
///
+ /// 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 GetCertificateAsync(
string certificateId,
global::System.Collections.Generic.IList? include = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.ListOrganizationCertificates.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.ListOrganizationCertificates.g.cs
index 16fe8fc90..6c56362d6 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.ListOrganizationCertificates.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.ListOrganizationCertificates.g.cs
@@ -14,12 +14,14 @@ public partial interface ICertificatesClient
///
/// Default Value: desc
///
+ /// 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 ListOrganizationCertificatesAsync(
int? limit = default,
string? after = default,
global::tryAGI.OpenAI.ListOrganizationCertificatesOrder? order = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.ListProjectCertificates.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.ListProjectCertificates.g.cs
index 8c8b9d319..78fc12d7f 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.ListProjectCertificates.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.ListProjectCertificates.g.cs
@@ -15,6 +15,7 @@ public partial interface ICertificatesClient
///
/// Default Value: desc
///
+ /// 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 ListProjectCertificatesAsync(
@@ -22,6 +23,7 @@ public partial interface ICertificatesClient
int? limit = default,
string? after = default,
global::tryAGI.OpenAI.ListProjectCertificatesOrder? order = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.ModifyCertificate.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.ModifyCertificate.g.cs
index 4eefe9dc8..c9e619a9e 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.ModifyCertificate.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.ModifyCertificate.g.cs
@@ -9,12 +9,14 @@ public partial interface ICertificatesClient
///
///
///
+ /// 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 ModifyCertificateAsync(
string certificateId,
global::tryAGI.OpenAI.ModifyCertificateRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Modify a certificate. Note that only the name can be modified.
@@ -23,11 +25,13 @@ public partial interface ICertificatesClient
///
/// The updated name for the certificate
///
+ /// 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 ModifyCertificateAsync(
string certificateId,
string name,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.UploadCertificate.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.UploadCertificate.g.cs
index dde56cf02..9a012e558 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.UploadCertificate.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.UploadCertificate.g.cs
@@ -9,11 +9,13 @@ public partial interface ICertificatesClient
/// Organizations can upload up to 50 certificates.
///
///
+ /// 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 UploadCertificateAsync(
global::tryAGI.OpenAI.UploadCertificateRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Upload a certificate to the organization. This does **not** automatically activate the certificate.
@@ -25,11 +27,13 @@ public partial interface ICertificatesClient
///
/// The certificate content in PEM format
///
+ /// 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 UploadCertificateAsync(
string content,
string? name = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.g.cs
index 58665df0b..59c220638 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICertificatesClient.g.cs
@@ -33,6 +33,11 @@ public partial interface ICertificatesClient : global::System.IDisposable
///
public bool ReadResponseAsString { get; set; }
+ ///
+ /// Client-wide request defaults such as headers, query parameters, retries, and timeout.
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
+
///
///
///
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IChatClient.CreateChatCompletion.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IChatClient.CreateChatCompletion.g.cs
index 7ab549fb5..bc88cd996 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IChatClient.CreateChatCompletion.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IChatClient.CreateChatCompletion.g.cs
@@ -21,11 +21,13 @@ public partial interface IChatClient
/// chunk objects if the request is streamed.
///
///
+ /// 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 CreateChatCompletionAsync(
global::tryAGI.OpenAI.CreateChatCompletionRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// **Starting a new project?** We recommend trying [Responses](/docs/api-reference/responses)
@@ -43,9 +45,11 @@ public partial interface IChatClient
/// Returns a chat completion object, or a streamed sequence of chat completion
/// chunk objects if the request is streamed.
///
+ /// 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 CreateChatCompletionAsync(
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IChatClient.CreateChatCompletionAsStream.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IChatClient.CreateChatCompletionAsStream.g.cs
index f0c009759..9ab0f61f7 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IChatClient.CreateChatCompletionAsStream.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IChatClient.CreateChatCompletionAsStream.g.cs
@@ -21,11 +21,13 @@ public partial interface IChatClient
/// chunk objects if the request is streamed.
///
///
+ /// 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 CreateChatCompletionAsStreamAsync(
global::tryAGI.OpenAI.CreateChatCompletionRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// **Starting a new project?** We recommend trying [Responses](/docs/api-reference/responses)
@@ -43,9 +45,11 @@ public partial interface IChatClient
/// Returns a chat completion object, or a streamed sequence of chat completion
/// chunk objects if the request is streamed.
///
+ /// 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 CreateChatCompletionAsStreamAsync(
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IChatClient.DeleteChatCompletion.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IChatClient.DeleteChatCompletion.g.cs
index 083f5cf76..4e5bb25c1 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IChatClient.DeleteChatCompletion.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IChatClient.DeleteChatCompletion.g.cs
@@ -9,10 +9,12 @@ public partial interface IChatClient
/// created with the `store` parameter set to `true` can be deleted.
///
///
+ /// 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 DeleteChatCompletionAsync(
string completionId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IChatClient.GetChatCompletion.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IChatClient.GetChatCompletion.g.cs
index 03fc90db9..4e7387b64 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IChatClient.GetChatCompletion.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IChatClient.GetChatCompletion.g.cs
@@ -9,10 +9,12 @@ public partial interface IChatClient
/// with the `store` parameter set to `true` will be returned.
///
///
+ /// 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 GetChatCompletionAsync(
string completionId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IChatClient.GetChatMessages.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IChatClient.GetChatMessages.g.cs
index db961ec06..6d69741d4 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IChatClient.GetChatMessages.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IChatClient.GetChatMessages.g.cs
@@ -17,6 +17,7 @@ public partial interface IChatClient
///
/// Default Value: asc
///
+ /// 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 GetChatMessagesAsync(
@@ -24,6 +25,7 @@ public partial interface IChatClient
string? after = default,
int? limit = default,
global::tryAGI.OpenAI.GetChatCompletionMessagesOrder? order = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IChatClient.ListChatCompletions.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IChatClient.ListChatCompletions.g.cs
index 03cef78ae..cfeef99b0 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IChatClient.ListChatCompletions.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IChatClient.ListChatCompletions.g.cs
@@ -17,6 +17,7 @@ public partial interface IChatClient
///
/// Default Value: asc
///
+ /// 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 ListChatCompletionsAsync(
@@ -25,6 +26,7 @@ public partial interface IChatClient
string? after = default,
int? limit = default,
global::tryAGI.OpenAI.ListChatCompletionsOrder? order = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IChatClient.UpdateChatCompletion.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IChatClient.UpdateChatCompletion.g.cs
index 0310d22a6..1cbb9a312 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IChatClient.UpdateChatCompletion.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IChatClient.UpdateChatCompletion.g.cs
@@ -11,12 +11,14 @@ public partial interface IChatClient
///
///
///
+ /// 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 UpdateChatCompletionAsync(
string completionId,
global::tryAGI.OpenAI.UpdateChatCompletionRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Modify a stored chat completion. Only Chat Completions that have been
@@ -25,11 +27,13 @@ public partial interface IChatClient
///
///
///
+ /// 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 UpdateChatCompletionAsync(
string completionId,
global::System.Collections.Generic.Dictionary? metadata = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IChatClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IChatClient.g.cs
index 9b9e64f4a..7b6477ca4 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IChatClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IChatClient.g.cs
@@ -34,6 +34,11 @@ public partial interface IChatClient : global::System.IDisposable
///
public bool ReadResponseAsString { get; set; }
+ ///
+ /// Client-wide request defaults such as headers, query parameters, retries, and timeout.
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
+
///
///
///
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICompletionsClient.CreateCompletion.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICompletionsClient.CreateCompletion.g.cs
index d340eb9a1..93690dcd9 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICompletionsClient.CreateCompletion.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICompletionsClient.CreateCompletion.g.cs
@@ -9,11 +9,13 @@ public partial interface ICompletionsClient
/// Returns a completion object, or a sequence of completion objects if the request is streamed.
///
///
+ /// 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 CreateCompletionAsync(
global::tryAGI.OpenAI.CreateCompletionRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Creates a completion for the provided prompt and parameters.
@@ -107,6 +109,7 @@ public partial interface ICompletionsClient
/// A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids).
/// Example: user-1234
///
+ /// 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 CreateCompletionAsync(
@@ -128,6 +131,7 @@ public partial interface ICompletionsClient
double? temperature = default,
double? topP = default,
string? user = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICompletionsClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICompletionsClient.g.cs
index f657ebaa5..02c7be114 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICompletionsClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.ICompletionsClient.g.cs
@@ -34,6 +34,11 @@ public partial interface ICompletionsClient : global::System.IDisposable
///
public bool ReadResponseAsString { get; set; }
+ ///
+ /// Client-wide request defaults such as headers, query parameters, retries, and timeout.
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
+
///
///
///
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.CreateAConversation.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.CreateAConversation.g.cs
index dc31d48be..d1d18c626 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.CreateAConversation.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.CreateAConversation.g.cs
@@ -8,22 +8,26 @@ public partial interface IConversationsClient
/// Create a conversation.
///
///
+ /// 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 CreateAConversationAsync(
global::tryAGI.OpenAI.CreateConversationBody request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Create a conversation.
///
///
///
+ /// 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 CreateAConversationAsync(
global::System.Collections.Generic.Dictionary? metadata = default,
global::System.Collections.Generic.IList? items = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.CreateItems.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.CreateItems.g.cs
index 68fff78a7..ca3a616d0 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.CreateItems.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.CreateItems.g.cs
@@ -12,6 +12,7 @@ public partial interface IConversationsClient
///
///
///
+ /// 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 CreateItemsAsync(
@@ -19,6 +20,7 @@ public partial interface IConversationsClient
global::tryAGI.OpenAI.CreateConversationItemsRequest request,
global::System.Collections.Generic.IList? include = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Create items in a conversation with the given ID.
@@ -30,12 +32,14 @@ public partial interface IConversationsClient
///
/// The items to add to the conversation. You may add up to 20 items at a time.
///
+ /// 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 CreateItemsAsync(
string conversationId,
global::System.Collections.Generic.IList items,
global::System.Collections.Generic.IList? include = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.DeleteAConversation.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.DeleteAConversation.g.cs
index 8fc207977..6c910142c 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.DeleteAConversation.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.DeleteAConversation.g.cs
@@ -10,10 +10,12 @@ public partial interface IConversationsClient
///
/// Example: conv_123
///
+ /// 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 DeleteAConversationAsync(
string conversationId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.DeleteAnItem.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.DeleteAnItem.g.cs
index ba91952a5..f4e78c134 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.DeleteAnItem.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.DeleteAnItem.g.cs
@@ -13,11 +13,13 @@ public partial interface IConversationsClient
///
/// Example: msg_abc
///
+ /// 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 DeleteAnItemAsync(
string conversationId,
string itemId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.ListItems.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.ListItems.g.cs
index d6bd5deba..432c85a78 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.ListItems.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.ListItems.g.cs
@@ -16,6 +16,7 @@ public partial interface IConversationsClient
///
///
///
+ /// 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 ListItemsAsync(
@@ -24,6 +25,7 @@ public partial interface IConversationsClient
global::tryAGI.OpenAI.ListConversationItemsOrder? order = default,
string? after = default,
global::System.Collections.Generic.IList? include = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.RetrieveAConversation.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.RetrieveAConversation.g.cs
index 8703768e4..b37aba48a 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.RetrieveAConversation.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.RetrieveAConversation.g.cs
@@ -10,10 +10,12 @@ public partial interface IConversationsClient
///
/// Example: conv_123
///
+ /// 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 RetrieveAConversationAsync(
string conversationId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.RetrieveAnItem.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.RetrieveAnItem.g.cs
index 7dc92faeb..5a8a5fe4d 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.RetrieveAnItem.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.RetrieveAnItem.g.cs
@@ -14,12 +14,14 @@ public partial interface IConversationsClient
/// Example: msg_abc
///
///
+ /// 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 RetrieveAnItemAsync(
string conversationId,
string itemId,
global::System.Collections.Generic.IList? include = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.UpdateAConversation.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.UpdateAConversation.g.cs
index b3565392f..b92c9e3b3 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.UpdateAConversation.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.UpdateAConversation.g.cs
@@ -11,12 +11,14 @@ public partial interface IConversationsClient
/// Example: conv_123
///
///
+ /// 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 UpdateAConversationAsync(
string conversationId,
global::tryAGI.OpenAI.UpdateConversationBody request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Update a conversation
@@ -28,11 +30,13 @@ public partial interface IConversationsClient
/// Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.
/// Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
///
+ /// 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 UpdateAConversationAsync(
string conversationId,
global::System.Collections.Generic.Dictionary? metadata = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.g.cs
index 833a97f54..038d1b53c 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IConversationsClient.g.cs
@@ -34,6 +34,11 @@ public partial interface IConversationsClient : global::System.IDisposable
///
public bool ReadResponseAsString { get; set; }
+ ///
+ /// Client-wide request defaults such as headers, query parameters, retries, and timeout.
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
+
///
///
///
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEmbeddingsClient.CreateEmbeddings.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEmbeddingsClient.CreateEmbeddings.g.cs
index 7f0fa410f..3f728c4ea 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEmbeddingsClient.CreateEmbeddings.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEmbeddingsClient.CreateEmbeddings.g.cs
@@ -8,11 +8,13 @@ public partial interface IEmbeddingsClient
/// Creates an embedding vector representing the input 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 CreateEmbeddingsAsync(
global::tryAGI.OpenAI.CreateEmbeddingRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Creates an embedding vector representing the input text.
@@ -37,6 +39,7 @@ public partial interface IEmbeddingsClient
/// A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids).
/// Example: user-1234
///
+ /// 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 CreateEmbeddingsAsync(
@@ -45,6 +48,7 @@ public partial interface IEmbeddingsClient
global::tryAGI.OpenAI.CreateEmbeddingRequestEncodingFormat? encodingFormat = default,
int? dimensions = default,
string? user = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEmbeddingsClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEmbeddingsClient.g.cs
index 599f4d96a..d43561a92 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEmbeddingsClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEmbeddingsClient.g.cs
@@ -34,6 +34,11 @@ public partial interface IEmbeddingsClient : global::System.IDisposable
///
public bool ReadResponseAsString { get; set; }
+ ///
+ /// Client-wide request defaults such as headers, query parameters, retries, and timeout.
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
+
///
///
///
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.CancelEvalRun.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.CancelEvalRun.g.cs
index 817ce7856..8da893ef8 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.CancelEvalRun.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.CancelEvalRun.g.cs
@@ -9,11 +9,13 @@ public partial interface IEvalsClient
///
///
///
+ /// 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 CancelEvalRunAsync(
string evalId,
string runId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.CreateEval.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.CreateEval.g.cs
index 8e058a481..b9ef75dab 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.CreateEval.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.CreateEval.g.cs
@@ -12,11 +12,13 @@ public partial interface IEvalsClient
/// For more information, see the [Evals guide](/docs/guides/evals).
///
///
+ /// 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 CreateEvalAsync(
global::tryAGI.OpenAI.CreateEvalRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Create the structure of an evaluation that can be used to test a model's performance.
@@ -33,6 +35,7 @@ public partial interface IEvalsClient
///
/// A list of graders for all eval runs in this group. Graders can reference variables in the data source using double curly braces notation, like `{{item.variable_name}}`. To reference the model's output, use the `sample` namespace (ie, `{{sample.output_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 CreateEvalAsync(
@@ -42,6 +45,7 @@ public partial interface IEvalsClient
global::System.Collections.Generic.IList> testingCriteria,
string? name = default,
global::System.Collections.Generic.Dictionary? metadata = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.CreateEvalRun.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.CreateEvalRun.g.cs
index 9327ffb3b..80f921b61 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.CreateEvalRun.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.CreateEvalRun.g.cs
@@ -9,12 +9,14 @@ public partial interface IEvalsClient
///
///
///
+ /// 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 CreateEvalRunAsync(
string evalId,
global::tryAGI.OpenAI.CreateEvalRunRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Kicks off a new run for a given evaluation, specifying the data source, and what model configuration to use to test. The datasource will be validated against the schema specified in the config of the evaluation.
@@ -27,6 +29,7 @@ public partial interface IEvalsClient
///
/// Details about the run's data source.
///
+ /// 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 CreateEvalRunAsync(
@@ -34,6 +37,7 @@ public partial interface IEvalsClient
global::tryAGI.OpenAI.OneOf dataSource,
string? name = default,
global::System.Collections.Generic.Dictionary? metadata = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.DeleteAnEval.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.DeleteAnEval.g.cs
index e7bd75b3f..a2699261b 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.DeleteAnEval.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.DeleteAnEval.g.cs
@@ -8,10 +8,12 @@ public partial interface IEvalsClient
/// Delete an 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 DeleteAnEvalAsync(
string evalId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.DeleteEvalRun.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.DeleteEvalRun.g.cs
index 3a8df6871..e6b8b7541 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.DeleteEvalRun.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.DeleteEvalRun.g.cs
@@ -9,11 +9,13 @@ public partial interface IEvalsClient
///
///
///
+ /// 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 DeleteEvalRunAsync(
string evalId,
string runId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.GetAnEval.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.GetAnEval.g.cs
index 3f7f23303..2b97b178a 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.GetAnEval.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.GetAnEval.g.cs
@@ -8,10 +8,12 @@ public partial interface IEvalsClient
/// Get an evaluation by 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 GetAnEvalAsync(
string evalId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.GetAnEvalRun.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.GetAnEvalRun.g.cs
index 09e1c4931..7c4245b2a 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.GetAnEvalRun.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.GetAnEvalRun.g.cs
@@ -9,11 +9,13 @@ public partial interface IEvalsClient
///
///
///
+ /// 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 GetAnEvalRunAsync(
string evalId,
string runId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.GetAnOutputItemOfAnEvalRun.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.GetAnOutputItemOfAnEvalRun.g.cs
index ab479192a..c05bdeb9b 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.GetAnOutputItemOfAnEvalRun.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.GetAnOutputItemOfAnEvalRun.g.cs
@@ -10,12 +10,14 @@ public partial interface IEvalsClient
///
///
///
+ /// 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 GetAnOutputItemOfAnEvalRunAsync(
string evalId,
string runId,
string outputItemId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.GetEvalRunOutputItems.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.GetEvalRunOutputItems.g.cs
index f3c7d6f2c..ead789b86 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.GetEvalRunOutputItems.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.GetEvalRunOutputItems.g.cs
@@ -17,6 +17,7 @@ public partial interface IEvalsClient
///
/// Default Value: asc
///
+ /// 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 GetEvalRunOutputItemsAsync(
@@ -26,6 +27,7 @@ public partial interface IEvalsClient
int? limit = default,
global::tryAGI.OpenAI.GetEvalRunOutputItemsStatus? status = default,
global::tryAGI.OpenAI.GetEvalRunOutputItemsOrder? order = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.GetEvalRuns.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.GetEvalRuns.g.cs
index 5604666f6..afe6c66db 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.GetEvalRuns.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.GetEvalRuns.g.cs
@@ -16,6 +16,7 @@ public partial interface IEvalsClient
/// Default Value: asc
///
///
+ /// 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 GetEvalRunsAsync(
@@ -24,6 +25,7 @@ public partial interface IEvalsClient
int? limit = default,
global::tryAGI.OpenAI.GetEvalRunsOrder? order = default,
global::tryAGI.OpenAI.GetEvalRunsStatus? status = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.ListEvals.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.ListEvals.g.cs
index eaad65eef..285fd8e7a 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.ListEvals.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.ListEvals.g.cs
@@ -17,6 +17,7 @@ public partial interface IEvalsClient
///
/// Default Value: created_at
///
+ /// 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 ListEvalsAsync(
@@ -24,6 +25,7 @@ public partial interface IEvalsClient
int? limit = default,
global::tryAGI.OpenAI.ListEvalsOrder? order = default,
global::tryAGI.OpenAI.ListEvalsOrderBy? orderBy = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.UpdateAnEval.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.UpdateAnEval.g.cs
index d23444dd7..ee96e5915 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.UpdateAnEval.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.UpdateAnEval.g.cs
@@ -9,12 +9,14 @@ public partial interface IEvalsClient
///
///
///
+ /// 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 UpdateAnEvalAsync(
string evalId,
global::tryAGI.OpenAI.UpdateEvalRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Update certain properties of an evaluation.
@@ -24,12 +26,14 @@ public partial interface IEvalsClient
/// Rename 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 UpdateAnEvalAsync(
string evalId,
string? name = default,
global::System.Collections.Generic.Dictionary? metadata = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.g.cs
index dff056f90..a16fbbb63 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IEvalsClient.g.cs
@@ -34,6 +34,11 @@ public partial interface IEvalsClient : global::System.IDisposable
///
public bool ReadResponseAsString { get; set; }
+ ///
+ /// Client-wide request defaults such as headers, query parameters, retries, and timeout.
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
+
///
///
///
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFilesClient.DeleteFile.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFilesClient.DeleteFile.g.cs
index 7b3346432..2ece6017c 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFilesClient.DeleteFile.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFilesClient.DeleteFile.g.cs
@@ -8,10 +8,12 @@ public partial interface IFilesClient
/// Delete a file and remove it from all vector stores.
///
///
+ /// 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 DeleteFileAsync(
string fileId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFilesClient.ListFiles.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFilesClient.ListFiles.g.cs
index 054b0179b..fbfea807f 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFilesClient.ListFiles.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFilesClient.ListFiles.g.cs
@@ -15,6 +15,7 @@ public partial interface IFilesClient
/// Default Value: desc
///
///
+ /// 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 ListFilesAsync(
@@ -22,6 +23,7 @@ public partial interface IFilesClient
int? limit = default,
global::tryAGI.OpenAI.ListFilesOrder? order = default,
string? after = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFilesClient.RetrieveFile.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFilesClient.RetrieveFile.g.cs
index d85880179..816006fdf 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFilesClient.RetrieveFile.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFilesClient.RetrieveFile.g.cs
@@ -8,10 +8,12 @@ public partial interface IFilesClient
/// Returns information about a specific file.
///
///
+ /// 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 RetrieveFileAsync(
string fileId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFilesClient.RetrieveFileContent.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFilesClient.RetrieveFileContent.g.cs
index 40d8c8aef..30b0ec9d6 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFilesClient.RetrieveFileContent.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFilesClient.RetrieveFileContent.g.cs
@@ -8,10 +8,12 @@ public partial interface IFilesClient
/// Returns the contents of the specified file.
///
///
+ /// 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 RetrieveFileContentAsync(
string fileId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFilesClient.UploadFile.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFilesClient.UploadFile.g.cs
index 7a46eaa6a..fc9984c03 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFilesClient.UploadFile.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFilesClient.UploadFile.g.cs
@@ -22,11 +22,13 @@ public partial interface IFilesClient
/// storage limits.
///
///
+ /// 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 UploadFileAsync(
global::tryAGI.OpenAI.CreateFileRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Upload a file that can be used across various endpoints. Individual files
@@ -63,6 +65,7 @@ public partial interface IFilesClient
///
/// The expiration policy for a file. By default, files with `purpose=batch` expire after 30 days and all other files are persisted until they are manually deleted.
///
+ /// 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 UploadFileAsync(
@@ -70,6 +73,7 @@ public partial interface IFilesClient
string filename,
global::tryAGI.OpenAI.CreateFileRequestPurpose purpose,
global::tryAGI.OpenAI.FileExpirationAfter? expiresAfter = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFilesClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFilesClient.g.cs
index 9d41cc7c7..5d70af5e2 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFilesClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFilesClient.g.cs
@@ -34,6 +34,11 @@ public partial interface IFilesClient : global::System.IDisposable
///
public bool ReadResponseAsString { get; set; }
+ ///
+ /// Client-wide request defaults such as headers, query parameters, retries, and timeout.
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
+
///
///
///
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.CancelFineTuning.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.CancelFineTuning.g.cs
index a2d4fc7aa..e188a2ccc 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.CancelFineTuning.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.CancelFineTuning.g.cs
@@ -10,10 +10,12 @@ public partial interface IFineTuningClient
///
/// Example: ft-AF1WoRqd3aJAHsqc9NY7iL8F
///
+ /// 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 CancelFineTuningAsync(
string fineTuningJobId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.CreateCheckpointPermissions.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.CreateCheckpointPermissions.g.cs
index 0a69985e9..9a1bb9458 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.CreateCheckpointPermissions.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.CreateCheckpointPermissions.g.cs
@@ -12,12 +12,14 @@ public partial interface IFineTuningClient
/// Example: ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd
///
///
+ /// 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 CreateCheckpointPermissionsAsync(
string fineTunedModelCheckpoint,
global::tryAGI.OpenAI.CreateFineTuningCheckpointPermissionRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// **NOTE:** Calling this endpoint requires an [admin API key](../admin-api-keys).
@@ -29,11 +31,13 @@ public partial interface IFineTuningClient
///
/// The project identifiers to grant access 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 CreateCheckpointPermissionsAsync(
string fineTunedModelCheckpoint,
global::System.Collections.Generic.IList projectIds,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.CreateFineTuningJob.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.CreateFineTuningJob.g.cs
index e6db11a1d..d7ac5f223 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.CreateFineTuningJob.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.CreateFineTuningJob.g.cs
@@ -12,11 +12,13 @@ public partial interface IFineTuningClient
/// [Learn more about fine-tuning](/docs/guides/model-optimization)
///
///
+ /// 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 CreateFineTuningJobAsync(
global::tryAGI.OpenAI.CreateFineTuningJobRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Creates a fine-tuning job which begins the process of creating a new model from a given dataset.
@@ -63,6 +65,7 @@ public partial interface IFineTuningClient
/// The method used for fine-tuning.
///
///
+ /// 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 CreateFineTuningJobAsync(
@@ -74,6 +77,7 @@ public partial interface IFineTuningClient
int? seed = default,
global::tryAGI.OpenAI.FineTuneMethod? method = default,
global::System.Collections.Generic.Dictionary? metadata = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.DeleteCheckpointPermission.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.DeleteCheckpointPermission.g.cs
index ad02907f4..3eb6d69c1 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.DeleteCheckpointPermission.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.DeleteCheckpointPermission.g.cs
@@ -14,11 +14,13 @@ public partial interface IFineTuningClient
///
/// Example: cp_zc4Q7MP6XxulcVzj4MZdwsAB
///
+ /// 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 DeleteCheckpointPermissionAsync(
string fineTunedModelCheckpoint,
string permissionId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.ListCheckpointPermissions.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.ListCheckpointPermissions.g.cs
index d7f641dcc..816cf88d6 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.ListCheckpointPermissions.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.ListCheckpointPermissions.g.cs
@@ -19,6 +19,7 @@ public partial interface IFineTuningClient
///
/// Default Value: descending
///
+ /// 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 ListCheckpointPermissionsAsync(
@@ -27,6 +28,7 @@ public partial interface IFineTuningClient
string? after = default,
int? limit = default,
global::tryAGI.OpenAI.ListFineTuningCheckpointPermissionsOrder? order = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.ListFineTuningCheckpoints.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.ListFineTuningCheckpoints.g.cs
index 18db8ad00..6ce3856c3 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.ListFineTuningCheckpoints.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.ListFineTuningCheckpoints.g.cs
@@ -14,12 +14,14 @@ public partial interface IFineTuningClient
///
/// Default Value: 10
///
+ /// 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 ListFineTuningCheckpointsAsync(
string fineTuningJobId,
string? after = default,
int? limit = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.ListFineTuningEvents.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.ListFineTuningEvents.g.cs
index 1663cbec7..046250b5a 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.ListFineTuningEvents.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.ListFineTuningEvents.g.cs
@@ -14,12 +14,14 @@ public partial interface IFineTuningClient
///
/// Default Value: 20
///
+ /// 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 ListFineTuningEventsAsync(
string fineTuningJobId,
string? after = default,
int? limit = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.ListFineTuningJobs.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.ListFineTuningJobs.g.cs
index 058ef1f2d..b9d1f960f 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.ListFineTuningJobs.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.ListFineTuningJobs.g.cs
@@ -12,12 +12,14 @@ public partial interface IFineTuningClient
/// Default Value: 20
///
///
+ /// 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 ListFineTuningJobsAsync(
string? after = default,
int? limit = default,
global::System.Collections.Generic.Dictionary? metadata = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.PauseFineTuning.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.PauseFineTuning.g.cs
index 3d697e90a..346ddd151 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.PauseFineTuning.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.PauseFineTuning.g.cs
@@ -10,10 +10,12 @@ public partial interface IFineTuningClient
///
/// Example: ft-AF1WoRqd3aJAHsqc9NY7iL8F
///
+ /// 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 PauseFineTuningAsync(
string fineTuningJobId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.ResumeFineTuning.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.ResumeFineTuning.g.cs
index 2ba8354c4..6ba4401aa 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.ResumeFineTuning.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.ResumeFineTuning.g.cs
@@ -10,10 +10,12 @@ public partial interface IFineTuningClient
///
/// Example: ft-AF1WoRqd3aJAHsqc9NY7iL8F
///
+ /// 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 ResumeFineTuningAsync(
string fineTuningJobId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.RetrieveFineTuningJob.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.RetrieveFineTuningJob.g.cs
index 9295fde5e..73cdfb1c5 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.RetrieveFineTuningJob.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.RetrieveFineTuningJob.g.cs
@@ -11,10 +11,12 @@ public partial interface IFineTuningClient
///
/// Example: ft-AF1WoRqd3aJAHsqc9NY7iL8F
///
+ /// 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 RetrieveFineTuningJobAsync(
string fineTuningJobId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.RunGrader.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.RunGrader.g.cs
index e3ce616ea..c7c23e234 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.RunGrader.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.RunGrader.g.cs
@@ -8,11 +8,13 @@ public partial interface IFineTuningClient
/// Run a grader.
///
///
+ /// 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 RunGraderAsync(
global::tryAGI.OpenAI.RunGraderRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Run a grader.
@@ -31,12 +33,14 @@ public partial interface IFineTuningClient
/// valid JSON string.
///
///
+ /// 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 RunGraderAsync(
global::tryAGI.OpenAI.OneOf grader,
string modelSample,
object? item = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.ValidateGrader.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.ValidateGrader.g.cs
index 7394fdcbe..0899472fa 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.ValidateGrader.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.ValidateGrader.g.cs
@@ -8,11 +8,13 @@ public partial interface IFineTuningClient
/// Validate a grader.
///
///
+ /// 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 ValidateGraderAsync(
global::tryAGI.OpenAI.ValidateGraderRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Validate a grader.
@@ -20,10 +22,12 @@ public partial interface IFineTuningClient
///
/// The grader used for the 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 ValidateGraderAsync(
global::tryAGI.OpenAI.OneOf grader,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.g.cs
index c1e9e70d6..bcfb25147 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IFineTuningClient.g.cs
@@ -34,6 +34,11 @@ public partial interface IFineTuningClient : global::System.IDisposable
///
public bool ReadResponseAsString { get; set; }
+ ///
+ /// Client-wide request defaults such as headers, query parameters, retries, and timeout.
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
+
///
///
///
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupOrganizationRoleAssignmentsClient.AssignOrganizationRoleToGroup.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupOrganizationRoleAssignmentsClient.AssignOrganizationRoleToGroup.g.cs
index 060d81a68..433790181 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupOrganizationRoleAssignmentsClient.AssignOrganizationRoleToGroup.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupOrganizationRoleAssignmentsClient.AssignOrganizationRoleToGroup.g.cs
@@ -9,12 +9,14 @@ public partial interface IGroupOrganizationRoleAssignmentsClient
///
///
///
+ /// 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 AssignOrganizationRoleToGroupAsync(
string groupId,
global::tryAGI.OpenAI.PublicAssignOrganizationGroupRoleBody request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Assigns an organization role to a group within the organization.
@@ -23,11 +25,13 @@ public partial interface IGroupOrganizationRoleAssignmentsClient
///
/// Identifier of the role to assign.
///
+ /// 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 AssignOrganizationRoleToGroupAsync(
string groupId,
string roleId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupOrganizationRoleAssignmentsClient.ListGroupOrganizationRoleAssignments.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupOrganizationRoleAssignmentsClient.ListGroupOrganizationRoleAssignments.g.cs
index 9cf0a2841..9069508d9 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupOrganizationRoleAssignmentsClient.ListGroupOrganizationRoleAssignments.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupOrganizationRoleAssignmentsClient.ListGroupOrganizationRoleAssignments.g.cs
@@ -11,6 +11,7 @@ public partial interface IGroupOrganizationRoleAssignmentsClient
///
///
///
+ /// 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 ListGroupOrganizationRoleAssignmentsAsync(
@@ -18,6 +19,7 @@ public partial interface IGroupOrganizationRoleAssignmentsClient
int? limit = default,
string? after = default,
global::tryAGI.OpenAI.ListGroupRoleAssignmentsOrder? order = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupOrganizationRoleAssignmentsClient.UnassignOrganizationRoleFromGroup.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupOrganizationRoleAssignmentsClient.UnassignOrganizationRoleFromGroup.g.cs
index 07a453235..bfe43cedc 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupOrganizationRoleAssignmentsClient.UnassignOrganizationRoleFromGroup.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupOrganizationRoleAssignmentsClient.UnassignOrganizationRoleFromGroup.g.cs
@@ -9,11 +9,13 @@ public partial interface IGroupOrganizationRoleAssignmentsClient
///
///
///
+ /// 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 UnassignOrganizationRoleFromGroupAsync(
string groupId,
string roleId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupOrganizationRoleAssignmentsClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupOrganizationRoleAssignmentsClient.g.cs
index 1e926c20b..1e55b126e 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupOrganizationRoleAssignmentsClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupOrganizationRoleAssignmentsClient.g.cs
@@ -33,6 +33,11 @@ public partial interface IGroupOrganizationRoleAssignmentsClient : global::Syste
///
public bool ReadResponseAsString { get; set; }
+ ///
+ /// Client-wide request defaults such as headers, query parameters, retries, and timeout.
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
+
///
///
///
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupUsersClient.AddGroupUser.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupUsersClient.AddGroupUser.g.cs
index b9f485eaf..99e2d7bf6 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupUsersClient.AddGroupUser.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupUsersClient.AddGroupUser.g.cs
@@ -9,12 +9,14 @@ public partial interface IGroupUsersClient
///
///
///
+ /// 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 AddGroupUserAsync(
string groupId,
global::tryAGI.OpenAI.CreateGroupUserBody request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Adds a user to a group.
@@ -23,11 +25,13 @@ public partial interface IGroupUsersClient
///
/// Identifier of the user to add to the group.
///
+ /// 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 AddGroupUserAsync(
string groupId,
string userId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupUsersClient.ListGroupUsers.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupUsersClient.ListGroupUsers.g.cs
index 20dd983b1..0ab813efc 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupUsersClient.ListGroupUsers.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupUsersClient.ListGroupUsers.g.cs
@@ -15,6 +15,7 @@ public partial interface IGroupUsersClient
///
/// Default Value: desc
///
+ /// 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 ListGroupUsersAsync(
@@ -22,6 +23,7 @@ public partial interface IGroupUsersClient
int? limit = default,
string? after = default,
global::tryAGI.OpenAI.ListGroupUsersOrder? order = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupUsersClient.RemoveGroupUser.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupUsersClient.RemoveGroupUser.g.cs
index d948e7237..984ad51a9 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupUsersClient.RemoveGroupUser.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupUsersClient.RemoveGroupUser.g.cs
@@ -9,11 +9,13 @@ public partial interface IGroupUsersClient
///
///
///
+ /// 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 RemoveGroupUserAsync(
string groupId,
string userId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupUsersClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupUsersClient.g.cs
index 01d496190..a2283513c 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupUsersClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupUsersClient.g.cs
@@ -33,6 +33,11 @@ public partial interface IGroupUsersClient : global::System.IDisposable
///
public bool ReadResponseAsString { get; set; }
+ ///
+ /// Client-wide request defaults such as headers, query parameters, retries, and timeout.
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
+
///
///
///
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupsClient.CreateGroup.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupsClient.CreateGroup.g.cs
index c8afc8feb..14629e3b5 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupsClient.CreateGroup.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupsClient.CreateGroup.g.cs
@@ -8,11 +8,13 @@ public partial interface IGroupsClient
/// Creates a new group in the organization.
///
///
+ /// 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 CreateGroupAsync(
global::tryAGI.OpenAI.CreateGroupBody request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Creates a new group in the organization.
@@ -20,10 +22,12 @@ public partial interface IGroupsClient
///
/// Human readable name for the group.
///
+ /// 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 CreateGroupAsync(
string name,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupsClient.DeleteGroup.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupsClient.DeleteGroup.g.cs
index 3f5375468..9d96c3c39 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupsClient.DeleteGroup.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupsClient.DeleteGroup.g.cs
@@ -8,10 +8,12 @@ public partial interface IGroupsClient
/// Deletes a group from the organization.
///
///
+ /// 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 DeleteGroupAsync(
string groupId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupsClient.ListGroups.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupsClient.ListGroups.g.cs
index 3d922f987..1098ccdd8 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupsClient.ListGroups.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupsClient.ListGroups.g.cs
@@ -14,12 +14,14 @@ public partial interface IGroupsClient
///
/// Default Value: asc
///
+ /// 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 ListGroupsAsync(
int? limit = default,
string? after = default,
global::tryAGI.OpenAI.ListGroupsOrder? order = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupsClient.UpdateGroup.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupsClient.UpdateGroup.g.cs
index 494878454..1d94dbc1e 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupsClient.UpdateGroup.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupsClient.UpdateGroup.g.cs
@@ -9,12 +9,14 @@ public partial interface IGroupsClient
///
///
///
+ /// 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 UpdateGroupAsync(
string groupId,
global::tryAGI.OpenAI.UpdateGroupBody request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Updates a group's information.
@@ -23,11 +25,13 @@ public partial interface IGroupsClient
///
/// New display name for the group.
///
+ /// 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 UpdateGroupAsync(
string groupId,
string name,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupsClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupsClient.g.cs
index 089922fc7..337616ecb 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupsClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IGroupsClient.g.cs
@@ -33,6 +33,11 @@ public partial interface IGroupsClient : global::System.IDisposable
///
public bool ReadResponseAsString { get; set; }
+ ///
+ /// Client-wide request defaults such as headers, query parameters, retries, and timeout.
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
+
///
///
///
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IImagesClient.CreateImage.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IImagesClient.CreateImage.g.cs
index bb9609bf0..0baf960cd 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IImagesClient.CreateImage.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IImagesClient.CreateImage.g.cs
@@ -8,11 +8,13 @@ public partial interface IImagesClient
/// Creates an image given a prompt. [Learn more](/docs/guides/images).
///
///
+ /// 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 CreateImageAsync(
global::tryAGI.OpenAI.CreateImageRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Creates an image given a prompt. [Learn more](/docs/guides/images).
@@ -85,6 +87,7 @@ public partial interface IImagesClient
/// A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids).
/// Example: user-1234
///
+ /// 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 CreateImageAsync(
@@ -101,6 +104,7 @@ public partial interface IImagesClient
global::tryAGI.OpenAI.CreateImageRequestBackground? background = default,
global::tryAGI.OpenAI.CreateImageRequestStyle? style = default,
string? user = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IImagesClient.CreateImageAsStream.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IImagesClient.CreateImageAsStream.g.cs
index f93965b53..4068b2094 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IImagesClient.CreateImageAsStream.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IImagesClient.CreateImageAsStream.g.cs
@@ -8,11 +8,13 @@ public partial interface IImagesClient
/// Creates an image given a prompt. [Learn more](/docs/guides/images).
///
///
+ /// 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 CreateImageAsStreamAsync(
global::tryAGI.OpenAI.CreateImageRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Creates an image given a prompt. [Learn more](/docs/guides/images).
@@ -85,6 +87,7 @@ public partial interface IImagesClient
/// A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids).
/// Example: user-1234
///
+ /// 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 CreateImageAsStreamAsync(
@@ -101,6 +104,7 @@ public partial interface IImagesClient
global::tryAGI.OpenAI.CreateImageRequestBackground? background = default,
global::tryAGI.OpenAI.CreateImageRequestStyle? style = default,
string? user = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IImagesClient.CreateImageEdit.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IImagesClient.CreateImageEdit.g.cs
index 0f3d78a39..d16e0b958 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IImagesClient.CreateImageEdit.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IImagesClient.CreateImageEdit.g.cs
@@ -12,11 +12,13 @@ public partial interface IImagesClient
/// Note that JSON requests use `images` (array) instead of the multipart `image` field.
///
///
+ /// 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 CreateImageEditAsync(
global::tryAGI.OpenAI.CreateImageEditRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Creates an edited or extended image given one or more source images and a prompt. This endpoint supports GPT Image models (`gpt-image-1.5`, `gpt-image-1`, `gpt-image-1-mini`, and `chatgpt-image-latest`) and `dall-e-2`.
@@ -97,6 +99,7 @@ public partial interface IImagesClient
/// Default Value: auto
/// Example: high
///
+ /// 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 CreateImageEditAsync(
@@ -115,6 +118,7 @@ public partial interface IImagesClient
global::tryAGI.OpenAI.InputFidelity? inputFidelity = default,
int? partialImages = default,
global::tryAGI.OpenAI.CreateImageEditRequestQuality? quality = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IImagesClient.CreateImageEditAsStream.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IImagesClient.CreateImageEditAsStream.g.cs
index ecacd3be1..34e64529e 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IImagesClient.CreateImageEditAsStream.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IImagesClient.CreateImageEditAsStream.g.cs
@@ -12,11 +12,13 @@ public partial interface IImagesClient
/// Note that JSON requests use `images` (array) instead of the multipart `image` field.
///
///
+ /// 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 CreateImageEditAsStreamAsync(
global::tryAGI.OpenAI.CreateImageEditRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Creates an edited or extended image given one or more source images and a prompt. This endpoint supports GPT Image models (`gpt-image-1.5`, `gpt-image-1`, `gpt-image-1-mini`, and `chatgpt-image-latest`) and `dall-e-2`.
@@ -97,6 +99,7 @@ public partial interface IImagesClient
/// Default Value: auto
/// Example: high
///
+ /// 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 CreateImageEditAsStreamAsync(
@@ -115,6 +118,7 @@ public partial interface IImagesClient
global::tryAGI.OpenAI.InputFidelity? inputFidelity = default,
int? partialImages = default,
global::tryAGI.OpenAI.CreateImageEditRequestQuality? quality = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IImagesClient.CreateImageVariation.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IImagesClient.CreateImageVariation.g.cs
index 4d9e18355..f255ff2f5 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IImagesClient.CreateImageVariation.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IImagesClient.CreateImageVariation.g.cs
@@ -8,11 +8,13 @@ public partial interface IImagesClient
/// Creates a variation of a given image. This endpoint only supports `dall-e-2`.
///
///
+ /// 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 CreateImageVariationAsync(
global::tryAGI.OpenAI.CreateImageVariationRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Creates a variation of a given image. This endpoint only supports `dall-e-2`.
@@ -47,6 +49,7 @@ public partial interface IImagesClient
/// A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids).
/// Example: user-1234
///
+ /// 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 CreateImageVariationAsync(
@@ -57,6 +60,7 @@ public partial interface IImagesClient
global::tryAGI.OpenAI.CreateImageVariationRequestResponseFormat? responseFormat = default,
global::tryAGI.OpenAI.CreateImageVariationRequestSize? size = default,
string? user = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IImagesClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IImagesClient.g.cs
index 9930dcb0c..29fceadb3 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IImagesClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IImagesClient.g.cs
@@ -34,6 +34,11 @@ public partial interface IImagesClient : global::System.IDisposable
///
public bool ReadResponseAsString { get; set; }
+ ///
+ /// Client-wide request defaults such as headers, query parameters, retries, and timeout.
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
+
///
///
///
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IInvitesClient.CreateInvite.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IInvitesClient.CreateInvite.g.cs
index aa235e747..2340121d1 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IInvitesClient.CreateInvite.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IInvitesClient.CreateInvite.g.cs
@@ -8,11 +8,13 @@ public partial interface IInvitesClient
/// Create an invite for a user to the organization. The invite must be accepted by the user before they have access to the organization.
///
///
+ /// 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 CreateInviteAsync(
global::tryAGI.OpenAI.InviteRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Create an invite for a user to the organization. The invite must be accepted by the user before they have access to the organization.
@@ -26,12 +28,14 @@ public partial interface IInvitesClient
///
/// An array of projects to which membership is granted at the same time the org invite is accepted. If omitted, the user will be invited to the default project for compatibility with legacy behavior.
///
+ /// 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 CreateInviteAsync(
string email,
global::tryAGI.OpenAI.InviteRequestRole role,
global::System.Collections.Generic.IList? projects = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IInvitesClient.DeleteInvite.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IInvitesClient.DeleteInvite.g.cs
index dabf96276..e8d546adf 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IInvitesClient.DeleteInvite.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IInvitesClient.DeleteInvite.g.cs
@@ -8,10 +8,12 @@ public partial interface IInvitesClient
/// Delete an invite. If the invite has already been accepted, it cannot be deleted.
///
///
+ /// 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 DeleteInviteAsync(
string inviteId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IInvitesClient.ListInvites.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IInvitesClient.ListInvites.g.cs
index e38e80061..8a940b5c1 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IInvitesClient.ListInvites.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IInvitesClient.ListInvites.g.cs
@@ -11,11 +11,13 @@ public partial interface IInvitesClient
/// Default Value: 20
///
///
+ /// 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 ListInvitesAsync(
int? limit = default,
string? after = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IInvitesClient.RetrieveInvite.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IInvitesClient.RetrieveInvite.g.cs
index 16feba69c..87d027725 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IInvitesClient.RetrieveInvite.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IInvitesClient.RetrieveInvite.g.cs
@@ -8,10 +8,12 @@ public partial interface IInvitesClient
/// Retrieves an invite.
///
///
+ /// 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 RetrieveInviteAsync(
string inviteId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IInvitesClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IInvitesClient.g.cs
index b0d6c04bb..f604df3cb 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IInvitesClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IInvitesClient.g.cs
@@ -33,6 +33,11 @@ public partial interface IInvitesClient : global::System.IDisposable
///
public bool ReadResponseAsString { get; set; }
+ ///
+ /// Client-wide request defaults such as headers, query parameters, retries, and timeout.
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
+
///
///
///
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IModelsClient.DeleteAFineTunedModel.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IModelsClient.DeleteAFineTunedModel.g.cs
index 60115310d..070e16d09 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IModelsClient.DeleteAFineTunedModel.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IModelsClient.DeleteAFineTunedModel.g.cs
@@ -10,10 +10,12 @@ public partial interface IModelsClient
///
/// Example: ft:gpt-4o-mini:acemeco:suffix:abc123
///
+ /// 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 DeleteAFineTunedModelAsync(
string model,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IModelsClient.ListModels.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IModelsClient.ListModels.g.cs
index 67a9e8b88..36031e2aa 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IModelsClient.ListModels.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IModelsClient.ListModels.g.cs
@@ -7,9 +7,11 @@ public partial interface IModelsClient
///
/// Lists the currently available models, and provides basic information about each one such as the owner and availability.
///
+ /// 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 ListModelsAsync(
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IModelsClient.RetrieveModel.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IModelsClient.RetrieveModel.g.cs
index 04d3c40bc..b8bcb8b44 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IModelsClient.RetrieveModel.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IModelsClient.RetrieveModel.g.cs
@@ -10,10 +10,12 @@ public partial interface IModelsClient
///
/// Example: gpt-4o-mini
///
+ /// 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 RetrieveModelAsync(
string model,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IModelsClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IModelsClient.g.cs
index c77e2acef..b879742cb 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IModelsClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IModelsClient.g.cs
@@ -34,6 +34,11 @@ public partial interface IModelsClient : global::System.IDisposable
///
public bool ReadResponseAsString { get; set; }
+ ///
+ /// Client-wide request defaults such as headers, query parameters, retries, and timeout.
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
+
///
///
///
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IModerationsClient.CreateModeration.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IModerationsClient.CreateModeration.g.cs
index f43a5f139..5dfe9a3d2 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IModerationsClient.CreateModeration.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IModerationsClient.CreateModeration.g.cs
@@ -9,11 +9,13 @@ public partial interface IModerationsClient
/// more in the [moderation guide](/docs/guides/moderation).
///
///
+ /// 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 CreateModerationAsync(
global::tryAGI.OpenAI.CreateModerationRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Classifies if text and/or image inputs are potentially harmful. Learn
@@ -30,11 +32,13 @@ public partial interface IModerationsClient
/// Default Value: omni-moderation-latest
/// Example: omni-moderation-2024-09-26
///
+ /// 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 CreateModerationAsync(
global::tryAGI.OpenAI.OneOf, global::System.Collections.Generic.IList>> input,
global::tryAGI.OpenAI.AnyOf? model = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IModerationsClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IModerationsClient.g.cs
index 0b8ed4c14..2eac39cce 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IModerationsClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IModerationsClient.g.cs
@@ -34,6 +34,11 @@ public partial interface IModerationsClient : global::System.IDisposable
///
public bool ReadResponseAsString { get; set; }
+ ///
+ /// Client-wide request defaults such as headers, query parameters, retries, and timeout.
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
+
///
///
///
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.CancelChatSession.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.CancelChatSession.g.cs
index 12744074d..a520d22a6 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.CancelChatSession.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.CancelChatSession.g.cs
@@ -11,10 +11,12 @@ public partial interface IOpenAiClient
///
/// Example: cksess_123
///
+ /// 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 CancelChatSessionAsync(
string sessionId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.CompactAResponse.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.CompactAResponse.g.cs
index 6d62b3ea7..fa09a41d9 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.CompactAResponse.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.CompactAResponse.g.cs
@@ -9,11 +9,13 @@ public partial interface IOpenAiClient
/// Learn when and how to compact long-running conversations in the [conversation state guide](/docs/guides/conversation-state#managing-the-context-window). For ZDR-compatible compaction details, see [Compaction (advanced)](/docs/guides/conversation-state#compaction-advanced).
///
///
+ /// 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 CompactAResponseAsync(
global::tryAGI.OpenAI.CompactResponseMethodPublicBody request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Compact a conversation. Returns a compacted response object.
@@ -26,6 +28,7 @@ public partial interface IOpenAiClient
///
///
///
+ /// 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 CompactAResponseAsync(
@@ -34,6 +37,7 @@ public partial interface IOpenAiClient
string? previousResponseId = default,
string? instructions = default,
string? promptCacheKey = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.CreateAdminApiKey.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.CreateAdminApiKey.g.cs
index cef1eab57..3c5192a3e 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.CreateAdminApiKey.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.CreateAdminApiKey.g.cs
@@ -9,11 +9,13 @@ public partial interface IOpenAiClient
/// Create a new admin-level API key for the organization.
///
///
+ /// 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 CreateAdminApiKeyAsync(
global::tryAGI.OpenAI.AdminApiKeysCreateRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Create an organization admin API key
@@ -22,10 +24,12 @@ public partial interface IOpenAiClient
///
/// Example: New Admin Key
///
+ /// 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 CreateAdminApiKeyAsync(
string name,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.CreateChatKitSession.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.CreateChatKitSession.g.cs
index c641db999..7fb0d5663 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.CreateChatKitSession.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.CreateChatKitSession.g.cs
@@ -8,11 +8,13 @@ public partial interface IOpenAiClient
/// Create a ChatKit 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 CreateChatKitSessionAsync(
global::tryAGI.OpenAI.CreateChatSessionBody request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Create a ChatKit session.
@@ -32,6 +34,7 @@ public partial interface IOpenAiClient
///
/// Optional overrides for ChatKit runtime configuration features
///
+ /// 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 CreateChatKitSessionAsync(
@@ -40,6 +43,7 @@ public partial interface IOpenAiClient
global::tryAGI.OpenAI.ExpiresAfterParam? expiresAfter = default,
global::tryAGI.OpenAI.RateLimitsParam? rateLimits = default,
global::tryAGI.OpenAI.ChatkitConfigurationParam? chatkitConfiguration = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.CreateContainer.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.CreateContainer.g.cs
index 5fd917387..18d670342 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.CreateContainer.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.CreateContainer.g.cs
@@ -9,11 +9,13 @@ public partial interface IOpenAiClient
/// Creates a container.
///
///
+ /// 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 CreateContainerAsync(
global::tryAGI.OpenAI.CreateContainerBody request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Create Container
@@ -37,6 +39,7 @@ public partial interface IOpenAiClient
///
/// Network access policy for the container.
///
+ /// 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 CreateContainerAsync(
@@ -46,6 +49,7 @@ public partial interface IOpenAiClient
global::System.Collections.Generic.IList? skills = default,
global::tryAGI.OpenAI.CreateContainerBodyMemoryLimit? memoryLimit = default,
global::tryAGI.OpenAI.NetworkPolicy? networkPolicy = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.CreateContainerFile.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.CreateContainerFile.g.cs
index c8d10fcf2..12f53d16f 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.CreateContainerFile.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.CreateContainerFile.g.cs
@@ -11,12 +11,14 @@ public partial interface IOpenAiClient
///
///
///
+ /// 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 CreateContainerFileAsync(
string containerId,
global::tryAGI.OpenAI.CreateContainerFileBody request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Create a Container File
@@ -33,6 +35,7 @@ public partial interface IOpenAiClient
///
/// The File object (not file name) to be 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 CreateContainerFileAsync(
@@ -40,6 +43,7 @@ public partial interface IOpenAiClient
string? fileId = default,
byte[]? file = default,
string? filename = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.DeleteAContainer.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.DeleteAContainer.g.cs
index c1aa6995d..7adf5d20e 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.DeleteAContainer.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.DeleteAContainer.g.cs
@@ -9,10 +9,12 @@ public partial interface IOpenAiClient
/// Delete a container.
///
///
+ /// 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 DeleteAContainerAsync(
string containerId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.DeleteAContainerFile.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.DeleteAContainerFile.g.cs
index 13cccbad6..b5e167b66 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.DeleteAContainerFile.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.DeleteAContainerFile.g.cs
@@ -10,11 +10,13 @@ public partial interface IOpenAiClient
///
///
///
+ /// 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 DeleteAContainerFileAsync(
string containerId,
string fileId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.DeleteAdminApiKey.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.DeleteAdminApiKey.g.cs
index 429c31f71..2a47a3f63 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.DeleteAdminApiKey.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.DeleteAdminApiKey.g.cs
@@ -11,10 +11,12 @@ public partial interface IOpenAiClient
///
/// The ID of the API key to be deleted.
///
+ /// 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 DeleteAdminApiKeyAsync(
string keyId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.DeleteChatKitThread.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.DeleteChatKitThread.g.cs
index 65d29fab3..3eafa9e26 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.DeleteChatKitThread.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.DeleteChatKitThread.g.cs
@@ -10,10 +10,12 @@ public partial interface IOpenAiClient
///
/// Example: cthr_123
///
+ /// 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 DeleteChatKitThreadAsync(
string threadId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.GetInputTokenCounts.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.GetInputTokenCounts.g.cs
index 28ca9f6c7..5e5c45afc 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.GetInputTokenCounts.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.GetInputTokenCounts.g.cs
@@ -9,11 +9,13 @@ public partial interface IOpenAiClient
/// Returns an object with `object` set to `response.input_tokens` and an `input_tokens` count.
///
///
+ /// 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 GetInputTokenCountsAsync(
global::tryAGI.OpenAI.TokenCountsBody request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Returns input token counts of the request.
@@ -32,6 +34,7 @@ public partial interface IOpenAiClient
///
///
///
+ /// 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 GetInputTokenCountsAsync(
@@ -46,6 +49,7 @@ public partial interface IOpenAiClient
global::tryAGI.OpenAI.ConversationParam? conversation = default,
global::tryAGI.OpenAI.ToolChoiceParam? toolChoice = default,
bool? parallelToolCalls = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.ListAllOrganizationAndProjectApiKeys.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.ListAllOrganizationAndProjectApiKeys.g.cs
index b1c2777ba..05d6590a3 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.ListAllOrganizationAndProjectApiKeys.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.ListAllOrganizationAndProjectApiKeys.g.cs
@@ -19,12 +19,14 @@ public partial interface IOpenAiClient
/// Maximum number of keys to return.
/// Default Value: 20
///
+ /// 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 ListAllOrganizationAndProjectApiKeysAsync(
string? after = default,
global::tryAGI.OpenAI.AdminApiKeysListOrder? order = default,
int? limit = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.ListChatKitThreadItems.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.ListChatKitThreadItems.g.cs
index 3326f7b15..b24cf4088 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.ListChatKitThreadItems.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.ListChatKitThreadItems.g.cs
@@ -18,6 +18,7 @@ public partial interface IOpenAiClient
///
/// List items created before this thread item ID. Defaults to null for the newest results.
///
+ /// 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 ListChatKitThreadItemsAsync(
@@ -26,6 +27,7 @@ public partial interface IOpenAiClient
global::tryAGI.OpenAI.OrderEnum? order = default,
string? after = default,
string? before = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.ListChatKitThreads.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.ListChatKitThreads.g.cs
index ade6ba568..248817c9e 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.ListChatKitThreads.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.ListChatKitThreads.g.cs
@@ -18,6 +18,7 @@ public partial interface IOpenAiClient
///
/// Filter threads that belong to this user identifier. Defaults to null to return all users.
///
+ /// 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 ListChatKitThreadsAsync(
@@ -26,6 +27,7 @@ public partial interface IOpenAiClient
string? after = default,
string? before = default,
string? user = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.ListContainerFiles.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.ListContainerFiles.g.cs
index 7706581ff..5824eb100 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.ListContainerFiles.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.ListContainerFiles.g.cs
@@ -16,6 +16,7 @@ public partial interface IOpenAiClient
/// Default Value: desc
///
///
+ /// 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 ListContainerFilesAsync(
@@ -23,6 +24,7 @@ public partial interface IOpenAiClient
int? limit = default,
global::tryAGI.OpenAI.ListContainerFilesOrder? order = default,
string? after = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.ListContainers.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.ListContainers.g.cs
index ea7c904eb..559948e4d 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.ListContainers.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.ListContainers.g.cs
@@ -16,6 +16,7 @@ public partial interface IOpenAiClient
///
///
///
+ /// 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 ListContainersAsync(
@@ -23,6 +24,7 @@ public partial interface IOpenAiClient
global::tryAGI.OpenAI.ListContainersOrder? order = default,
string? after = default,
string? name = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.RetrieveAdminApiKey.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.RetrieveAdminApiKey.g.cs
index af16b37fd..885b25639 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.RetrieveAdminApiKey.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.RetrieveAdminApiKey.g.cs
@@ -11,10 +11,12 @@ public partial interface IOpenAiClient
///
/// The ID of the API key.
///
+ /// 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 RetrieveAdminApiKeyAsync(
string keyId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.RetrieveChatKitThread.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.RetrieveChatKitThread.g.cs
index bb94d5dcf..5ddb5c7f3 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.RetrieveChatKitThread.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.RetrieveChatKitThread.g.cs
@@ -10,10 +10,12 @@ public partial interface IOpenAiClient
///
/// Example: cthr_123
///
+ /// 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 RetrieveChatKitThreadAsync(
string threadId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.RetrieveContainer.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.RetrieveContainer.g.cs
index ff766ea0b..92b11c761 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.RetrieveContainer.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.RetrieveContainer.g.cs
@@ -9,10 +9,12 @@ public partial interface IOpenAiClient
/// Retrieves a container.
///
///
+ /// 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 RetrieveContainerAsync(
string containerId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.RetrieveContainerFile.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.RetrieveContainerFile.g.cs
index 20c110588..7dbcebd18 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.RetrieveContainerFile.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.RetrieveContainerFile.g.cs
@@ -10,11 +10,13 @@ public partial interface IOpenAiClient
///
///
///
+ /// 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 RetrieveContainerFileAsync(
string containerId,
string fileId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.RetrieveContainerFileContent.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.RetrieveContainerFileContent.g.cs
index e72dc2d34..8a89f1a0a 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.RetrieveContainerFileContent.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.RetrieveContainerFileContent.g.cs
@@ -10,11 +10,13 @@ public partial interface IOpenAiClient
///
///
///
+ /// 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 RetrieveContainerFileContentAsync(
string containerId,
string fileId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.g.cs
index 942bcc7ab..fcc3d03f5 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IOpenAiClient.g.cs
@@ -34,6 +34,11 @@ public partial interface IOpenAiClient : global::System.IDisposable
///
public bool ReadResponseAsString { get; set; }
+ ///
+ /// Client-wide request defaults such as headers, query parameters, retries, and timeout.
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
+
///
///
///
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectGroupRoleAssignmentsClient.AssignProjectRoleToGroup.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectGroupRoleAssignmentsClient.AssignProjectRoleToGroup.g.cs
index 776d2ac25..f8a3c5b09 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectGroupRoleAssignmentsClient.AssignProjectRoleToGroup.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectGroupRoleAssignmentsClient.AssignProjectRoleToGroup.g.cs
@@ -10,6 +10,7 @@ public partial interface IProjectGroupRoleAssignmentsClient
///
///
///
+ /// 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 AssignProjectRoleToGroupAsync(
@@ -17,6 +18,7 @@ public partial interface IProjectGroupRoleAssignmentsClient
string groupId,
global::tryAGI.OpenAI.PublicAssignOrganizationGroupRoleBody request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Assigns a project role to a group within a project.
@@ -26,12 +28,14 @@ public partial interface IProjectGroupRoleAssignmentsClient
///
/// Identifier of the role to assign.
///
+ /// 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 AssignProjectRoleToGroupAsync(
string projectId,
string groupId,
string roleId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectGroupRoleAssignmentsClient.ListProjectGroupRoleAssignments.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectGroupRoleAssignmentsClient.ListProjectGroupRoleAssignments.g.cs
index cee286ae9..209d4b284 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectGroupRoleAssignmentsClient.ListProjectGroupRoleAssignments.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectGroupRoleAssignmentsClient.ListProjectGroupRoleAssignments.g.cs
@@ -12,6 +12,7 @@ public partial interface IProjectGroupRoleAssignmentsClient
///
///
///
+ /// 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 ListProjectGroupRoleAssignmentsAsync(
@@ -20,6 +21,7 @@ public partial interface IProjectGroupRoleAssignmentsClient
int? limit = default,
string? after = default,
global::tryAGI.OpenAI.ListProjectGroupRoleAssignmentsOrder? order = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectGroupRoleAssignmentsClient.UnassignProjectRoleFromGroup.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectGroupRoleAssignmentsClient.UnassignProjectRoleFromGroup.g.cs
index 982e542e6..01d8da8f5 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectGroupRoleAssignmentsClient.UnassignProjectRoleFromGroup.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectGroupRoleAssignmentsClient.UnassignProjectRoleFromGroup.g.cs
@@ -10,12 +10,14 @@ public partial interface IProjectGroupRoleAssignmentsClient
///
///
///
+ /// 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 UnassignProjectRoleFromGroupAsync(
string projectId,
string groupId,
string roleId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectGroupRoleAssignmentsClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectGroupRoleAssignmentsClient.g.cs
index 9ab126cd4..0c8bf03d6 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectGroupRoleAssignmentsClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectGroupRoleAssignmentsClient.g.cs
@@ -33,6 +33,11 @@ public partial interface IProjectGroupRoleAssignmentsClient : global::System.IDi
///
public bool ReadResponseAsString { get; set; }
+ ///
+ /// Client-wide request defaults such as headers, query parameters, retries, and timeout.
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
+
///
///
///
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectGroupsClient.AddProjectGroup.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectGroupsClient.AddProjectGroup.g.cs
index 0b71519c1..50f3e48b9 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectGroupsClient.AddProjectGroup.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectGroupsClient.AddProjectGroup.g.cs
@@ -9,12 +9,14 @@ public partial interface IProjectGroupsClient
///
///
///
+ /// 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 AddProjectGroupAsync(
string projectId,
global::tryAGI.OpenAI.InviteProjectGroupBody request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Grants a group access to a project.
@@ -26,12 +28,14 @@ public partial interface IProjectGroupsClient
///
/// Identifier of the project role to grant to the group.
///
+ /// 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 AddProjectGroupAsync(
string projectId,
string groupId,
string role,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectGroupsClient.ListProjectGroups.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectGroupsClient.ListProjectGroups.g.cs
index 6733ec252..330d6bdc0 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectGroupsClient.ListProjectGroups.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectGroupsClient.ListProjectGroups.g.cs
@@ -15,6 +15,7 @@ public partial interface IProjectGroupsClient
///
/// Default Value: asc
///
+ /// 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 ListProjectGroupsAsync(
@@ -22,6 +23,7 @@ public partial interface IProjectGroupsClient
int? limit = default,
string? after = default,
global::tryAGI.OpenAI.ListProjectGroupsOrder? order = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectGroupsClient.RemoveProjectGroup.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectGroupsClient.RemoveProjectGroup.g.cs
index ef955de31..1bfca0f84 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectGroupsClient.RemoveProjectGroup.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectGroupsClient.RemoveProjectGroup.g.cs
@@ -9,11 +9,13 @@ public partial interface IProjectGroupsClient
///
///
///
+ /// 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 RemoveProjectGroupAsync(
string projectId,
string groupId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectGroupsClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectGroupsClient.g.cs
index b7fef149e..367c3919a 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectGroupsClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectGroupsClient.g.cs
@@ -33,6 +33,11 @@ public partial interface IProjectGroupsClient : global::System.IDisposable
///
public bool ReadResponseAsString { get; set; }
+ ///
+ /// Client-wide request defaults such as headers, query parameters, retries, and timeout.
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
+
///
///
///
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectUserRoleAssignmentsClient.AssignProjectRoleToUser.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectUserRoleAssignmentsClient.AssignProjectRoleToUser.g.cs
index 2284d4ce7..50b512ebc 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectUserRoleAssignmentsClient.AssignProjectRoleToUser.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectUserRoleAssignmentsClient.AssignProjectRoleToUser.g.cs
@@ -10,6 +10,7 @@ public partial interface IProjectUserRoleAssignmentsClient
///
///
///
+ /// 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 AssignProjectRoleToUserAsync(
@@ -17,6 +18,7 @@ public partial interface IProjectUserRoleAssignmentsClient
string userId,
global::tryAGI.OpenAI.PublicAssignOrganizationGroupRoleBody request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Assigns a project role to a user within a project.
@@ -26,12 +28,14 @@ public partial interface IProjectUserRoleAssignmentsClient
///
/// Identifier of the role to assign.
///
+ /// 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 AssignProjectRoleToUserAsync(
string projectId,
string userId,
string roleId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectUserRoleAssignmentsClient.ListProjectUserRoleAssignments.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectUserRoleAssignmentsClient.ListProjectUserRoleAssignments.g.cs
index 9c4187b69..c3c3174d9 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectUserRoleAssignmentsClient.ListProjectUserRoleAssignments.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectUserRoleAssignmentsClient.ListProjectUserRoleAssignments.g.cs
@@ -12,6 +12,7 @@ public partial interface IProjectUserRoleAssignmentsClient
///
///
///
+ /// 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 ListProjectUserRoleAssignmentsAsync(
@@ -20,6 +21,7 @@ public partial interface IProjectUserRoleAssignmentsClient
int? limit = default,
string? after = default,
global::tryAGI.OpenAI.ListProjectUserRoleAssignmentsOrder? order = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectUserRoleAssignmentsClient.UnassignProjectRoleFromUser.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectUserRoleAssignmentsClient.UnassignProjectRoleFromUser.g.cs
index fd4b60f60..f1af0c391 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectUserRoleAssignmentsClient.UnassignProjectRoleFromUser.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectUserRoleAssignmentsClient.UnassignProjectRoleFromUser.g.cs
@@ -10,12 +10,14 @@ public partial interface IProjectUserRoleAssignmentsClient
///
///
///
+ /// 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 UnassignProjectRoleFromUserAsync(
string projectId,
string userId,
string roleId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectUserRoleAssignmentsClient.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectUserRoleAssignmentsClient.g.cs
index 21522e23d..9507b36b9 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectUserRoleAssignmentsClient.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectUserRoleAssignmentsClient.g.cs
@@ -33,6 +33,11 @@ public partial interface IProjectUserRoleAssignmentsClient : global::System.IDis
///
public bool ReadResponseAsString { get; set; }
+ ///
+ /// Client-wide request defaults such as headers, query parameters, retries, and timeout.
+ ///
+ public global::tryAGI.OpenAI.AutoSDKClientOptions Options { get; }
+
///
///
///
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.ArchiveProject.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.ArchiveProject.g.cs
index e0e70688b..5a1e1f7b5 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.ArchiveProject.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.ArchiveProject.g.cs
@@ -8,10 +8,12 @@ public partial interface IProjectsClient
/// Archives a project in the organization. Archived projects cannot be used or updated.
///
///
+ /// 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 ArchiveProjectAsync(
string projectId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.CreateProject.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.CreateProject.g.cs
index f2542588e..34f5aa456 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.CreateProject.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.CreateProject.g.cs
@@ -8,11 +8,13 @@ public partial interface IProjectsClient
/// Create a new project in the organization. Projects can be created and archived, but cannot be deleted.
///
///
+ /// 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 CreateProjectAsync(
global::tryAGI.OpenAI.ProjectCreateRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Create a new project in the organization. Projects can be created and archived, but cannot be deleted.
@@ -23,11 +25,13 @@ public partial interface IProjectsClient
///
/// Create the project with the specified data residency region. Your organization must have access to Data residency functionality in order to use. See [data residency controls](/docs/guides/your-data#data-residency-controls) to review the functionality and limitations of setting this field.
///
+ /// 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 CreateProjectAsync(
string name,
global::tryAGI.OpenAI.ProjectCreateRequestGeography? geography = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.CreateProjectServiceAccount.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.CreateProjectServiceAccount.g.cs
index dc23bc9bd..beb2cc0a6 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.CreateProjectServiceAccount.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.CreateProjectServiceAccount.g.cs
@@ -9,12 +9,14 @@ public partial interface IProjectsClient
///
///
///
+ /// 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 CreateProjectServiceAccountAsync(
string projectId,
global::tryAGI.OpenAI.ProjectServiceAccountCreateRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Creates a new service account in the project. This also returns an unredacted API key for the service account.
@@ -23,11 +25,13 @@ public partial interface IProjectsClient
///
/// The name of the service account being created.
///
+ /// 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 CreateProjectServiceAccountAsync(
string projectId,
string name,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.CreateProjectUser.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.CreateProjectUser.g.cs
index 7d4879d0a..4179fb36a 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.CreateProjectUser.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.CreateProjectUser.g.cs
@@ -9,12 +9,14 @@ public partial interface IProjectsClient
///
///
///
+ /// 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 CreateProjectUserAsync(
string projectId,
global::tryAGI.OpenAI.ProjectUserCreateRequest request,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Adds a user to the project. Users must already be members of the organization to be added to a project.
@@ -26,12 +28,14 @@ public partial interface IProjectsClient
///
/// `owner` or `member`
///
+ /// 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 CreateProjectUserAsync(
string projectId,
string userId,
global::tryAGI.OpenAI.ProjectUserCreateRequestRole role,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.DeleteProjectApiKey.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.DeleteProjectApiKey.g.cs
index ba60ea0ce..3d4fb395a 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.DeleteProjectApiKey.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.DeleteProjectApiKey.g.cs
@@ -11,11 +11,13 @@ public partial interface IProjectsClient
///
///
///
+ /// 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 DeleteProjectApiKeyAsync(
string projectId,
string keyId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.DeleteProjectServiceAccount.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.DeleteProjectServiceAccount.g.cs
index 7e534e3fb..bd97b8a9c 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.DeleteProjectServiceAccount.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.DeleteProjectServiceAccount.g.cs
@@ -11,11 +11,13 @@ public partial interface IProjectsClient
///
///
///
+ /// 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 DeleteProjectServiceAccountAsync(
string projectId,
string serviceAccountId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.DeleteProjectUser.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.DeleteProjectUser.g.cs
index 7f7c2cc57..514221ac7 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.DeleteProjectUser.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.DeleteProjectUser.g.cs
@@ -11,11 +11,13 @@ public partial interface IProjectsClient
///
///
///
+ /// 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 DeleteProjectUserAsync(
string projectId,
string userId,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.ListProjectApiKeys.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.ListProjectApiKeys.g.cs
index b8bb1afde..5c95dd2d0 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.ListProjectApiKeys.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.ListProjectApiKeys.g.cs
@@ -12,12 +12,14 @@ public partial interface IProjectsClient
/// Default Value: 20
///
///
+ /// 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 ListProjectApiKeysAsync(
string projectId,
int? limit = default,
string? after = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.ListProjectRateLimits.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.ListProjectRateLimits.g.cs
index 0c3338fee..79687a8d1 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.ListProjectRateLimits.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.ListProjectRateLimits.g.cs
@@ -13,6 +13,7 @@ public partial interface IProjectsClient
///
///
///
+ /// 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 ListProjectRateLimitsAsync(
@@ -20,6 +21,7 @@ public partial interface IProjectsClient
int? limit = default,
string? after = default,
string? before = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.ListProjectServiceAccounts.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.ListProjectServiceAccounts.g.cs
index c9db32986..b268e2517 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.ListProjectServiceAccounts.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.ListProjectServiceAccounts.g.cs
@@ -12,12 +12,14 @@ public partial interface IProjectsClient
/// Default Value: 20
///
///
+ /// 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 ListProjectServiceAccountsAsync(
string projectId,
int? limit = default,
string? after = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.ListProjectUsers.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.ListProjectUsers.g.cs
index 62bc857b4..486bb39f0 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.ListProjectUsers.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.ListProjectUsers.g.cs
@@ -12,12 +12,14 @@ public partial interface IProjectsClient
/// Default Value: 20
///
///
+ /// 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 ListProjectUsersAsync(
string projectId,
int? limit = default,
string? after = default,
+ global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.ListProjects.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.ListProjects.g.cs
index 05a8bbd2f..01b82508b 100644
--- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.ListProjects.g.cs
+++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IProjectsClient.ListProjects.g.cs
@@ -14,12 +14,14 @@ public partial interface IProjectsClient
///