Skip to content

Commit 6cc79bd

Browse files
StephenHodgsondudziakleapark
authored
com.openai.unity 8.8.2 (#410)
- Fix a bug in parsing the Response on Android by @dudziakl - Refactored json object .ctrs to fix AOT serialization problems - Added NoiseReductionSettings for RealtimeConfiguration by @eapark - Fix ConversationItemTruncateRequest.ContentIndex default serialization by @eapark - Add file_url for responses api by @gfreezy - Added support for gpt-5 and latest API changes - Added ConversationsEndpoint - Updated default model lists - Made Model class serializable so it can be picked and selected from inspectors - Refactor Assistant/Thread Endpoint beta headers to only be applied on those specific endpoints - Updated dependencies --------- Co-authored-by: Lukasz D <12583808+dudziakl@users.noreply.github.com> Co-authored-by: Emily Eap Park <epark3@nd.edu>
1 parent a81f086 commit 6cc79bd

File tree

86 files changed

+2321
-409
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+2321
-409
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"os": [
3+
"ubuntu-latest",
4+
"windows-latest",
5+
"macos-latest"
6+
],
7+
"unity-version": [
8+
"2022.x",
9+
"6000.0.x",
10+
"6000.1.x",
11+
"6000.2.x"
12+
],
13+
"include": [
14+
{
15+
"os": "ubuntu-latest",
16+
"build-target": "StandaloneLinux64"
17+
},
18+
{
19+
"os": "ubuntu-latest",
20+
"build-target": "WebGL"
21+
},
22+
{
23+
"os": "ubuntu-latest",
24+
"build-target": "Android"
25+
},
26+
{
27+
"os": "ubuntu-latest",
28+
"build-target": "iOS"
29+
},
30+
{
31+
"os": "windows-latest",
32+
"build-target": "StandaloneWindows64"
33+
},
34+
{
35+
"os": "windows-latest",
36+
"build-target": "WSAPlayer"
37+
},
38+
{
39+
"os": "macos-latest",
40+
"build-target": "StandaloneOSX"
41+
}
42+
]
43+
}

.github/workflows/unity.yml

