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

Commit

Permalink
chore: style black
Browse files Browse the repository at this point in the history
  • Loading branch information
dsdanielpark committed Mar 9, 2024
1 parent fc738d5 commit 9505971
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
17 changes: 5 additions & 12 deletions gemini/async.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,7 @@ async def async_init(
"""
self.session = await self._create_async_session()



async def _create_async_session(
self
) -> httpx.AsyncClient:
async def _create_async_session(self) -> httpx.AsyncClient:
"""
Initializes or configures the httpx.AsyncClient session with predefined session headers, proxies, and cookies.
Expand All @@ -134,8 +130,8 @@ async def _create_async_session(
headers=HEADERS,
cookies=self.cookies,
timeout=self.timeout,
auto_close=self.auto_close,
close_delay=self.close_delay
auto_close=self.auto_close,
close_delay=self.close_delay,
)

if hasattr(self, "session"):
Expand All @@ -144,7 +140,7 @@ async def _create_async_session(
self.running = False

return self.session

def _load_cookies_from_file(self, file_path: str) -> None:
"""Loads cookies from a file and updates the session."""
try:
Expand Down Expand Up @@ -216,7 +212,6 @@ def _set_sid_and_nonce(self):
raise ValueError(
"Failed to parse SID or SNlM0e nonce from the response.\nRefresh the Gemini web page or access Gemini in a new incognito browser to resend cookies."
)


except requests.RequestException as e:
raise ConnectionError(f"Request failed: {e}")
Expand All @@ -241,7 +236,7 @@ def extract_sid_nonce(response_text):
sid_match = re.search(r'"FdrFJe":"([\d-]+)"', response_text)
nonce_match = re.search(r'"SNlM0e":"(.*?)"', response_text)
return sid_match, nonce_match

def _get_cookies_from_browser(self) -> dict:
"""
Attempts to extract specific Gemini cookies from the cookies stored by web browsers on the current system.
Expand Down Expand Up @@ -280,8 +275,6 @@ def _get_cookies_from_browser(self) -> dict:
"Failed to get cookies. Set 'cookies' argument or 'auto_cookies' as True."
)



def _construct_params(self, sid: str) -> str:
"""
Constructs URL-encoded parameters for a request.
Expand Down
1 change: 0 additions & 1 deletion gemini/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ def extract_sid_nonce(response_text):
nonce_match = re.search(r'"SNlM0e":"(.*?)"', response_text)
return sid_match, nonce_match


def _construct_params(self, sid: str) -> str:
"""
Constructs URL-encoded parameters for a request.
Expand Down

0 comments on commit 9505971

Please sign in to comment.