Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging of @Metjuperry: Added embedding endpoint and tests #38

Merged
merged 4 commits into from
Feb 3, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Updated EmbeddingResult.Data to be a List rather than an array
OkGoDoIt committed Feb 3, 2023
commit 0788505677795c46aa417b711f75f4c22c7c1bc7
3 changes: 2 additions & 1 deletion OpenAI_API/Embedding/EmbeddingResult.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Linq;

namespace OpenAI_API.Embedding
@@ -12,7 +13,7 @@ public class EmbeddingResult : ApiResultBase
/// List of results of the embedding
/// </summary>
[JsonProperty("data")]
public Data[] Data { get; set; }
public List<Data> Data { get; set; }

/// <summary>
/// Usage statistics of how many tokens have been used for this request
2 changes: 1 addition & 1 deletion OpenAI_Tests/EmbeddingEndpointTests.cs
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ public void GetBasicEmbedding()
var results = api.Embeddings.CreateEmbeddingAsync(new EmbeddingRequest(Model.AdaTextEmbedding, "A test text for embedding")).Result;
Assert.IsNotNull(results);
Assert.NotNull(results.Object);
Assert.NotZero(results.Data.Length);
Assert.NotZero(results.Data.Count);
Assert.That(results.Data.First().Embedding.Length == 1536);
}