Skip to content

Commit

Permalink
com.openai.unity 7.1.3 (#152)
Browse files Browse the repository at this point in the history
- Fixed dictionary metadata deserialization for AOT platforms
  • Loading branch information
StephenHodgson authored Dec 17, 2023
1 parent eb849d7 commit 2f6a666
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

using OpenAI.Files;
using OpenAI.Threads;
using System.Threading.Tasks;
using System.Threading;
using System.Threading.Tasks;

namespace OpenAI.Assistants
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Licensed under the MIT License. See LICENSE in the project root for license information.

using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using UnityEngine.Scripting;

namespace OpenAI.Assistants
Expand All @@ -25,7 +25,7 @@ public AssistantResponse(
string instructions,
IReadOnlyList<Tool> tools,
IReadOnlyList<string> fileIds,
IReadOnlyDictionary<string, string> metadata)
Dictionary<string, string> metadata)
{
Id = id;
Object = @object;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Licensed under the MIT License. See LICENSE in the project root for license information.

using Newtonsoft.Json;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using UnityEngine.Scripting;

namespace OpenAI.Assistants
Expand Down Expand Up @@ -48,7 +48,14 @@ public sealed class CreateAssistantRequest
/// </param>
[Preserve]
public CreateAssistantRequest(AssistantResponse assistant, string model = null, string name = null, string description = null, string instructions = null, IEnumerable<Tool> tools = null, IEnumerable<string> files = null, IReadOnlyDictionary<string, string> metadata = null)
: this(string.IsNullOrWhiteSpace(model) ? assistant.Model : model, string.IsNullOrWhiteSpace(name) ? assistant.Name : name, string.IsNullOrWhiteSpace(description) ? assistant.Description : description, string.IsNullOrWhiteSpace(instructions) ? assistant.Instructions : instructions, tools ?? assistant.Tools, files ?? assistant.FileIds, metadata ?? assistant.Metadata)
: this(
string.IsNullOrWhiteSpace(model) ? assistant.Model : model,
string.IsNullOrWhiteSpace(name) ? assistant.Name : name,
string.IsNullOrWhiteSpace(description) ? assistant.Description : description,
string.IsNullOrWhiteSpace(instructions) ? assistant.Instructions : instructions,
tools ?? assistant.Tools,
files ?? assistant.FileIds,
metadata ?? assistant.Metadata)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public sealed class CreateThreadRequest
[Preserve]
public CreateThreadRequest(
[JsonProperty("messages")] IEnumerable<Message> messages = null,
[JsonProperty("metadata")] IReadOnlyDictionary<string, string> metadata = null)
[JsonProperty("metadata")] Dictionary<string, string> metadata = null)
{
Messages = messages?.ToList();
Metadata = metadata;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public sealed class Message
/// Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.
/// </param>
[Preserve]
public Message(string content, IEnumerable<string> fileIds = null, IReadOnlyDictionary<string, string> metadata = null)
public Message(string content, IEnumerable<string> fileIds = null, Dictionary<string, string> metadata = null)
{
Role = Role.User;
Content = content;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public MessageResponse(
[JsonProperty("assistant_id")] string assistantId,
[JsonProperty("run_id")] string runId,
[JsonProperty("file_ids")] IReadOnlyList<string> fileIds,
[JsonProperty("metadata")] IReadOnlyDictionary<string, string> metadata)
[JsonProperty("metadata")] Dictionary<string, string> metadata)
{
Id = id;
Object = @object;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public RunResponse(
[JsonProperty("instructions")] string instructions,
[JsonProperty("tools")] IReadOnlyList<Tool> tools,
[JsonProperty("file_ids")] IReadOnlyList<string> fileIds,
[JsonProperty("metadata")] IReadOnlyDictionary<string, string> metadata)
[JsonProperty("metadata")] Dictionary<string, string> metadata)
{
Id = id;
Object = @object;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Licensed under the MIT License. See LICENSE in the project root for license information.

using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using UnityEngine.Scripting;

namespace OpenAI.Threads
Expand Down Expand Up @@ -31,7 +31,7 @@ public RunStepResponse(
[JsonProperty("expires_at")] int? expiresAtUnixTimeSeconds,
[JsonProperty("cancelled_at")] int? cancelledAtUnixTimeSeconds,
[JsonProperty("failed_at")] int? failedAtUnixTimeSeconds,
[JsonProperty("metadata")] IReadOnlyDictionary<string, string> metadata)
[JsonProperty("metadata")] Dictionary<string, string> metadata)
{
Id = id;
Object = @object;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public ThreadResponse(
[JsonProperty("id")] string id,
[JsonProperty("object")] string @object,
[JsonProperty("created_at")] int createdAtUnitTimeSeconds,
[JsonProperty("metadata")] IReadOnlyDictionary<string, string> metadata)
[JsonProperty("metadata")] Dictionary<string, string> metadata)
{
Id = id;
Object = @object;
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.2",
"version": "7.1.3",
"unity": "2021.3",
"documentationUrl": "https://github.com/RageAgainstThePixel/com.openai.unity#documentation",
"changelogUrl": "https://github.com/RageAgainstThePixel/com.openai.unity/releases",
Expand Down

0 comments on commit 2f6a666

Please sign in to comment.