Skip to content

Commit 2d72144

Browse files
com.openai.unity 7.7.4 (#203)
- Fixed Threads.RunResponse.WaitForStatusChangeAsync timeout
1 parent 3655ff3 commit 2d72144

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

Runtime/Threads/MessageResponse.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ public MessageResponse(
5050
public string Id { get; }
5151

5252
/// <summary>
53-
/// The object type, which is always thread.
53+
/// The object type, which is always message.
5454
/// </summary>
5555
[Preserve]
5656
[JsonProperty("object")]
5757
public string Object { get; }
5858

5959
/// <summary>
60-
/// The Unix timestamp (in seconds) for when the thread was created.
60+
/// The Unix timestamp (in seconds) for when the message was created.
6161
/// </summary>
6262
[Preserve]
6363
[JsonProperty("created_at")]

Runtime/Threads/ThreadExtensions.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,13 +261,16 @@ public static async Task<RunResponse> ModifyAsync(this RunResponse run, IReadOnl
261261
/// <returns><see cref="RunResponse"/>.</returns>
262262
public static async Task<RunResponse> WaitForStatusChangeAsync(this RunResponse run, int? pollingInterval = null, int? timeout = null, CancellationToken cancellationToken = default)
263263
{
264-
using var cts = timeout is null or < 0 ? new CancellationTokenSource(TimeSpan.FromSeconds(timeout ?? 30)) : new CancellationTokenSource();
264+
using CancellationTokenSource cts = timeout.HasValue && timeout < 0
265+
? new CancellationTokenSource()
266+
: new CancellationTokenSource(TimeSpan.FromSeconds(timeout ?? 30));
265267
using var chainedCts = CancellationTokenSource.CreateLinkedTokenSource(cts.Token, cancellationToken);
266268
RunResponse result;
267269
do
268270
{
269-
result = await run.UpdateAsync(cancellationToken: chainedCts.Token);
270271
await Task.Delay(pollingInterval ?? 500, chainedCts.Token);
272+
cancellationToken.ThrowIfCancellationRequested();
273+
result = await run.UpdateAsync(cancellationToken: chainedCts.Token);
271274
} while (result.Status is RunStatus.Queued or RunStatus.InProgress or RunStatus.Cancelling);
272275
return result;
273276
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "OpenAI",
44
"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.",
55
"keywords": [],
6-
"version": "7.7.3",
6+
"version": "7.7.4",
77
"unity": "2021.3",
88
"documentationUrl": "https://github.com/RageAgainstThePixel/com.openai.unity#documentation",
99
"changelogUrl": "https://github.com/RageAgainstThePixel/com.openai.unity/releases",

0 commit comments

Comments
 (0)