Skip to content

Commit eb849d7

Browse files
com.openai.unity 7.1.2 (#151)
- attempt to fix some serialization errors - fixed some unit tests
1 parent 589e5cb commit eb849d7

File tree

11 files changed

+15
-11
lines changed

11 files changed

+15
-11
lines changed

OpenAI/Packages/com.openai.unity/Runtime/Chat/Delta.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public Delta(
5151
/// The contents of the message.
5252
/// </summary>
5353
[Preserve]
54-
[JsonProperty("content")]
54+
[JsonProperty("content", DefaultValueHandling = DefaultValueHandling.Populate, NullValueHandling = NullValueHandling.Include)]
5555
public string Content { get; private set; }
5656

5757
/// <summary>

OpenAI/Packages/com.openai.unity/Runtime/Chat/Message.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public Message(Role role, string content, string name, Function function)
4242
public Message(Role role, IEnumerable<Content> content, string name = null)
4343
{
4444
Role = role;
45-
Content = content.ToList();
45+
Content = content?.ToList();
4646
Name = name;
4747
}
4848

OpenAI/Packages/com.openai.unity/Runtime/Threads/Annotation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public Annotation(
3434
/// The text in the message content that needs to be replaced.
3535
/// </summary>
3636
[Preserve]
37-
[JsonProperty("text")]
37+
[JsonProperty("text", DefaultValueHandling = DefaultValueHandling.Populate, NullValueHandling = NullValueHandling.Include)]
3838
public string Text { get; }
3939

4040
/// <summary>

OpenAI/Packages/com.openai.unity/Runtime/Threads/CreateMessageRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public CreateMessageRequest(string content, IEnumerable<string> fieldIds = null,
4242
/// The content of the message.
4343
/// </summary>
4444
[Preserve]
45-
[JsonProperty("content")]
45+
[JsonProperty("content", DefaultValueHandling = DefaultValueHandling.Populate, NullValueHandling = NullValueHandling.Include)]
4646
public string Content { get; }
4747

4848
/// <summary>

OpenAI/Packages/com.openai.unity/Runtime/Threads/CreateThreadRequest.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ public sealed class CreateThreadRequest
2222
/// Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.
2323
/// </param>
2424
[Preserve]
25-
public CreateThreadRequest(IEnumerable<Message> messages = null,
26-
IReadOnlyDictionary<string, string> metadata = null)
25+
public CreateThreadRequest(
26+
[JsonProperty("messages")] IEnumerable<Message> messages = null,
27+
[JsonProperty("metadata")] IReadOnlyDictionary<string, string> metadata = null)
2728
{
2829
Messages = messages?.ToList();
2930
Metadata = metadata;
@@ -45,6 +46,7 @@ public CreateThreadRequest(IEnumerable<Message> messages = null,
4546
[JsonProperty("metadata")]
4647
public IReadOnlyDictionary<string, string> Metadata { get; }
4748

49+
[Preserve]
4850
public static implicit operator CreateThreadRequest(string message) => new CreateThreadRequest(new[] { new Message(message) });
4951
}
5052
}

OpenAI/Packages/com.openai.unity/Runtime/Threads/Message.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public Message(string content, IEnumerable<string> fileIds = null, IReadOnlyDict
4949
/// The content of the message.
5050
/// </summary>
5151
[Preserve]
52-
[JsonProperty("content")]
52+
[JsonProperty("content", DefaultValueHandling = DefaultValueHandling.Populate, NullValueHandling = NullValueHandling.Include)]
5353
public string Content { get; }
5454

5555
/// <summary>

OpenAI/Packages/com.openai.unity/Runtime/Threads/MessageResponse.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace OpenAI.Threads
1616
[Preserve]
1717
public sealed class MessageResponse : BaseResponse
1818
{
19+
[Preserve]
1920
[JsonConstructor]
2021
public MessageResponse(
2122
[JsonProperty("id")] string id,

OpenAI/Packages/com.openai.unity/Runtime/Threads/TextContent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public TextContent(
2323
/// The data that makes up the text.
2424
/// </summary>
2525
[Preserve]
26-
[JsonProperty("value")]
26+
[JsonProperty("value", DefaultValueHandling = DefaultValueHandling.Populate, NullValueHandling = NullValueHandling.Include)]
2727
public string Value { get; }
2828

2929
/// <summary>

OpenAI/Packages/com.openai.unity/Tests/TestFixture_11_Assistants.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public async Task Test_04_01_UploadAssistantFile()
9393
const string testFilePath = "assistant_test_2.txt";
9494
await File.WriteAllTextAsync(testFilePath, "Knowledge is power!");
9595
Assert.IsTrue(File.Exists(testFilePath));
96-
var file = testAssistant.UploadFileAsync(testFilePath);
96+
var file = await testAssistant.UploadFileAsync(testFilePath);
9797
Assert.IsNotNull(file);
9898
}
9999

@@ -105,6 +105,7 @@ public async Task Test_04_02_ListAssistantFiles()
105105
var filesList = await testAssistant.ListFilesAsync();
106106
Assert.IsNotNull(filesList);
107107
Assert.IsNotEmpty(filesList.Items);
108+
Assert.IsTrue(filesList.Items.Count == 2);
108109

109110
foreach (var file in filesList.Items)
110111
{

OpenAI/Packages/com.openai.unity/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.1.1",
6+
"version": "7.1.2",
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)