Lines changed: 29 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -3,94 +3,44 @@ on:
33
schedule:
44
- cron: '0 0 * * 0' # Every Sunday at midnight
55
push:
6-
branches:
7-
- 'main'
6+
branches: [main]
87
pull_request:
98
types: [opened, reopened, synchronize, ready_for_review]
10-
branches:
11-
- '**'
12-
workflow_dispatch:
9+
branches: ['**']
10+
workflow_dispatch: # manual workflow trigger
1311
concurrency:
1412
group: ${{ github.workflow }}-${{ github.ref }}
1513
cancel-in-progress: ${{(github.event_name == 'pull_request' || github.event.action == 'synchronize')}}
1614
jobs:
17-
build:
18-
name: ${{ matrix.os }} ${{ matrix.unity-version }} ${{ matrix.build-target }}
19-
runs-on: ${{ matrix.os }}
15+
setup:
2016
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
17+
runs-on: ubuntu-latest
2118
permissions:
2219
contents: read
23-
strategy:
24-
fail-fast: false
25-
matrix:
26-
include: # for each os specify the build targets
27-
- os: ubuntu-latest
28-
unity-version: 2022.x
29-
build-target: Android
30-
- os: ubuntu-latest
31-
unity-version: 6000.x
32-
build-target: Android
33-
- os: ubuntu-latest
34-
unity-version: 2022.x
35-
build-target: StandaloneLinux64
36-
- os: ubuntu-latest
37-
unity-version: 6000.x
38-
build-target: StandaloneLinux64
39-
- os: ubuntu-latest
40-
unity-version: 2022.x
41-
build-target: WebGL
42-
- os: ubuntu-latest
43-
unity-version: 6000.x
44-
build-target: WebGL
45-
- os: windows-latest
46-
unity-version: 2022.x
47-
build-target: StandaloneWindows64
48-
- os: windows-latest
49-
unity-version: 6000.x
50-
build-target: StandaloneWindows64
51-
- os: windows-latest
52-
unity-version: 2022.x
53-
build-target: WSAPlayer
54-
- os: windows-latest
55-
unity-version: 6000.x
56-
build-target: WSAPlayer
57-
- os: macos-latest
58-
unity-version: 2022.x
59-
build-target: iOS
60-
- os: macos-latest
61-
unity-version: 6000.x
62-
build-target: iOS
63-
- os: macos-latest
64-
unity-version: 2022.x
65-
build-target: StandaloneOSX
66-
- os: macos-latest
67-
unity-version: 6000.x
68-
build-target: StandaloneOSX
6920
steps:
70-
- uses: actions/checkout@v4
71-
- uses: RageAgainstThePixel/unity-setup@v1
72-
with:
73-
unity-version: ${{ matrix.unity-version }}
74-
build-targets: ${{ matrix.build-target }}
75-
- uses: RageAgainstThePixel/activate-unity-license@v1
76-
with:
77-
license: 'Personal'
78-
username: ${{ secrets.UNITY_USERNAME }}
79-
password: ${{ secrets.UNITY_PASSWORD }}
80-
- uses: RageAgainstThePixel/unity-action@v1
81-
name: '${{ matrix.build-target }}-Validate'
82-
with:
83-
build-target: ${{ matrix.build-target }}
84-
log-name: '${{ matrix.build-target }}-Validate'
85-
args: '-quit -nographics -batchmode -executeMethod Utilities.Editor.BuildPipeline.UnityPlayerBuildTools.ValidateProject -importTMProEssentialsAsset'
86-
- uses: RageAgainstThePixel/unity-action@v1
87-
name: '${{ matrix.build-target }}-Build'
21+
- uses: actions/checkout@v5
8822
with:
89-
build-target: ${{ matrix.build-target }}
90-
log-name: '${{ matrix.build-target }}-Build'
91-
args: '-quit -nographics -batchmode -executeMethod Utilities.Editor.BuildPipeline.UnityPlayerBuildTools.StartCommandLineBuild'
92-
- uses: actions/upload-artifact@v4
93-
if: success() || failure()
23+
sparse-checkout: .github/
24+
- uses: RageAgainstThePixel/job-builder@v1
25+
id: setup-jobs
9426
with:
95-
name: '${{ github.run_number }}.${{ github.run_attempt }}-${{ matrix.os }}-${{ matrix.unity-version }}-${{ matrix.build-target }}-Artifacts'
96-
path: '${{ github.workspace }}/**/*.log'
27+
build-options: ./.github/workflows/build-options.json
28+
group-by: 'unity-version'
29+
job-name-prefix: 'Build'
30+
outputs:
31+
jobs: ${{ steps.setup-jobs.outputs.jobs }}
32+
validate:
33+
if: ${{ needs.setup.outputs.jobs }}
34+
needs: setup
35+
name: ${{ matrix.jobs.name }}
36+
permissions:
37+
contents: read
38+
actions: write
39+
strategy:
40+
matrix: ${{ fromJSON(needs.setup.outputs.jobs) }}
41+
fail-fast: false
42+
max-parallel: 1
43+
secrets: inherit
44+
uses: RageAgainstThePixel/workflows/.github/workflows/build-unity-package.yml@main
45+
with:
46+
matrix: ${{ toJSON(matrix.jobs.matrix) }}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ on:
66
jobs:
77
upm-subtree-split:
88
runs-on: ubuntu-latest
9+
permissions:
10+
contents: write
911
steps:
1012
- uses: actions/checkout@v4
1113
with:

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

