diff --git a/OpenAI/Packages/com.openai.unity/Runtime/Images/ImageResult.cs b/OpenAI/Packages/com.openai.unity/Runtime/Images/ImageResult.cs index 4e79d4de..33daf9fc 100644 --- a/OpenAI/Packages/com.openai.unity/Runtime/Images/ImageResult.cs +++ b/OpenAI/Packages/com.openai.unity/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/OpenAI/Packages/com.openai.unity/Runtime/Images/ImagesEndpoint.cs b/OpenAI/Packages/com.openai.unity/Runtime/Images/ImagesEndpoint.cs index f482e730..39d4530a 100644 --- a/OpenAI/Packages/com.openai.unity/Runtime/Images/ImagesEndpoint.cs +++ b/OpenAI/Packages/com.openai.unity/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/OpenAI/Packages/com.openai.unity/package.json b/OpenAI/Packages/com.openai.unity/package.json index 73079c7b..30686f09 100644 --- a/OpenAI/Packages/com.openai.unity/package.json +++ b/OpenAI/Packages/com.openai.unity/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",