Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Commit

Permalink
feat(client): add request count
Browse files Browse the repository at this point in the history
  • Loading branch information
dsdanielpark committed Apr 17, 2024
1 parent 3a4b4b9 commit 31b8424
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions gemini/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def __init__(
"""
Initializes the Gemini object with session, cookies, and other configurations.
"""
self._request_count = 0
self._nonce = None # SNlM0e nonce value
self._sid = None # session id
self._rcid = None # response candidate id
Expand All @@ -75,6 +76,10 @@ def __init__(
self.base_url: str = URLs.BASE_URL.value
self.parser = ResponseParser(cookies=self.cookies)

@property
def request_count(self) -> int:
return self._request_count

@property
def nonce(self) -> Optional[str]:
return self._nonce
Expand Down Expand Up @@ -226,6 +231,7 @@ def send_request(
self, prompt: str, image: Union[bytes, str] = None
) -> Tuple[str, int]:
"""Sends a request and returns the response text and status code."""
self._request_count += 1
params = self._construct_params(self._sid)
data = self._construct_payload(prompt, image, self._nonce)
response = self.session.post(
Expand Down

0 comments on commit 31b8424

Please sign in to comment.