-1

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 :)

2
  • 1
    by error you mean runtime exception right? Commented Jan 13 at 22:07
  • Yes sorry, a runtime exception Commented Jan 14 at 11:03

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.