-
Notifications
You must be signed in to change notification settings - Fork 89
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
Is it possible to allow changes to the encoding_format
of the embedded options?
#51
Comments
Thank you for reaching out, @JadynWong ! Presently, it is not in our plans to expose the As you have correctly pointed out, you can use the EmbeddingClient client = new("text-embedding-3-small", Environment.GetEnvironmentVariable("OPENAI_API_KEY"));
string description = "Best hotel in town if you like luxury hotels. They have an amazing infinity pool, a spa,"
+ " and a really helpful concierge. The location is perfect -- right downtown, close to all the tourist"
+ " attractions. We highly recommend this hotel.";
BinaryData input = BinaryData.FromObjectAsJson(new
{
model = "text-embedding-3-small",
input = description,
encoding_format = "float"
});
using BinaryContent content = BinaryContent.Create(input);
ClientResult result = await client.GenerateEmbeddingsAsync(content);
BinaryData output = result.GetRawResponse().Content;
using JsonDocument outputAsJson = JsonDocument.Parse(output.ToString());
JsonElement vector = outputAsJson.RootElement
.GetProperty("data"u8)[0]
.GetProperty("embedding"u8);
Console.WriteLine($"Dimension: {vector.GetArrayLength()}");
Console.WriteLine($"Floats: ");
int i = 0;
foreach (JsonElement element in vector.EnumerateArray())
{
Console.WriteLine($" [{i++,4}] = {element.GetDouble()}");
} Note that, when using protocol methods, the input and output (represented as I have also created the following PR to add this example to our suite: 🔗 #122 |
Currently
EmbeddingClient
fixes theencoding_format
value to base64 for better performance.openai-dotnet/src/Custom/Embeddings/EmbeddingGenerationOptions.cs
Lines 77 to 82 in 45fc4d7
openai-dotnet/src/Custom/Embeddings/Embedding.cs
Lines 75 to 84 in 45fc4d7
It can't be changed, even if I want to use float format. I want to use this client for text-embeddings-inference, which currently does not support the
encoding_format
parameter.This results in the following error
I know that
encoding_format
compatibility would be a better approach in other projects, but a lot of compatible openai api's don't update as fast as they should.Is it possible to allow users to change the
encoding_format
value?Of course, as the official SDK of OpenAI, I would respect it if it was only compatible with OpenAI.
For now I can serialize it myself using protocol methods.
The text was updated successfully, but these errors were encountered: