Skip to content

Commit

Permalink
com.openai.unity 7.7.4 (#203)
Browse files Browse the repository at this point in the history
- Fixed Threads.RunResponse.WaitForStatusChangeAsync timeout
  • Loading branch information
StephenHodgson authored Feb 29, 2024
1 parent 1671be7 commit 43212ee
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ public MessageResponse(
public string Id { get; }

/// <summary>
/// The object type, which is always thread.
/// The object type, which is always message.
/// </summary>
[Preserve]
[JsonProperty("object")]
public string Object { get; }

/// <summary>
/// The Unix timestamp (in seconds) for when the thread was created.
/// The Unix timestamp (in seconds) for when the message was created.
/// </summary>
[Preserve]
[JsonProperty("created_at")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,16 @@ public static async Task<RunResponse> ModifyAsync(this RunResponse run, IReadOnl
/// <returns><see cref="RunResponse"/>.</returns>
public static async Task<RunResponse> WaitForStatusChangeAsync(this RunResponse run, int? pollingInterval = null, int? timeout = null, CancellationToken cancellationToken = default)
{
using var cts = timeout is null or < 0 ? new CancellationTokenSource(TimeSpan.FromSeconds(timeout ?? 30)) : new CancellationTokenSource();
using CancellationTokenSource cts = timeout.HasValue && timeout < 0
? new CancellationTokenSource()
: new CancellationTokenSource(TimeSpan.FromSeconds(timeout ?? 30));
using var chainedCts = CancellationTokenSource.CreateLinkedTokenSource(cts.Token, cancellationToken);
RunResponse result;
do
{
result = await run.UpdateAsync(cancellationToken: chainedCts.Token);
await Task.Delay(pollingInterval ?? 500, chainedCts.Token);
cancellationToken.ThrowIfCancellationRequested();
result = await run.UpdateAsync(cancellationToken: chainedCts.Token);
} while (result.Status is RunStatus.Queued or RunStatus.InProgress or RunStatus.Cancelling);
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion OpenAI/Packages/com.openai.unity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "OpenAI",
"description": "A OpenAI package for the Unity Game Engine to use GPT-4, GPT-3.5, GPT-3 and Dall-E though their RESTful API (currently in beta).\n\nIndependently developed, this is not an official library and I am not affiliated with OpenAI.\n\nAn OpenAI API account is required.",
"keywords": [],
"version": "7.7.3",
"version": "7.7.4",
"unity": "2021.3",
"documentationUrl": "https://github.com/RageAgainstThePixel/com.openai.unity#documentation",
"changelogUrl": "https://github.com/RageAgainstThePixel/com.openai.unity/releases",
Expand Down

0 comments on commit 43212ee

Please sign in to comment.