From be0c518cadbca261586a37970d7bf742b3c546b0 Mon Sep 17 00:00:00 2001 From: Stephen Hodgson Date: Sat, 14 Sep 2024 17:31:25 -0400 Subject: [PATCH] com.openai.unity 8.2.5 (#296) - Fixed ResponseObjectFormat deserialization when maxNumberOfResults is null --- Runtime/Common/FileSearchOptions.cs | 9 +++++---- package.json | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Runtime/Common/FileSearchOptions.cs b/Runtime/Common/FileSearchOptions.cs index 3f7f6de5..9cae4fce 100644 --- a/Runtime/Common/FileSearchOptions.cs +++ b/Runtime/Common/FileSearchOptions.cs @@ -12,11 +12,12 @@ public sealed class FileSearchOptions [Preserve] [JsonConstructor] public FileSearchOptions( - [JsonProperty("max_num_results")] int maxNumberOfResults, + [JsonProperty("max_num_results")] int? maxNumberOfResults, [JsonProperty("ranking_options")] RankingOptions rankingOptions = null) { MaxNumberOfResults = maxNumberOfResults switch { + null => null, < 1 => throw new ArgumentOutOfRangeException(nameof(maxNumberOfResults), "Max number of results must be greater than 0."), > 50 => throw new ArgumentOutOfRangeException(nameof(maxNumberOfResults), "Max number of results must be less than 50."), _ => maxNumberOfResults @@ -25,11 +26,11 @@ public FileSearchOptions( } [Preserve] - [JsonProperty("max_num_results")] - public int MaxNumberOfResults { get; } + [JsonProperty("max_num_results", DefaultValueHandling = DefaultValueHandling.Ignore)] + public int? MaxNumberOfResults { get; } [Preserve] - [JsonProperty("ranking_options")] + [JsonProperty("ranking_options", DefaultValueHandling = DefaultValueHandling.Ignore)] public RankingOptions RankingOptions { get; } } } diff --git a/package.json b/package.json index 9e48c80d..5320d1f5 100644 --- a/package.json +++ b/package.json @@ -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": "8.2.4", + "version": "8.2.5", "unity": "2021.3", "documentationUrl": "https://github.com/RageAgainstThePixel/com.openai.unity#documentation", "changelogUrl": "https://github.com/RageAgainstThePixel/com.openai.unity/releases",