Skip to content

Commit cfe9902

Browse files
committed
fix: Fixed issues.
1 parent 9004782 commit cfe9902

File tree

7 files changed

+7
-37
lines changed

7 files changed

+7
-37
lines changed

helpers/TrimmingHelper/Program.cs

Lines changed: 0 additions & 1 deletion
This file was deleted.

helpers/TrimmingHelper/TrimmingHelper.csproj

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/Custom/Embeddings/EmbeddingClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public virtual async Task<ClientResult<OpenAIEmbeddingCollection>> GenerateEmbed
182182
Argument.AssertNotNullOrEmpty(inputs, nameof(inputs));
183183

184184
options ??= new();
185-
CreateEmbeddingGenerationOptions(BinaryData.FromObjectAsJson(inputs, SourceGenerationContext.Default.IEnumerableIEnumerableInt32), ref options);
185+
CreateEmbeddingGenerationOptions(BinaryData.FromObjectAsJson(inputs, SourceGenerationContext.Default.IEnumerableReadOnlyMemoryInt32), ref options);
186186

187187
using BinaryContent content = options.ToBinaryContent();
188188
ClientResult result = await GenerateEmbeddingsAsync(content, cancellationToken.ToRequestOptions()).ConfigureAwait(false);
@@ -201,7 +201,7 @@ public virtual ClientResult<OpenAIEmbeddingCollection> GenerateEmbeddings(IEnume
201201
Argument.AssertNotNullOrEmpty(inputs, nameof(inputs));
202202

203203
options ??= new();
204-
CreateEmbeddingGenerationOptions(BinaryData.FromObjectAsJson(inputs, SourceGenerationContext.Default.IEnumerableIEnumerableInt32), ref options);
204+
CreateEmbeddingGenerationOptions(BinaryData.FromObjectAsJson(inputs, SourceGenerationContext.Default.IEnumerableReadOnlyMemoryInt32), ref options);
205205

206206
using BinaryContent content = options.ToBinaryContent();
207207
ClientResult result = GenerateEmbeddings(content, cancellationToken.ToRequestOptions());

src/Custom/OpenAIModelFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static OpenAIEmbeddingCollection OpenAIEmbeddingCollection(IEnumerable<Op
3030
public static OpenAIEmbedding OpenAIEmbedding(ReadOnlyMemory<float> vector = default, int index = default)
3131
{
3232
// TODO: Vector must be converted to base64-encoded string.
33-
return new OpenAIEmbedding(index, BinaryData.FromObjectAsJson(vector), InternalEmbeddingObject.Embedding, serializedAdditionalRawData: null);
33+
return new OpenAIEmbedding(index, BinaryData.FromObjectAsJson(vector, SourceGenerationContext.Default.ReadOnlyMemorySingle), InternalEmbeddingObject.Embedding, serializedAdditionalRawData: null);
3434
}
3535

3636
}

src/Generated/Internal/ModelSerializationExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace OpenAI
1515
internal static class ModelSerializationExtensions
1616
{
1717
internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W");
18-
internal static readonly BinaryData SentinelValue = BinaryData.FromObjectAsJson("__EMPTY__");
18+
internal static readonly BinaryData SentinelValue = BinaryData.FromObjectAsJson("__EMPTY__", SourceGenerationContext.Default.String);
1919

2020
public static object GetObject(this JsonElement element)
2121
{

src/OpenAI.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<VersionPrefix>2.1.0</VersionPrefix>
1010
<VersionSuffix>beta.2</VersionSuffix>
1111

12-
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
12+
<TargetFrameworks>netstandard2.0;net6.0;net8.0</TargetFrameworks>
1313
<LangVersion>latest</LangVersion>
1414

1515
<!-- Generate an XML documentation file for the project. -->
@@ -78,5 +78,6 @@
7878
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
7979
<PackageReference Include="System.ClientModel" Version="1.2.1" />
8080
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="6.0.1" />
81+
<PackageReference Include="System.Memory.Data" Version="9.0.0" />
8182
</ItemGroup>
8283
</Project>

src/SourceGenerationContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ namespace OpenAI;
77
[JsonSourceGenerationOptions]
88
[JsonSerializable(typeof(string))]
99
[JsonSerializable(typeof(IEnumerable<string>))]
10-
[JsonSerializable(typeof(IEnumerable<IEnumerable<int>>))]
10+
[JsonSerializable(typeof(IEnumerable<ReadOnlyMemory<int>>))]
1111
[JsonSerializable(typeof(ReadOnlyMemory<float>))]
1212
internal sealed partial class SourceGenerationContext : JsonSerializerContext;

0 commit comments

Comments
 (0)