From a28bab938704a15c825c1b45a8983c72e8c90ace Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Mon, 29 Jan 2024 18:14:46 +0100 Subject: Add aiohttp_socks to requirements Fix preview for uploaded and generated images in gui Improve typing, readme --- g4f/requests_aiohttp.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'g4f/requests_aiohttp.py') diff --git a/g4f/requests_aiohttp.py b/g4f/requests_aiohttp.py index aa097312..0da8973b 100644 --- a/g4f/requests_aiohttp.py +++ b/g4f/requests_aiohttp.py @@ -4,6 +4,7 @@ from aiohttp import ClientSession, ClientResponse, ClientTimeout from typing import AsyncGenerator, Any from .Provider.helper import get_connector +from .defaults import DEFAULT_HEADERS class StreamResponse(ClientResponse): async def iter_lines(self) -> AsyncGenerator[bytes, None]: @@ -17,17 +18,7 @@ class StreamSession(ClientSession): def __init__(self, headers: dict = {}, timeout: int = None, proxies: dict = {}, impersonate = None, **kwargs): if impersonate: headers = { - 'Accept-Encoding': 'gzip, deflate, br', - 'Accept-Language': 'en-US', - 'Connection': 'keep-alive', - 'Sec-Fetch-Dest': 'empty', - 'Sec-Fetch-Mode': 'cors', - 'Sec-Fetch-Site': 'same-site', - "User-Agent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36', - 'Accept': '*/*', - 'sec-ch-ua': '"Google Chrome";v="107", "Chromium";v="107", "Not?A_Brand";v="24"', - 'sec-ch-ua-mobile': '?0', - 'sec-ch-ua-platform': '"Windows"', + **DEFAULT_HEADERS, **headers } super().__init__( -- cgit v1.2.3