Skip to content

Commit

Permalink
com.openai.unity 7.1.2 (#151)
Browse files Browse the repository at this point in the history
- attempt to fix some serialization errors
- fixed some unit tests
  • Loading branch information
StephenHodgson authored Dec 16, 2023
1 parent 589e5cb commit eb849d7
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion OpenAI/Packages/com.openai.unity/Runtime/Chat/Delta.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public Delta(
/// The contents of the message.
/// </summary>
[Preserve]
[JsonProperty("content")]
[JsonProperty("content", DefaultValueHandling = DefaultValueHandling.Populate, NullValueHandling = NullValueHandling.Include)]
public string Content { get; private set; }

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion OpenAI/Packages/com.openai.unity/Runtime/Chat/Message.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public Message(Role role, string content, string name, Function function)
public Message(Role role, IEnumerable<Content> content, string name = null)
{
Role = role;
Content = content.ToList();
Content = content?.ToList();
Name = name;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public Annotation(
/// The text in the message content that needs to be replaced.
/// </summary>
[Preserve]
[JsonProperty("text")]
[JsonProperty("text", DefaultValueHandling = DefaultValueHandling.Populate, NullValueHandling = NullValueHandling.Include)]
public string Text { get; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public CreateMessageRequest(string content, IEnumerable<string> fieldIds = null,
/// The content of the message.
/// </summary>
[Preserve]
[JsonProperty("content")]
[JsonProperty("content", DefaultValueHandling = DefaultValueHandling.Populate, NullValueHandling = NullValueHandling.Include)]
public string Content { get; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ public sealed class CreateThreadRequest
/// Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.
/// </param>
[Preserve]
public CreateThreadRequest(IEnumerable<Message> messages = null,
IReadOnlyDictionary<string, string> metadata = null)
public CreateThreadRequest(
[JsonProperty("messages")] IEnumerable<Message> messages = null,
[JsonProperty("metadata")] IReadOnlyDictionary<string, string> metadata = null)
{
Messages = messages?.ToList();
Metadata = metadata;
Expand All @@ -45,6 +46,7 @@ public CreateThreadRequest(IEnumerable<Message> messages = null,
[JsonProperty("metadata")]
public IReadOnlyDictionary<string, string> Metadata { get; }

[Preserve]
public static implicit operator CreateThreadRequest(string message) => new CreateThreadRequest(new[] { new Message(message) });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public Message(string content, IEnumerable<string> fileIds = null, IReadOnlyDict
/// The content of the message.
/// </summary>
[Preserve]
[JsonProperty("content")]
[JsonProperty("content", DefaultValueHandling = DefaultValueHandling.Populate, NullValueHandling = NullValueHandling.Include)]
public string Content { get; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace OpenAI.Threads
[Preserve]
public sealed class MessageResponse : BaseResponse
{
[Preserve]
[JsonConstructor]
public MessageResponse(
[JsonProperty("id")] string id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public TextContent(
/// The data that makes up the text.
/// </summary>
[Preserve]
[JsonProperty("value")]
[JsonProperty("value", DefaultValueHandling = DefaultValueHandling.Populate, NullValueHandling = NullValueHandling.Include)]
public string Value { get; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public async Task Test_04_01_UploadAssistantFile()
const string testFilePath = "assistant_test_2.txt";
await File.WriteAllTextAsync(testFilePath, "Knowledge is power!");
Assert.IsTrue(File.Exists(testFilePath));
var file = testAssistant.UploadFileAsync(testFilePath);
var file = await testAssistant.UploadFileAsync(testFilePath);
Assert.IsNotNull(file);
}

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

foreach (var file in filesList.Items)
{
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.1.1",
"version": "7.1.2",
"unity": "2021.3",
"documentationUrl": "https://github.com/RageAgainstThePixel/com.openai.unity#documentation",
"changelogUrl": "https://github.com/RageAgainstThePixel/com.openai.unity/releases",
Expand Down
2 changes: 1 addition & 1 deletion OpenAI/ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ PlayerSettings:
tvOS: 0
overrideDefaultApplicationIdentifier: 1
AndroidBundleVersionCode: 1
AndroidMinSdkVersion: 22
AndroidMinSdkVersion: 25
AndroidTargetSdkVersion: 0
AndroidPreferredInstallLocation: 1
aotOptions:
Expand Down

0 comments on commit eb849d7

Please sign in to comment.