Reputation: 77
I have seen this question before but i couldn't find a answer that helped my case, but somebody can probably find a way, so i came to ask here. When i run this code:
public static async Task<List<float>> GetEmbedding(string input, CancellationToken cancellationToken = default)
{
string embeddingModel = "text-embedding-3-small";
// Get GoogleAI
GoogleAI googleAI = new(apiKey: "apikey");
// Make the Generative model
googleAI.GenerativeModel(embeddingModel);
GenerativeModel model = googleAI.GenerativeModel(embeddingModel);
// Embed the content
EmbedContentResponse embedding = new EmbedContentResponse();
try
{
embedding = await model.EmbedContent(input, embeddingModel);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
// Here i get error
return embedding.Embedding.Values;
}
I get the 'Specified method is not supported' error, on the last line, but when i remove the try and catch, the error happens on this line:
embedding = await model.EmbedContent(input, embeddingModel);
I am newer to GoogleAi, embeddings and vector databases, so its probably something i have overlooked.
I started by using breakpoints, but it just hits the error on that line. I have looked through another question but couldn't find an answer that would fit my application. Comment if you need more code :)
Upvotes: 0
Views: 51
Reputation: 178
You may change your embeddingModel = “text-embedding-3-small” into these 9 Embeddings for Text supported model versions namely:
Text-embedding-preview-0815
Text-embedding-004
Text-multilingual-embedding-002
Text-embedding-preview-0409
Text-multilingual-embedding-preview-0409
textembedding-gecko@003
textembedding-gecko@002
textembedding-gecko-multilingua@001
textembedding-gecko@001
Upvotes: 1