Skip to content

Commit 7d79a65

Browse files
com.openai.unity 8.8.3 (#415)
- Fix RealtimeBehaviour sample transcriptions - Fix sample scene microphone sprite references - Added DurationUsage - Updated ConversationItemInputAudioTranscriptionResponse to include logprobs and usage - Add Azure Blob Batch API compatible fields for CreateBatchRequest - Update Realtime.SessionConfiguration with Prompt and Speed parameters - Move Realtime.Prompt to common namespace - Bump package deps
1 parent 6cc79bd commit 7d79a65

25 files changed

Lines changed: 311 additions & 73 deletions

.github/workflows/build-options.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
"macos-latest"
66
],
77
"unity-version": [
8-
"2022.x",
9-
"6000.0.x",
10-
"6000.1.x",
11-
"6000.2.x"
8+
"2021",
9+
"2022",
10+
"6000.0",
11+
"6000.1",
12+
"6000.2"
1213
],
1314
"include": [
1415
{

.github/workflows/unity.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ jobs:
2525
id: setup-jobs
2626
with:
2727
build-options: ./.github/workflows/build-options.json
28-
group-by: 'unity-version'
29-
job-name-prefix: 'Build'
28+
group-by: unity-version
29+
job-name-prefix: Build
3030
outputs:
3131
jobs: ${{ steps.setup-jobs.outputs.jobs }}
3232
validate:

.github/workflows/upm-subtree-split.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
permissions:
1010
contents: write
1111
steps:
12-
- uses: actions/checkout@v4
12+
- uses: actions/checkout@v5
1313
with:
1414
fetch-depth: 0
1515
- uses: RageAgainstThePixel/upm-subtree-split@v1.1

OpenAI/Packages/com.openai.unity/Documentation~/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ openupm add com.openai.unity
8080
- [List Input Items](#list-input-items)
8181
- [Cancel Response](#cancel-response)
8282
- [Delete Response](#delete-response)
83-
- [Conversations](#conversations) :new:
84-
- [Create Conversation](#create-conversation) :new:
85-
- [Retrieve Conversation](#retrieve-conversation) :new:
86-
- [Update Conversation](#update-conversation) :new:
87-
- [Delete Conversation](#delete-conversation) :new:
88-
- [List Conversation Items](#list-conversation-items) :new:
89-
- [Create Conversation Item](#create-conversation-item) :new:
90-
- [Retrieve Conversation Item](#retrieve-conversation-item) :new:
91-
- [Delete Conversation Item](#delete-conversation-item) :new:
83+
- [Conversations](#conversations)
84+
- [Create Conversation](#create-conversation)
85+
- [Retrieve Conversation](#retrieve-conversation)
86+
- [Update Conversation](#update-conversation)
87+
- [Delete Conversation](#delete-conversation)
88+
- [List Conversation Items](#list-conversation-items)
89+
- [Create Conversation Item](#create-conversation-item)
90+
- [Retrieve Conversation Item](#retrieve-conversation-item)
91+
- [Delete Conversation Item](#delete-conversation-item)
9292
- [Realtime](#realtime)
9393
- [Create Realtime Session](#create-realtime-session)
9494
- [Client Events](#client-events)

OpenAI/Packages/com.openai.unity/Runtime/Authentication/OpenAIAuthInfo.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,23 @@ public OpenAIAuthInfo(string apiKey, string organizationId = null, string projec
2727

2828
if (!string.IsNullOrWhiteSpace(organizationId))
2929
{
30-
if (!organizationId.Contains(OrganizationPrefix))
30+
if (!organizationId!.Contains(OrganizationPrefix))
3131
{
3232
throw new InvalidCredentialException($"{nameof(organizationId)} must start with '{OrganizationPrefix}'");
3333
}
34-
35-
this.organizationId = organizationId;
3634
}
3735

36+
this.organizationId = organizationId;
37+
3838
if (!string.IsNullOrWhiteSpace(projectId))
3939
{
40-
if (!projectId.Contains(ProjectPrefix))
40+
if (!projectId!.Contains(ProjectPrefix))
4141
{
4242
throw new InvalidCredentialException($"{nameof(projectId)} must start with '{ProjectPrefix}'");
4343
}
44-
45-
this.projectId = projectId;
4644
}
45+
46+
this.projectId = projectId;
4747
}
4848

4949
[SerializeField]
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Licensed under the MIT License. See LICENSE in the project root for license information.
2+
3+
using Newtonsoft.Json;
4+
using UnityEngine.Scripting;
5+
6+
namespace OpenAI.Batch
7+
{
8+
[Preserve]
9+
public sealed class BatchOutputFolder
10+
{
11+
[JsonConstructor]
12+
public BatchOutputFolder([JsonProperty("url")] string url)
13+
{
14+
Url = url;
15+
}
16+
17+
[Preserve]
18+
[JsonProperty("url")]
19+
public string Url { get; }
20+
21+
[Preserve]
22+
public static implicit operator BatchOutputFolder(string url) => new(url);
23+
}
24+
}

OpenAI/Packages/com.openai.unity/Runtime/Batch/BatchOutputFolder.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

OpenAI/Packages/com.openai.unity/Runtime/Batch/BatchResponse.cs

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ internal BatchResponse(
3131
[JsonProperty("expired_at")] int? expiredAt,
3232
[JsonProperty("cancelled_at")] int? cancelledAt,
3333
[JsonProperty("request_counts")] RequestCounts requestCounts,
34-
[JsonProperty("metadata")] Dictionary<string, object> metadata)
34+
[JsonProperty("metadata")] Dictionary<string, object> metadata,
35+
[JsonProperty("error_blob")] string errorBlob,
36+
[JsonProperty("input_blob")] string inputBlob,
37+
[JsonProperty("output_blob")] string outputBlob)
3538
{
3639
Id = id;
3740
Object = @object;
@@ -52,6 +55,9 @@ internal BatchResponse(
5255
CancelledAtUnixTimeSeconds = cancelledAt;
5356
RequestCounts = requestCounts;
5457
Metadata = metadata;
58+
ErrorBlob = errorBlob;
59+
InputBlob = inputBlob;
60+
OutputBlob = outputBlob;
5561
}
5662

5763
[Preserve]
@@ -76,7 +82,7 @@ internal BatchResponse(
7682
/// Errors that occurred during the batch job.
7783
/// </summary>
7884
[Preserve]
79-
[JsonProperty("errors")]
85+
[JsonProperty("errors", DefaultValueHandling = DefaultValueHandling.Ignore)]
8086
public BatchErrors BatchErrors { get; }
8187

8288
/// <summary>
@@ -104,14 +110,14 @@ internal BatchResponse(
104110
/// The ID of the file containing the outputs of successfully executed requests.
105111
/// </summary>
106112
[Preserve]
107-
[JsonProperty("output_file_id")]
113+
[JsonProperty("output_file_id", DefaultValueHandling = DefaultValueHandling.Ignore)]
108114
public string OutputFileId { get; }
109115

110116
/// <summary>
111117
/// The ID of the file containing the outputs of requests with errors.
112118
/// </summary>
113119
[Preserve]
114-
[JsonProperty("error_file_id")]
120+
[JsonProperty("error_file_id", DefaultValueHandling = DefaultValueHandling.Ignore)]
115121
public string ErrorFileId { get; }
116122

117123
/// <summary>
@@ -129,7 +135,7 @@ internal BatchResponse(
129135
/// The Unix timestamp (in seconds) for when the batch started processing.
130136
/// </summary>
131137
[Preserve]
132-
[JsonProperty("in_progress_at")]
138+
[JsonProperty("in_progress_at", DefaultValueHandling = DefaultValueHandling.Ignore)]
133139
public int? InProgressAtUnixTimeSeconds { get; }
134140

135141
[Preserve]
@@ -143,7 +149,7 @@ public DateTime? InProgressAt
143149
/// The Unix timestamp (in seconds) for when the batch will expire.
144150
/// </summary>
145151
[Preserve]
146-
[JsonProperty("expires_at")]
152+
[JsonProperty("expires_at", DefaultValueHandling = DefaultValueHandling.Ignore)]
147153
public int? ExpiresAtUnixTimeSeconds { get; }
148154

149155
[Preserve]
@@ -157,7 +163,7 @@ public DateTime? ExpiresAt
157163
/// The Unix timestamp (in seconds) for when the batch started finalizing.
158164
/// </summary>
159165
[Preserve]
160-
[JsonProperty("finalizing_at")]
166+
[JsonProperty("finalizing_at", DefaultValueHandling = DefaultValueHandling.Ignore)]
161167
public int? FinalizingAtUnixTimeSeconds { get; }
162168

163169
[Preserve]
@@ -171,7 +177,7 @@ public DateTime? FinalizingAt
171177
/// The Unix timestamp (in seconds) for when the batch was completed.
172178
/// </summary>
173179
[Preserve]
174-
[JsonProperty("completed_at")]
180+
[JsonProperty("completed_at", DefaultValueHandling = DefaultValueHandling.Ignore)]
175181
public int? CompletedAtUnixTimeSeconds { get; }
176182

177183
[Preserve]
@@ -185,7 +191,7 @@ public DateTime? CompletedAt
185191
/// The Unix timestamp (in seconds) for when the batch failed.
186192
/// </summary>
187193
[Preserve]
188-
[JsonProperty("failed_at")]
194+
[JsonProperty("failed_at", DefaultValueHandling = DefaultValueHandling.Ignore)]
189195
public int? FailedAtUnixTimeSeconds { get; }
190196

191197
[Preserve]
@@ -199,7 +205,7 @@ public DateTime? FailedAt
199205
/// The Unix timestamp (in seconds) for when the batch expired.
200206
/// </summary>
201207
[Preserve]
202-
[JsonProperty("expired_at")]
208+
[JsonProperty("expired_at", DefaultValueHandling = DefaultValueHandling.Ignore)]
203209
public int? ExpiredAtUnixTimeSeconds { get; }
204210

205211
[Preserve]
@@ -213,7 +219,7 @@ public DateTime? ExpiredAt
213219
/// The Unix timestamp (in seconds) for when the batch was cancelled.
214220
/// </summary>
215221
[Preserve]
216-
[JsonProperty("cancelled_at")]
222+
[JsonProperty("cancelled_at", DefaultValueHandling = DefaultValueHandling.Ignore)]
217223
public int? CancelledAtUnixTimeSeconds { get; }
218224

219225
[Preserve]
@@ -227,7 +233,7 @@ public DateTime? CancelledAt
227233
/// The request counts for different statuses within the batch.
228234
/// </summary>
229235
[Preserve]
230-
[JsonProperty("request_counts")]
236+
[JsonProperty("request_counts", DefaultValueHandling = DefaultValueHandling.Ignore)]
231237
public RequestCounts RequestCounts { get; }
232238

233239
/// <summary>
@@ -236,9 +242,30 @@ public DateTime? CancelledAt
236242
/// Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.
237243
/// </summary>
238244
[Preserve]
239-
[JsonProperty("metadata")]
245+
[JsonProperty("metadata", DefaultValueHandling = DefaultValueHandling.Ignore)]
240246
public IReadOnlyDictionary<string, object> Metadata { get; }
241247

248+
/// <summary>
249+
/// The URL of the blob storage location where any errors encountered during processing will be written.
250+
/// </summary>
251+
[Preserve]
252+
[JsonProperty("error_blob", DefaultValueHandling = DefaultValueHandling.Ignore)]
253+
public string ErrorBlob { get; }
254+
255+
/// <summary>
256+
/// The URL of the blob storage location where the batch output will be written.
257+
/// </summary>
258+
[Preserve]
259+
[JsonProperty("output_blob", DefaultValueHandling = DefaultValueHandling.Ignore)]
260+
public string OutputBlob { get; }
261+
262+
/// <summary>
263+
/// The URL of the blob storage location where the batch input was read from.
264+
/// </summary>
265+
[Preserve]
266+
[JsonProperty("input_blob", DefaultValueHandling = DefaultValueHandling.Ignore)]
267+
public string InputBlob { get; }
268+
242269
[Preserve]
243270
public override string ToString() => Id;
244271

OpenAI/Packages/com.openai.unity/Runtime/Batch/CreateBatchRequest.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,14 @@ public sealed class CreateBatchRequest
2727
/// <param name="metadata">
2828
/// Optional custom metadata for the batch.
2929
/// </param>
30+
/// <param name="inputBlob">Azure blob</param>
31+
/// <param name="outputFolder"><see cref="BatchOutputFolder"/>.</param>
3032
[Preserve]
31-
public CreateBatchRequest(string inputFileId, string endpoint, IReadOnlyDictionary<string, object> metadata = null)
33+
public CreateBatchRequest(
34+
string inputFileId,
35+
string endpoint, IReadOnlyDictionary<string, object> metadata = null,
36+
string inputBlob = null,
37+
BatchOutputFolder outputFolder = null)
3238
{
3339
InputFileId = inputFileId;
3440
Endpoint = endpoint;
@@ -49,7 +55,15 @@ public CreateBatchRequest(string inputFileId, string endpoint, IReadOnlyDictiona
4955
public string CompletionWindow { get; }
5056

5157
[Preserve]
52-
[JsonProperty("metadata")]
58+
[JsonProperty("metadata", DefaultValueHandling = DefaultValueHandling.Ignore)]
5359
public IReadOnlyDictionary<string, object> Metadata { get; }
60+
61+
[Preserve]
62+
[JsonProperty("input_blob", DefaultValueHandling = DefaultValueHandling.Ignore)]
63+
public string InputBlob { get; }
64+
65+
[Preserve]
66+
[JsonProperty("output_folder", DefaultValueHandling = DefaultValueHandling.Ignore)]
67+
public BatchOutputFolder OutputFolder { get; }
5468
}
5569
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Licensed under the MIT License. See LICENSE in the project root for license information.
2+
3+
using Newtonsoft.Json;
4+
using UnityEngine.Scripting;
5+
6+
namespace OpenAI
7+
{
8+
[Preserve]
9+
public sealed class DurationUsage
10+
{
11+
[Preserve]
12+
[JsonConstructor]
13+
internal DurationUsage(
14+
[JsonProperty("seconds")] float seconds,
15+
[JsonProperty("type")] string type)
16+
{
17+
Seconds = seconds;
18+
Type = type;
19+
}
20+
21+
[Preserve]
22+
[JsonProperty("seconds")]
23+
public float Seconds { get; }
24+
25+
[Preserve]
26+
[JsonProperty("type")]
27+
public string Type { get; }
28+
29+
[Preserve]
30+
public override string ToString()
31+
=> JsonConvert.SerializeObject(this, Formatting.Indented, OpenAIClient.JsonSerializationOptions);
32+
}
33+
}

0 commit comments

Comments
 (0)