mscraftsman / generative-ai

Gemini AI SDK for .NET and ASP.NET Core enables developers to use Google's state-of-the-art generative AI models to build AI-powered features and applications.
https://mscraftsman.github.io/generative-ai/
Apache License 2.0
55 stars 11 forks source link

The original usage seems broken: new GenerativeModel(...) #5

Closed doggy8088 closed 7 months ago

doggy8088 commented 7 months ago

Here is my code:

async Task Main()
{
    var model = new GenerativeModel(apiKey: Util.GetPassword("GEMINI_API_KEY"), model: Model.GeminiPro);

    var prompt = "I love Taipei.";

    var response = await model.GenerateContent(prompt);

    response.Text.Dump();
}

LINQPad Query: https://share.linqpad.net/s5ftv46u.linq

Screenshot:

image

jochenkirstaetter commented 7 months ago

You got an HTTP 429 Too many requests.

You exceeded the default limit 60 qpm (queries per minute).

doggy8088 commented 7 months ago

I know the limitation of the 60 QPM. The point is that, I am NOT request that much at that moment. The Google AI Gemini API will returned HTTP 429 from time to time. Unknown reason! Don't you met that before?

jochenkirstaetter commented 7 months ago

Hardly. However, that's an external issue which I cannot control in the package itself. That's probably something that could be handled by a Retry pattern/approach. There are times when Google AI has too many loads and rejects calls even though you might be below the 60 QPMs. It's discussed among other developers, too.

jochenkirstaetter commented 7 months ago

Considering this as a use case of #2