Skip to content

Instantly share code, notes, and snippets.

@dontpaniclabsgists
Created May 6, 2024 14:45
Show Gist options
  • Save dontpaniclabsgists/e45ca49102e5017b2986914be5955b7c to your computer and use it in GitHub Desktop.
Save dontpaniclabsgists/e45ca49102e5017b2986914be5955b7c to your computer and use it in GitHub Desktop.
const string model = "text-embedding-3-small";
const string apiKey = "<YOUR_API_KEY>";
using (var api = new OpenAIClient(apiKey))
{
foreach (var review in reviews)
{
var response = await api.EmbeddingsEndpoint
.CreateEmbeddingAsync(review.Combined, model, dimensions: 512);
review.Embeddings = response.Data.First().Embedding
.Select(e => (float)e).ToArray();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment