zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
50.08k stars 3.07k forks source link

Gemini CountTokens error #17343

Open cgarciae opened 2 months ago

cgarciae commented 2 months ago

Check for existing issues

Describe the bug / provide steps to reproduce it

I'm getting this error in the logs:

2024-09-04T08:47:24.780408Z [ERROR] error during countTokens, status code: 400, body: {
  "error": {
    "code": 400,
    "message": "CountTokens requires generate_content_request or contents to be set.",
    "status": "INVALID_ARGUMENT"
  }
}

I haven't been able to generate anything when including a file in the context.

Environment

-

If applicable, add mockups / screenshots to help explain present your vision of the feature

-

If applicable, attach your Zed.log file to this issue.

No response

subatomic-co commented 2 months ago

I have been encountering the exact same issue for approx the last 7 days with the Gemini models (both Pro and Flash) in the Assistant.

My logs show the same error as the original poster.

Environment

Apple Macbook Pro M1 Pro 16GB MacOS Sonoma 14.6.1

When the issue began occurring, I did a complete erase / reinstall of MacOS (it was time to do this anyway). The issue persisted following this OS reset.

I tried reverting to older versions of Zed, but the issue persisted.

I also tested with API keys from different Google accounts. I also tested whilst both logged-in and logged-out from Zed.

No matter what I have tried, the issue has persisted.

When I first installed Zed (approx Aug 27), I was using Gemini Flash without issue. It seems that the issue began occurring around approx Sep 1.

Additional Notes

I am experiencing minor variations in the errors generated when attempting to run Gemini. Some of the time, it throws the CountToken error. Other times, the response text will begin to stream (usually approx 1 paragraph), then it will stall, then it will throw a timeout error.

The end result is that with this error, Gemini is currently unusable for me in Zed.

Please let me know if you need any more information from me, and thank you to you and the Zed team for this incredible piece of software.