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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,29 @@ partial void ProcessCancelARunResponseContent(
string runId,
global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __response = await CancelARunAsResponseAsync(
threadId: threadId,
runId: runId,
requestOptions: requestOptions,
cancellationToken: cancellationToken
).ConfigureAwait(false);

return __response.Body;
}
/// <summary>
/// Cancels a run that is `in_progress`.
/// </summary>
/// <param name="threadId"></param>
/// <param name="runId"></param>
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::tryAGI.OpenAI.ApiException"></exception>
public async global::System.Threading.Tasks.Task<global::tryAGI.OpenAI.AutoSDKHttpResponse<global::tryAGI.OpenAI.RunObject>> CancelARunAsResponseAsync(
string threadId,
string runId,
global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
client: HttpClient);
Expand Down Expand Up @@ -86,6 +109,7 @@ partial void ProcessCancelARunResponseContent(

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

var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
path: $"/threads/{threadId}/runs/{runId}/cancel",
baseUri: HttpClient.BaseAddress);
Expand Down Expand Up @@ -160,6 +184,8 @@ partial void ProcessCancelARunResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
retryDelay: null,
retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
Expand All @@ -170,6 +196,11 @@ partial void ProcessCancelARunResponseContent(
}
catch (global::System.Net.Http.HttpRequestException __exception)
{
var __retryDelay = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetRetryDelay(
clientOptions: Options,
requestOptions: requestOptions,
response: null,
attempt: __attempt);
var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
Expand All @@ -187,6 +218,8 @@ partial void ProcessCancelARunResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
Expand All @@ -196,8 +229,7 @@ partial void ProcessCancelARunResponseContent(
__httpRequest.Dispose();
__httpRequest = null;
await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
clientOptions: Options,
requestOptions: requestOptions,
retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
Expand All @@ -206,6 +238,11 @@ partial void ProcessCancelARunResponseContent(
__attempt < __maxAttempts &&
global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
var __retryDelay = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetRetryDelay(
clientOptions: Options,
requestOptions: requestOptions,
response: __response,
attempt: __attempt);
await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
Expand All @@ -222,14 +259,15 @@ partial void ProcessCancelARunResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: true,
retryDelay: __retryDelay,
retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
__response.Dispose();
__response = null;
__httpRequest.Dispose();
__httpRequest = null;
await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
clientOptions: Options,
requestOptions: requestOptions,
retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
Expand Down Expand Up @@ -269,6 +307,8 @@ partial void ProcessCancelARunResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
retryDelay: null,
retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
Expand All @@ -289,6 +329,8 @@ partial void ProcessCancelARunResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
retryDelay: null,
retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}

Expand All @@ -313,9 +355,13 @@ partial void ProcessCancelARunResponseContent(
{
__response.EnsureSuccessStatusCode();

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

return
await global::tryAGI.OpenAI.RunObject.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
var __value = await global::tryAGI.OpenAI.RunObject.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
return new global::tryAGI.OpenAI.AutoSDKHttpResponse<global::tryAGI.OpenAI.RunObject>(
statusCode: __response.StatusCode,
headers: global::tryAGI.OpenAI.AutoSDKHttpResponse.CreateHeaders(__response),
requestUri: __response.RequestMessage?.RequestUri,
body: __value);
}
catch (global::System.Exception __ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,31 @@ partial void ProcessCreateMessageResponseContent(
public async global::System.Threading.Tasks.Task<global::tryAGI.OpenAI.MessageObject> CreateMessageAsync(
string threadId,

global::tryAGI.OpenAI.CreateMessageRequest request,
global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __response = await CreateMessageAsResponseAsync(
threadId: threadId,

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

return __response.Body;
}
/// <summary>
/// Create a message.
/// </summary>
/// <param name="threadId"></param>
/// <param name="request"></param>
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::tryAGI.OpenAI.ApiException"></exception>
public async global::System.Threading.Tasks.Task<global::tryAGI.OpenAI.AutoSDKHttpResponse<global::tryAGI.OpenAI.MessageObject>> CreateMessageAsResponseAsync(
string threadId,

global::tryAGI.OpenAI.CreateMessageRequest request,
global::tryAGI.OpenAI.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
Expand Down Expand Up @@ -89,6 +114,7 @@ partial void ProcessCreateMessageResponseContent(

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

var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
path: $"/threads/{threadId}/messages",
baseUri: HttpClient.BaseAddress);
Expand Down Expand Up @@ -169,6 +195,8 @@ partial void ProcessCreateMessageResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
retryDelay: null,
retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
Expand All @@ -179,6 +207,11 @@ partial void ProcessCreateMessageResponseContent(
}
catch (global::System.Net.Http.HttpRequestException __exception)
{
var __retryDelay = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetRetryDelay(
clientOptions: Options,
requestOptions: requestOptions,
response: null,
attempt: __attempt);
var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
Expand All @@ -196,6 +229,8 @@ partial void ProcessCreateMessageResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
Expand All @@ -205,8 +240,7 @@ partial void ProcessCreateMessageResponseContent(
__httpRequest.Dispose();
__httpRequest = null;
await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
clientOptions: Options,
requestOptions: requestOptions,
retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
Expand All @@ -215,6 +249,11 @@ partial void ProcessCreateMessageResponseContent(
__attempt < __maxAttempts &&
global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
var __retryDelay = global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.GetRetryDelay(
clientOptions: Options,
requestOptions: requestOptions,
response: __response,
attempt: __attempt);
await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
context: global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.CreateHookContext(
Expand All @@ -231,14 +270,15 @@ partial void ProcessCreateMessageResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: true,
retryDelay: __retryDelay,
retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
__response.Dispose();
__response = null;
__httpRequest.Dispose();
__httpRequest = null;
await global::tryAGI.OpenAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
clientOptions: Options,
requestOptions: requestOptions,
retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
Expand Down Expand Up @@ -278,6 +318,8 @@ partial void ProcessCreateMessageResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
retryDelay: null,
retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
Expand All @@ -298,6 +340,8 @@ partial void ProcessCreateMessageResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
retryDelay: null,
retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}

Expand All @@ -322,9 +366,13 @@ partial void ProcessCreateMessageResponseContent(
{
__response.EnsureSuccessStatusCode();

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

return
await global::tryAGI.OpenAI.MessageObject.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
var __value = await global::tryAGI.OpenAI.MessageObject.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
return new global::tryAGI.OpenAI.AutoSDKHttpResponse<global::tryAGI.OpenAI.MessageObject>(
statusCode: __response.StatusCode,
headers: global::tryAGI.OpenAI.AutoSDKHttpResponse.CreateHeaders(__response),
requestUri: __response.RequestMessage?.RequestUri,
body: __value);
}
catch (global::System.Exception __ex)
{
Expand Down
Loading
Loading