Lines changed: 134 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +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:
8392
- [Realtime](#realtime)
8493
- [Create Realtime Session](#create-realtime-session)
8594
- [Client Events](#client-events)
@@ -452,7 +461,7 @@ Creates a model response. Provide text or image inputs to generate text or JSON
452461
var api = new OpenAIClient();
453462
var response = await api.ResponsesEndpoint.CreateModelResponseAsync("Tell me a three sentence bedtime story about a unicorn.");
454463
var responseItem = response.Output.LastOrDefault();
455-
Debug.Log($"{messageItem.Role}:{textContent.Text}");
464+
Debug.Log($"{responseItem.Role}:{responseItem}");
456465
response.PrintUsage();
457466
```
458467

@@ -469,7 +478,7 @@ var tools = new List<Tool>
469478
{
470479
Tool.GetOrCreateTool(typeof(DateTimeUtility), nameof(DateTimeUtility.GetDateTime))
471480
};
472-
var request = new CreateResponseRequest(conversation, Model.GPT4_1_Nano, tools: tools);
481+
var request = new CreateResponseRequest(conversation, Model.GPT5_Nano, tools: tools);
473482

474483
async Task StreamCallback(string @event, IServerSentEvent sseEvent)
475484
{
@@ -482,7 +491,7 @@ async Task StreamCallback(string @event, IServerSentEvent sseEvent)
482491
conversation.Add(functionToolCall);
483492
var output = await functionToolCall.InvokeFunctionAsync();
484493
conversation.Add(output);
485-
await api.ResponsesEndpoint.CreateModelResponseAsync(new(conversation, Model.GPT4_1_Nano, tools: tools, toolChoice: "none"), StreamCallback);
494+
await api.ResponsesEndpoint.CreateModelResponseAsync(new(conversation, Model.GPT5_Nano, tools: tools, toolChoice: "none"), StreamCallback);
486495
break;
487496
}
488497
}
@@ -541,6 +550,120 @@ Assert.IsTrue(isDeleted);
541550

542551
---
543552

553+
### [Conversations](https://platform.openai.com/docs/api-reference/conversations)
554+
555+
Create and manage conversations to store and retrieve conversation state across Response API calls.
556+
557+
The Conversations API is accessed via `OpenAIClient.ConversationsEndpoint`
558+
559+
#### [Create Conversation](https://platform.openai.com/docs/api-reference/conversations/create)
560+
561+
Create a conversation.
562+
563+
```csharp
564+
var api = new OpenAIClient();
565+
conversation = await api.ConversationsEndpoint.CreateConversationAsync(
566+
new CreateConversationRequest(new Message(Role.Developer, systemPrompt)));
567+
Debug.Log(conversation.ToString());
568+
// use the conversation object when creating responses.
569+
var request = await api.ResponsesEndpoint.CreateResponseAsync(
570+
new CreateResponseRequest(textInput: "Hello!", conversationId: conversation, model: Model.GPT5_Nano));
571+
var response = await openAI.ResponsesEndpoint.CreateModelResponseAsync(request);
572+
var responseItem = response.Output.LastOrDefault();
573+
Debug.Log($"{responseItem.Role}:{responseItem}");
574+
response.PrintUsage();
575+
```
576+
577+
#### [Retrieve Conversation](https://platform.openai.com/docs/api-reference/conversations/retrieve)
578+
579+
Get a conversation by id.
580+
581+
```csharp
582+
var api = new OpenAIClient();
583+
var conversation = await api.ConversationsEndpoint.GetConversationAsync("conversation-id");
584+
Debug.Log(conversation.ToString());
585+
```
586+
587+
#### [Update Conversation](https://platform.openai.com/docs/api-reference/conversations/update)
588+
589+
Update a conversation with custom metadata.
590+
591+
```csharp
592+
var api = new OpenAIClient();
593+
var metadata = new Dictionary<string, object>
594+
{
595+
{ "favorite_color", "blue" },
596+
{ "favorite_food", "pizza" }
597+
};
598+
var updatedConversation = await api.ConversationsEndpoint.UpdateConversationAsync("conversation-id", metadata);
599+
```
600+
601+
#### [Delete Conversation](https://platform.openai.com/docs/api-reference/conversations/delete)
602+
603+
Delete a conversation by id.
604+
605+
```csharp
606+
var api = new OpenAIClient();
607+
var isDeleted = await api.ConversationsEndpoint.DeleteConversationAsync("conversation-id");
608+
Assert.IsTrue(isDeleted);
609+
```
610+
611+
#### [List Conversation Items](https://platform.openai.com/docs/api-reference/conversations/list-items)
612+
613+
List all items for a conversation with the given ID.
614+
615+
```csharp
616+
var api = new OpenAIClient();
617+
var query = new ListQuery(limit: 10);
618+
var items = await api.ConversationsEndpoint.ListConversationItemsAsync("conversation-id", query);
619+
620+
foreach (var item in items)
621+
{
622+
Debug.Log(item.ToJsonString());
623+
}
624+
```
625+
626+
#### [Create Conversation Item](https://platform.openai.com/docs/api-reference/conversations/create-item)
627+
628+
Create a new conversation item for a conversation with the given ID.
629+
630+
```csharp
631+
var api = new OpenAIClient();
632+
var items = new List<IResponseItem>
633+
{
634+
new Message(Role.User, "Hello!"),
635+
new Message(Role.Assistant, "Hi! How can I help you?")
636+
}
637+
var addedItems = await api.ConversationsEndpoint.CreateConversationItemsAsync("conversation-id", items);
638+
639+
foreach (var item in addedItems)
640+
{
641+
Debug.Log(item.ToJsonString());
642+
}
643+
```
644+
645+
#### [Retrieve Conversation Item](https://platform.openai.com/docs/api-reference/conversations/retrieve-item)
646+
647+
Get a conversation item by id.
648+
649+
```csharp
650+
var api = new OpenAIClient();
651+
var item = await api.ConversationsEndpoint.GetConversationItemAsync("conversation-id", "item-id");
652+
Debug.Log(item.ToJsonString());
653+
```
654+
655+
#### [Delete Conversation Item](https://platform.openai.com/docs/api-reference/conversations/delete-item)
656+
657+
Delete a conversation item by id.
658+
659+
```csharp
660+
var api = new OpenAIClient();
661+
var isDeleted = await api.ConversationsEndpoint.DeleteConversationItemAsync("conversation-id", "item-id");
662+
Assert.IsTrue(isDeleted);
663+
```
664+
665+
---
666+
544667
### [Realtime](https://platform.openai.com/docs/api-reference/realtime)
545668

546669
> [!WARNING]
@@ -903,7 +1026,8 @@ Debug.Log($"Retrieve thread {thread.Id} -> {thread.CreatedAt}");
9031026

9041027
Modifies a thread.
9051028

906-
> Note: Only the metadata can be modified.
1029+
> [!NOTE]
1030+
> Only the metadata can be modified.
9071031
9081032
```csharp
9091033
var api = new OpenAIClient();
@@ -981,7 +1105,8 @@ Debug.Log($"{message.Id}: {message.Role}: {message.PrintContent()}");
9811105

9821106
Modify a message.
9831107

984-
> Note: Only the message metadata can be modified.
1108+
> [!NOTE]
1109+
> Only the message metadata can be modified.
9851110
9861111
```csharp
9871112
var api = new OpenAIClient();
@@ -1076,7 +1201,8 @@ Debug.Log($"[{run.Id}] {run.Status} | {run.CreatedAt}");
10761201

10771202
Modifies a run.
10781203

1079-
> Note: Only the metadata can be modified.
1204+
> [!NOTE]
1205+
> Only the metadata can be modified.
10801206
10811207
```csharp
10821208
var api = new OpenAIClient();
@@ -1795,7 +1921,7 @@ Generates audio from the input text.
17951921
```csharp
17961922
var api = new OpenAIClient();
17971923
var request = new SpeechRequest("Hello world!");
1798-
var speechClip = await api.AudioEndpoint.CreateSpeechAsync(request);
1924+
var speechClip = await api.AudioEndpoint.GetSpeechAsync(request);
17991925
audioSource.PlayOneShot(speechClip);
18001926
Debug.Log(speechClip);
18011927
```
@@ -1807,7 +1933,7 @@ Generate streamed audio from the input text.
18071933
```csharp
18081934
var api = new OpenAIClient();
18091935
var request = new SpeechRequest("Hello world!", responseFormat: SpeechResponseFormat.PCM);
1810-
var speechClip = await api.AudioEndpoint.CreateSpeechStreamAsync(request, partialClip =>
1936+
var speechClip = await api.AudioEndpoint.GetSpeechAsync(request, partialClip =>
18111937
{
18121938
audioSource.PlayOneShot(partialClip);
18131939
});

OpenAI/Packages/com.openai.unity/Runtime/Assistants/AssistantResponse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ internal AssistantResponse(
2424
[JsonProperty("description")] string description,
2525
[JsonProperty("model")] string model,
2626
[JsonProperty("instructions")] string instructions,
27-
[JsonProperty("tools")] IReadOnlyList<Tool> tools,
27+
[JsonProperty("tools")] List<Tool> tools,
2828
[JsonProperty("tool_resources")] ToolResources toolResources,
2929
[JsonProperty("metadata")] Dictionary<string, string> metadata,
3030
[JsonProperty("temperature")] float? temperature,

0 commit comments

Comments
 (0)