From 252fe1b6590961379016b336218ba97efb214cde Mon Sep 17 00:00:00 2001 From: Stephen Hodgson Date: Sat, 23 Dec 2023 15:23:03 -0500 Subject: [PATCH] com.openai.unity 7.2.1 (#156) - fix ImageResult.CacheedPath calculation --- Runtime/Images/ImageResult.cs | 8 ++++---- Runtime/Images/ImagesEndpoint.cs | 13 +++++++++---- package.json | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Runtime/Images/ImageResult.cs b/Runtime/Images/ImageResult.cs index 4e79d4de..33daf9fc 100644 --- a/Runtime/Images/ImageResult.cs +++ b/Runtime/Images/ImageResult.cs @@ -55,14 +55,14 @@ public override string ToString() return CachedPath; } - if (!string.IsNullOrWhiteSpace(Url)) + if (!string.IsNullOrWhiteSpace(B64_Json)) { - return Url; + return B64_Json; } - if (!string.IsNullOrWhiteSpace(B64_Json)) + if (!string.IsNullOrWhiteSpace(Url)) { - return B64_Json; + return Url; } return string.Empty; diff --git a/Runtime/Images/ImagesEndpoint.cs b/Runtime/Images/ImagesEndpoint.cs index f482e730..39d4530a 100644 --- a/Runtime/Images/ImagesEndpoint.cs +++ b/Runtime/Images/ImagesEndpoint.cs @@ -133,16 +133,21 @@ async Task DownloadAsync(ImageResult result) } result.Texture = await Rest.DownloadTextureAsync(localFilePath, debug: EnableDebug, cancellationToken: cancellationToken); + + if (Rest.TryGetDownloadCacheItem(result.B64_Json, out var cachedPath)) + { + result.CachedPath = cachedPath; + } #endif } else { result.Texture = await Rest.DownloadTextureAsync(result.Url, debug: EnableDebug, cancellationToken: cancellationToken); - } - if (Rest.TryGetDownloadCacheItem(result, out var cachedPath)) - { - result.CachedPath = cachedPath; + if (Rest.TryGetDownloadCacheItem(result.Url, out var cachedPath)) + { + result.CachedPath = cachedPath; + } } } diff --git a/package.json b/package.json index 73079c7b..30686f09 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": "7.2.0", + "version": "7.2.1", "unity": "2021.3", "documentationUrl": "https://github.com/RageAgainstThePixel/com.openai.unity#documentation", "changelogUrl": "https://github.com/RageAgainstThePixel/com.openai.unity/releases",