HanaokaYuzu / Gemini-API

✨ An elegant async Python wrapper for Google Gemini web app
https://pypi.org/project/gemini-webapi/
GNU Affero General Public License v3.0
134 stars 19 forks source link

How to select version? #15

Closed npow closed 2 months ago

npow commented 3 months ago

Hi, Gemini has versions 1.0 and 1.5. Is there a way to specify the version when initializing GeminiClient? What is the default version used?

jollyolliel commented 3 months ago

Refer to #5. The 1.5 is the Advacted (Refering to #5 )

npow commented 3 months ago

So by default it should be using 1.0? Reason I'm asking is because the limits are different (15 RPM vs 2 RPM for 1.5) but it seems like I'm being throttled way too early if I'm on 1.0

jollyolliel commented 3 months ago

Since there's no HTTP 1.5 to test against, HTTP 1.0 is likely the default version, especially considering it was built with HTTP 1.0. To confirm, check the source code against an HTTP 1.5 request. If you're interested in supporting HTTP 1.5 (optional), identifying the differences and adjustments could be valuable to others. You could even submit a pull request with your changes!

npow commented 3 months ago

I took a quick look, and I do see the model version in the payload. You seem to be using a different endpoint for GenerateContent though. I'm seeing https://alkalimakersuite-pa.clients6.google.com/$rpc/google.internal.alkali.applications.makersuite.v1.MakerSuiteService/GenerateContent from aistudio.google.com

["models/gemini-1.0-pro",[[[[null,"hi"]],"user"]

vs

["models/gemini-1.5-pro-latest",[[[[null,"hi"]]
jollyolliel commented 3 months ago

I didn't make this so I don't know but you could try mess around with the code and see if there is a difference. Also I think that acording to the endpoint link it is using the website https://gemini.google.com/app and not aistudio.google.com. Try looking on the https://gemini.google.com/app website and compare the differences there in the payload.

HanaokaYuzu commented 2 months ago

As @jollyolliel mentioned, this library is backed on Gemini web app instead of Google AI Studio.

As far as I know, there is no option in the web app to let user choose model version (unless you subscribed to Gemini Advanced, which allows you to use 1.0 Ultra model). Since google hasn't announced model version change for Gemini web app, I believe it's still using 1.0 pro, with extra ability to fetch real time information from internet, and has no limit on request frequency.

chrisdlees commented 2 weeks ago

@HanaokaYuzu Sorry to bug you, but will being subscribed to Gemini Advanced and using that account's cookie allow you to use the Ultra model with the unofficial API?

Google is giving away 2 months of free trial to Gemini Advanced, if you sign up for a 2-month, 1TB, Google One trial. I've been able to sign up with both my primary Google account and a throwaway account created just prior to signing up for the trial. This is with United States accounts, btw.

HanaokaYuzu commented 2 weeks ago

@chrisdlees Sorry but I haven't been able to test this package with advanced subscription (for personal reason I'm not going to activate the free trial). Likely this package will not work as expected, but still, I'm not sure.