gunpal5 / Google_GenerativeAI

Unofficial C# Google Generative AI SDK (Google Gemini) with function calls support
MIT License
34 stars 4 forks source link

Code not working #1

Closed aiqinxuancai closed 9 months ago

aiqinxuancai commented 9 months ago

Version:0.1.9 I can use this key in local curl and it works fine. It is difficult to determine the specific cause of the error based on the information provided in the exception. image

gunpal5 commented 9 months ago

I think its due to Service Unavailable (HTTP Code 500) issue.

I fixed the error message. Please try again with version 0.1.12

aiqinxuancai commented 9 months ago

I think its due to Service Unavailable (HTTP Code 500) issue.

I fixed the error message. Please try again with version 0.1.12

Thank you, I have seen the specific reason for the output. It seems that API access is restricted by region.

{
  "error": {
    "code": 400,
    "message": "User location is not supported for the API use.",
    "status": "FAILED_PRECONDITION"
  }
}
gunpal5 commented 9 months ago

Can you try to change the APIs version to v1 instead of v1beta?

var model = new GenerativeModel(apiKey){ Version = "v1" }

Version v1 doesn't support function calling.