summaryrefslogtreecommitdiffstats
path: root/g4f/Provider
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2024-04-23 17:38:42 +0200
committerGitHub <noreply@github.com>2024-04-23 17:38:42 +0200
commit10f25fdcaf5bf74abc798c70d218ce481116c217 (patch)
treed0c06f94dd1c5be203fb02b95e22c51ff976be88 /g4f/Provider
parentMerge pull request #1880 from Strvm/feat/credit_meta (diff)
parentAdd conversation title change in gui (diff)
downloadgpt4free-10f25fdcaf5bf74abc798c70d218ce481116c217.tar
gpt4free-10f25fdcaf5bf74abc798c70d218ce481116c217.tar.gz
gpt4free-10f25fdcaf5bf74abc798c70d218ce481116c217.tar.bz2
gpt4free-10f25fdcaf5bf74abc798c70d218ce481116c217.tar.lz
gpt4free-10f25fdcaf5bf74abc798c70d218ce481116c217.tar.xz
gpt4free-10f25fdcaf5bf74abc798c70d218ce481116c217.tar.zst
gpt4free-10f25fdcaf5bf74abc798c70d218ce481116c217.zip
Diffstat (limited to '')
-rw-r--r--g4f/Provider/Bing.py2
-rw-r--r--g4f/Provider/BingCreateImages.py14
-rw-r--r--g4f/Provider/HuggingChat.py3
-rw-r--r--g4f/Provider/openai/har_file.py3
4 files changed, 14 insertions, 8 deletions
diff --git a/g4f/Provider/Bing.py b/g4f/Provider/Bing.py
index bfd74f8c..a9eb78e6 100644
--- a/g4f/Provider/Bing.py
+++ b/g4f/Provider/Bing.py
@@ -484,7 +484,7 @@ async def stream_generate(
elif message.get('contentType') == "IMAGE":
prompt = message.get('text')
try:
- image_client = BingCreateImages(cookies, proxy)
+ image_client = BingCreateImages(cookies, proxy, api_key)
image_response = await image_client.create_async(prompt)
except Exception as e:
if debug.logging:
diff --git a/g4f/Provider/BingCreateImages.py b/g4f/Provider/BingCreateImages.py
index 69bf1e92..9e5146cc 100644
--- a/g4f/Provider/BingCreateImages.py
+++ b/g4f/Provider/BingCreateImages.py
@@ -19,9 +19,13 @@ class BingCreateImages(AsyncGeneratorProvider, ProviderModelMixin):
needs_auth = True
image_models = ["dall-e"]
- def __init__(self, cookies: Cookies = None, proxy: str = None) -> None:
- self.cookies: Cookies = cookies
- self.proxy: str = proxy
+ def __init__(self, cookies: Cookies = None, proxy: str = None, api_key: str = None) -> None:
+ if api_key is not None:
+ if cookies is None:
+ cookies = {}
+ cookies["_U"] = api_key
+ self.cookies = cookies
+ self.proxy = proxy
@classmethod
async def create_async_generator(
@@ -33,9 +37,7 @@ class BingCreateImages(AsyncGeneratorProvider, ProviderModelMixin):
proxy: str = None,
**kwargs
) -> AsyncResult:
- if api_key is not None:
- cookies = {"_U": api_key}
- session = BingCreateImages(cookies, proxy)
+ session = BingCreateImages(cookies, proxy, api_key)
yield await session.create_async(messages[-1]["content"])
def create(self, prompt: str) -> Iterator[Union[ImageResponse, str]]:
diff --git a/g4f/Provider/HuggingChat.py b/g4f/Provider/HuggingChat.py
index 527f0a56..65273345 100644
--- a/g4f/Provider/HuggingChat.py
+++ b/g4f/Provider/HuggingChat.py
@@ -24,6 +24,9 @@ class HuggingChat(AsyncGeneratorProvider, ProviderModelMixin):
'mistralai/Mistral-7B-Instruct-v0.2',
'meta-llama/Meta-Llama-3-70B-Instruct'
]
+ model_aliases = {
+ "mistralai/Mistral-7B-Instruct-v0.1": "mistralai/Mistral-7B-Instruct-v0.2"
+ }
@classmethod
def get_models(cls):
diff --git a/g4f/Provider/openai/har_file.py b/g4f/Provider/openai/har_file.py
index da25b637..6a34c97a 100644
--- a/g4f/Provider/openai/har_file.py
+++ b/g4f/Provider/openai/har_file.py
@@ -30,6 +30,7 @@ sessionUrl = "https://chat.openai.com/api/auth/session"
chatArk: arkReq = None
accessToken: str = None
cookies: dict = None
+headers: dict = None
def readHAR():
dirPath = "./"
@@ -130,7 +131,7 @@ def getN() -> str:
return base64.b64encode(timestamp.encode()).decode()
async def getArkoseAndAccessToken(proxy: str) -> tuple[str, str, dict, dict]:
- global chatArk, accessToken, cookies
+ global chatArk, accessToken, cookies, headers
if chatArk is None or accessToken is None:
chatArk, accessToken, cookies, headers = readHAR()
if chatArk is None: