Skip to content

Commit 0579d42

Browse files
prathikrPrathik Rao
andauthored
fixes netstandard2.0 bug in embeddings request response types (#675)
``` E:\_work\1\s\sdk\cs\src\OpenAI\EmbeddingRequestResponseTypes.cs(60,16): error CS8604: Possible null reference argument for parameter 'responseData' in 'EmbeddingCreateResponse EmbeddingRequestResponseExtensions.ToEmbeddingResponse(string responseData, ILogger logger)'. [E:\_work\1\s\sdk\cs\src\Microsoft.AI.Foundry.Local.csproj::TargetFramework=netstandard2.0] ``` The null check string.IsNullOrWhiteSpace doesn't narrow the nullable type under netstandard2.0's annotations. Needs to be response.Data! to avoid error but we know it's not null or whitespace due to the check above. Co-authored-by: Prathik Rao <prathikrao@microsoft.com>
1 parent 857aa22 commit 0579d42

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

sdk/cs/src/OpenAI/EmbeddingRequestResponseTypes.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ internal static EmbeddingCreateResponse ToEmbeddingResponse(this ICoreInterop.Re
5757
throw new FoundryLocalException("Embeddings command returned null or empty response data");
5858
}
5959

60-
return response.Data.ToEmbeddingResponse(logger);
60+
return response.Data!.ToEmbeddingResponse(logger);
6161
}
6262

6363
internal static EmbeddingCreateResponse ToEmbeddingResponse(this string responseData, ILogger logger)

sdk/cs/test/FoundryLocal.Tests/EmbeddingClientTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace Microsoft.AI.Foundry.Local.Tests;
88

99
using System.Threading.Tasks;
1010

11+
[SkipUnlessIntegration]
1112
internal sealed class EmbeddingClientTests
1213
{
1314
private static IModel? model;

0 commit comments

Comments
 (0)