Skip to content

Commit

Permalink
feat: add support for 2.0 experimental advanced model
Browse files Browse the repository at this point in the history
ref #55
  • Loading branch information
HanaokaYuzu committed Jan 10, 2025
1 parent 9d61943 commit 75cf1e8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ Currently available models (as of Dec 21, 2024):
- `unspecified` - Default model (Gemini 1.5 Flash)
- `gemini-1.5-flash` - Gemini 1.5 Flash
- `gemini-2.0-flash-exp` - Gemini 2.0 Flash Experimental
- `gemini-2.0-exp-advanced` - Gemini 2.0 Experimental Advanced (requires Gemini Advanced account)

```python
from gemini_webapi.constants import Model
Expand Down
12 changes: 10 additions & 2 deletions src/gemini_webapi/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,27 @@ class Headers(Enum):


class Model(Enum):
UNSPECIFIED = ("unspecified", {})
UNSPECIFIED = ("unspecified", {}, False)
G_1_5_FLASH = (
"gemini-1.5-flash",
{"x-goog-ext-525001261-jspb": '[null,null,null,null,"7daceb7ef88130f5"]'},
False,
)
G_2_0_FLASH_EXP = (
"gemini-2.0-flash-exp",
{"x-goog-ext-525001261-jspb": '[null,null,null,null,"948b866104ccf484"]'},
False,
)
G_2_0_EXP_ADVANCED = (
"gemini-2.0-exp-advanced",
{"x-goog-ext-525001261-jspb": '[null,null,null,null,"b1e46a6037e6aa9f"]'},
True,
)

def __init__(self, name, header):
def __init__(self, name, header, advanced_only):
self.model_name = name
self.model_header = header
self.advanced_only = advanced_only

@classmethod
def from_name(cls, name: str):
Expand Down
4 changes: 4 additions & 0 deletions tests/test_client_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ async def test_successful_request(self):
@logger.catch(reraise=True)
async def test_switch_model(self):
for model in Model:
if model.advanced_only:
logger.debug(f"Model {model.model_name} requires an advanced account")
continue

response = await self.geminiclient.generate_content(
"What's you language model version? Reply version number only.",
model=model,
Expand Down

0 comments on commit 75cf1e8

Please sign in to comment.