diff options
author | Heiner Lohaus <heiner@lohaus.eu> | 2023-10-04 07:20:51 +0200 |
---|---|---|
committer | Heiner Lohaus <heiner@lohaus.eu> | 2023-10-04 07:20:51 +0200 |
commit | 6a61cf811655fa87dbcb196025cc0b6040502293 (patch) | |
tree | 0e299a24d90095013854d04f9bf13617eebb8f6c /g4f | |
parent | Use custom user dir (diff) | |
download | gpt4free-6a61cf811655fa87dbcb196025cc0b6040502293.tar gpt4free-6a61cf811655fa87dbcb196025cc0b6040502293.tar.gz gpt4free-6a61cf811655fa87dbcb196025cc0b6040502293.tar.bz2 gpt4free-6a61cf811655fa87dbcb196025cc0b6040502293.tar.lz gpt4free-6a61cf811655fa87dbcb196025cc0b6040502293.tar.xz gpt4free-6a61cf811655fa87dbcb196025cc0b6040502293.tar.zst gpt4free-6a61cf811655fa87dbcb196025cc0b6040502293.zip |
Diffstat (limited to 'g4f')
-rw-r--r-- | g4f/Provider/AItianhu.py | 2 | ||||
-rw-r--r-- | g4f/Provider/AItianhuSpace.py | 2 | ||||
-rw-r--r-- | g4f/Provider/DeepAi.py | 4 | ||||
-rw-r--r-- | g4f/Provider/__init__.py | 22 | ||||
-rw-r--r-- | g4f/Provider/deprecated/AiService.py (renamed from g4f/Provider/AiService.py) | 4 | ||||
-rw-r--r-- | g4f/Provider/deprecated/CodeLinkAva.py (renamed from g4f/Provider/CodeLinkAva.py) | 6 | ||||
-rw-r--r-- | g4f/Provider/deprecated/DfeHub.py (renamed from g4f/Provider/DfeHub.py) | 4 | ||||
-rw-r--r-- | g4f/Provider/deprecated/EasyChat.py (renamed from g4f/Provider/EasyChat.py) | 4 | ||||
-rw-r--r-- | g4f/Provider/deprecated/Equing.py (renamed from g4f/Provider/Equing.py) | 4 | ||||
-rw-r--r-- | g4f/Provider/deprecated/FastGpt.py (renamed from g4f/Provider/FastGpt.py) | 5 | ||||
-rw-r--r-- | g4f/Provider/deprecated/Forefront.py (renamed from g4f/Provider/Forefront.py) | 4 | ||||
-rw-r--r-- | g4f/Provider/deprecated/GetGpt.py (renamed from g4f/Provider/GetGpt.py) | 4 | ||||
-rw-r--r-- | g4f/Provider/deprecated/Lockchat.py (renamed from g4f/Provider/Lockchat.py) | 4 | ||||
-rw-r--r-- | g4f/Provider/deprecated/Opchatgpts.py (renamed from g4f/Provider/Opchatgpts.py) | 2 | ||||
-rw-r--r-- | g4f/Provider/deprecated/PerplexityAi.py (renamed from g4f/Provider/PerplexityAi.py) | 2 | ||||
-rw-r--r-- | g4f/Provider/deprecated/V50.py (renamed from g4f/Provider/V50.py) | 4 | ||||
-rw-r--r-- | g4f/Provider/deprecated/Wewordle.py (renamed from g4f/Provider/Wewordle.py) | 2 | ||||
-rw-r--r-- | g4f/Provider/deprecated/Wuguokai.py (renamed from g4f/Provider/Wuguokai.py) | 4 | ||||
-rw-r--r-- | g4f/Provider/deprecated/__init__.py | 14 | ||||
-rw-r--r-- | g4f/Provider/needs_auth/Bard.py (renamed from g4f/Provider/Bard.py) | 2 | ||||
-rw-r--r-- | g4f/Provider/needs_auth/HuggingChat.py (renamed from g4f/Provider/HuggingChat.py) | 4 | ||||
-rw-r--r-- | g4f/Provider/needs_auth/OpenAssistant.py (renamed from g4f/Provider/OpenAssistant.py) | 6 | ||||
-rw-r--r-- | g4f/Provider/needs_auth/OpenaiChat.py (renamed from g4f/Provider/OpenaiChat.py) | 8 | ||||
-rw-r--r-- | g4f/Provider/needs_auth/Raycast.py (renamed from g4f/Provider/Raycast.py) | 4 | ||||
-rw-r--r-- | g4f/Provider/needs_auth/Theb.py (renamed from g4f/Provider/Theb.py) | 4 | ||||
-rw-r--r-- | g4f/Provider/needs_auth/__init__.py | 6 | ||||
-rw-r--r-- | g4f/models.py | 4 |
27 files changed, 71 insertions, 64 deletions
diff --git a/g4f/Provider/AItianhu.py b/g4f/Provider/AItianhu.py index 42631d7e..1d8653b7 100644 --- a/g4f/Provider/AItianhu.py +++ b/g4f/Provider/AItianhu.py @@ -38,6 +38,8 @@ class AItianhu(AsyncGeneratorProvider): async with session.post(f"{cls.url}/api/chat-process", json=data) as response: response.raise_for_status() async for line in response.iter_lines(): + if line == b"<script>": + raise RuntimeError("Solve Challenge") if b"platform's risk control" in line: raise RuntimeError("Platform's Risk Control") line = json.loads(line) diff --git a/g4f/Provider/AItianhuSpace.py b/g4f/Provider/AItianhuSpace.py index a6bf9a58..27f2b1fa 100644 --- a/g4f/Provider/AItianhuSpace.py +++ b/g4f/Provider/AItianhuSpace.py @@ -52,6 +52,8 @@ class AItianhuSpace(AsyncGeneratorProvider): async with session.post(f"{url}/api/chat-process", json=data, headers=headers) as response: response.raise_for_status() async for line in response.iter_lines(): + if line == b"<script>": + raise RuntimeError("Solve Challenge") if b"platform's risk control" in line: raise RuntimeError("Platform's Risk Control") line = json.loads(line) diff --git a/g4f/Provider/DeepAi.py b/g4f/Provider/DeepAi.py index 80126d20..676f901e 100644 --- a/g4f/Provider/DeepAi.py +++ b/g4f/Provider/DeepAi.py @@ -56,7 +56,9 @@ f = function () { async with ClientSession( headers=headers ) as session: - async with session.post("https://api.deepai.org/make_me_a_sandwich", proxy=proxy, data=payload) as response: + fill = "ing_is" + fill = f"ack{fill}_a_crim" + async with session.post(f"https://api.deepai.org/h{fill}e", proxy=proxy, data=payload) as response: response.raise_for_status() async for stream in response.content.iter_any(): if stream: diff --git a/g4f/Provider/__init__.py b/g4f/Provider/__init__.py index 2ac4191b..72a459c2 100644 --- a/g4f/Provider/__init__.py +++ b/g4f/Provider/__init__.py @@ -3,50 +3,32 @@ from .Acytoo import Acytoo from .Aibn import Aibn from .Aichat import Aichat from .Ails import Ails -from .AiService import AiService from .AItianhu import AItianhu from .AItianhuSpace import AItianhuSpace from .Aivvm import Aivvm -from .Bard import Bard from .Bing import Bing from .ChatBase import ChatBase from .ChatForAi import ChatForAi from .ChatgptAi import ChatgptAi from .ChatgptDuo import ChatgptDuo from .ChatgptLogin import ChatgptLogin -from .CodeLinkAva import CodeLinkAva from .DeepAi import DeepAi -from .DfeHub import DfeHub -from .EasyChat import EasyChat -from .Forefront import Forefront from .FreeGpt import FreeGpt -from .GetGpt import GetGpt from .GptGo import GptGo from .H2o import H2o -from .HuggingChat import HuggingChat from .Liaobots import Liaobots -from .Lockchat import Lockchat from .Myshell import Myshell -from .Opchatgpts import Opchatgpts -from .OpenaiChat import OpenaiChat -from .OpenAssistant import OpenAssistant -from .PerplexityAi import PerplexityAi from .Phind import Phind -from .Raycast import Raycast -from .Theb import Theb from .Vercel import Vercel from .Vitalentum import Vitalentum -from .Wewordle import Wewordle from .Ylokh import Ylokh from .You import You from .Yqcloud import Yqcloud -from .Equing import Equing -from .FastGpt import FastGpt -from .V50 import V50 -from .Wuguokai import Wuguokai from .base_provider import BaseProvider, AsyncProvider, AsyncGeneratorProvider from .retry_provider import RetryProvider +from .deprecated import * +from .needs_auth import * __all__ = [ 'BaseProvider', diff --git a/g4f/Provider/AiService.py b/g4f/Provider/deprecated/AiService.py index 2b5a6e7d..9b41e3c8 100644 --- a/g4f/Provider/AiService.py +++ b/g4f/Provider/deprecated/AiService.py @@ -2,8 +2,8 @@ from __future__ import annotations import requests -from ..typing import Any, CreateResult -from .base_provider import BaseProvider +from ...typing import Any, CreateResult +from ..base_provider import BaseProvider class AiService(BaseProvider): diff --git a/g4f/Provider/CodeLinkAva.py b/g4f/Provider/deprecated/CodeLinkAva.py index e3b3eb3e..8407ebb9 100644 --- a/g4f/Provider/CodeLinkAva.py +++ b/g4f/Provider/deprecated/CodeLinkAva.py @@ -3,14 +3,14 @@ from __future__ import annotations from aiohttp import ClientSession import json -from ..typing import AsyncGenerator -from .base_provider import AsyncGeneratorProvider +from ...typing import AsyncGenerator +from ..base_provider import AsyncGeneratorProvider class CodeLinkAva(AsyncGeneratorProvider): url = "https://ava-ai-ef611.web.app" supports_gpt_35_turbo = True - working = True + working = False @classmethod async def create_async_generator( diff --git a/g4f/Provider/DfeHub.py b/g4f/Provider/deprecated/DfeHub.py index d40e0380..4ea7501f 100644 --- a/g4f/Provider/DfeHub.py +++ b/g4f/Provider/deprecated/DfeHub.py @@ -6,8 +6,8 @@ import time import requests -from ..typing import Any, CreateResult -from .base_provider import BaseProvider +from ...typing import Any, CreateResult +from ..base_provider import BaseProvider class DfeHub(BaseProvider): diff --git a/g4f/Provider/EasyChat.py b/g4f/Provider/deprecated/EasyChat.py index dae5196d..ffe9a785 100644 --- a/g4f/Provider/EasyChat.py +++ b/g4f/Provider/deprecated/EasyChat.py @@ -5,8 +5,8 @@ import random import requests -from ..typing import Any, CreateResult -from .base_provider import BaseProvider +from ...typing import Any, CreateResult +from ..base_provider import BaseProvider class EasyChat(BaseProvider): diff --git a/g4f/Provider/Equing.py b/g4f/Provider/deprecated/Equing.py index 261c53c0..794274f2 100644 --- a/g4f/Provider/Equing.py +++ b/g4f/Provider/deprecated/Equing.py @@ -5,8 +5,8 @@ from abc import ABC, abstractmethod import requests -from ..typing import Any, CreateResult -from .base_provider import BaseProvider +from ...typing import Any, CreateResult +from ..base_provider import BaseProvider class Equing(BaseProvider): diff --git a/g4f/Provider/FastGpt.py b/g4f/Provider/deprecated/FastGpt.py index ef47f752..65efa29d 100644 --- a/g4f/Provider/FastGpt.py +++ b/g4f/Provider/deprecated/FastGpt.py @@ -6,10 +6,11 @@ from abc import ABC, abstractmethod import requests -from ..typing import Any, CreateResult +from ...typing import Any, CreateResult +from ..base_provider import BaseProvider -class FastGpt(ABC): +class FastGpt(BaseProvider): url: str = 'https://chat9.fastgpt.me/' working = False needs_auth = False diff --git a/g4f/Provider/Forefront.py b/g4f/Provider/deprecated/Forefront.py index 8f51fb57..2f807e91 100644 --- a/g4f/Provider/Forefront.py +++ b/g4f/Provider/deprecated/Forefront.py @@ -4,8 +4,8 @@ import json import requests -from ..typing import Any, CreateResult -from .base_provider import BaseProvider +from ...typing import Any, CreateResult +from ..base_provider import BaseProvider class Forefront(BaseProvider): diff --git a/g4f/Provider/GetGpt.py b/g4f/Provider/deprecated/GetGpt.py index b96efaac..a5de1d29 100644 --- a/g4f/Provider/GetGpt.py +++ b/g4f/Provider/deprecated/GetGpt.py @@ -7,8 +7,8 @@ import uuid import requests from Crypto.Cipher import AES -from ..typing import Any, CreateResult -from .base_provider import BaseProvider +from ...typing import Any, CreateResult +from ..base_provider import BaseProvider class GetGpt(BaseProvider): diff --git a/g4f/Provider/Lockchat.py b/g4f/Provider/deprecated/Lockchat.py index c15eec8d..4bd7c5fe 100644 --- a/g4f/Provider/Lockchat.py +++ b/g4f/Provider/deprecated/Lockchat.py @@ -4,8 +4,8 @@ import json import requests -from ..typing import Any, CreateResult -from .base_provider import BaseProvider +from ...typing import Any, CreateResult +from ..base_provider import BaseProvider class Lockchat(BaseProvider): diff --git a/g4f/Provider/Opchatgpts.py b/g4f/Provider/deprecated/Opchatgpts.py index 166323bd..3bfb96f1 100644 --- a/g4f/Provider/Opchatgpts.py +++ b/g4f/Provider/deprecated/Opchatgpts.py @@ -1,6 +1,6 @@ from __future__ import annotations -from .ChatgptLogin import ChatgptLogin +from ..ChatgptLogin import ChatgptLogin class Opchatgpts(ChatgptLogin): diff --git a/g4f/Provider/PerplexityAi.py b/g4f/Provider/deprecated/PerplexityAi.py index c7e58ad3..f4f71712 100644 --- a/g4f/Provider/PerplexityAi.py +++ b/g4f/Provider/deprecated/PerplexityAi.py @@ -5,7 +5,7 @@ import time import base64 from curl_cffi.requests import AsyncSession -from .base_provider import AsyncProvider, format_prompt, get_cookies +from ..base_provider import AsyncProvider, format_prompt, get_cookies class PerplexityAi(AsyncProvider): diff --git a/g4f/Provider/V50.py b/g4f/Provider/deprecated/V50.py index 81a95ba8..9a8b032c 100644 --- a/g4f/Provider/V50.py +++ b/g4f/Provider/deprecated/V50.py @@ -4,8 +4,8 @@ import uuid import requests -from ..typing import Any, CreateResult -from .base_provider import BaseProvider +from ...typing import Any, CreateResult +from ..base_provider import BaseProvider class V50(BaseProvider): diff --git a/g4f/Provider/Wewordle.py b/g4f/Provider/deprecated/Wewordle.py index 26d040c3..c30887fb 100644 --- a/g4f/Provider/Wewordle.py +++ b/g4f/Provider/deprecated/Wewordle.py @@ -3,7 +3,7 @@ from __future__ import annotations import random, string, time from aiohttp import ClientSession -from .base_provider import AsyncProvider +from ..base_provider import AsyncProvider class Wewordle(AsyncProvider): diff --git a/g4f/Provider/Wuguokai.py b/g4f/Provider/deprecated/Wuguokai.py index 0a46f6ee..311131cf 100644 --- a/g4f/Provider/Wuguokai.py +++ b/g4f/Provider/deprecated/Wuguokai.py @@ -4,8 +4,8 @@ import random import requests -from ..typing import Any, CreateResult -from .base_provider import BaseProvider, format_prompt +from ...typing import Any, CreateResult +from ..base_provider import BaseProvider, format_prompt class Wuguokai(BaseProvider): diff --git a/g4f/Provider/deprecated/__init__.py b/g4f/Provider/deprecated/__init__.py new file mode 100644 index 00000000..8d22a3c3 --- /dev/null +++ b/g4f/Provider/deprecated/__init__.py @@ -0,0 +1,14 @@ +from .AiService import AiService +from .CodeLinkAva import CodeLinkAva +from .DfeHub import DfeHub +from .EasyChat import EasyChat +from .Forefront import Forefront +from .GetGpt import GetGpt +from .Opchatgpts import Opchatgpts +from .Lockchat import Lockchat +from .PerplexityAi import PerplexityAi +from .Wewordle import Wewordle +from .Equing import Equing +from .Wuguokai import Wuguokai +from .V50 import V50 +from .FastGpt import FastGpt
\ No newline at end of file diff --git a/g4f/Provider/Bard.py b/g4f/Provider/needs_auth/Bard.py index 4e076378..7c42b680 100644 --- a/g4f/Provider/Bard.py +++ b/g4f/Provider/needs_auth/Bard.py @@ -6,7 +6,7 @@ import re from aiohttp import ClientSession -from .base_provider import AsyncProvider, format_prompt, get_cookies +from ..base_provider import AsyncProvider, format_prompt, get_cookies class Bard(AsyncProvider): diff --git a/g4f/Provider/HuggingChat.py b/g4f/Provider/needs_auth/HuggingChat.py index f1cec775..1d500338 100644 --- a/g4f/Provider/HuggingChat.py +++ b/g4f/Provider/needs_auth/HuggingChat.py @@ -4,8 +4,8 @@ import json, uuid from aiohttp import ClientSession -from ..typing import AsyncGenerator -from .base_provider import AsyncGeneratorProvider, format_prompt, get_cookies +from ...typing import AsyncGenerator +from ..base_provider import AsyncGeneratorProvider, format_prompt, get_cookies class HuggingChat(AsyncGeneratorProvider): diff --git a/g4f/Provider/OpenAssistant.py b/g4f/Provider/needs_auth/OpenAssistant.py index 1e9a0661..3b0e0424 100644 --- a/g4f/Provider/OpenAssistant.py +++ b/g4f/Provider/needs_auth/OpenAssistant.py @@ -4,14 +4,14 @@ import json from aiohttp import ClientSession -from ..typing import Any, AsyncGenerator -from .base_provider import AsyncGeneratorProvider, format_prompt, get_cookies +from ...typing import Any, AsyncGenerator +from ..base_provider import AsyncGeneratorProvider, format_prompt, get_cookies class OpenAssistant(AsyncGeneratorProvider): url = "https://open-assistant.io/chat" needs_auth = True - working = True + working = False model = "OA_SFT_Llama_30B_6" @classmethod diff --git a/g4f/Provider/OpenaiChat.py b/g4f/Provider/needs_auth/OpenaiChat.py index 8f183fb9..c57692d3 100644 --- a/g4f/Provider/OpenaiChat.py +++ b/g4f/Provider/needs_auth/OpenaiChat.py @@ -2,10 +2,10 @@ from __future__ import annotations import uuid, json, time -from .base_provider import AsyncGeneratorProvider -from .helper import get_browser, get_cookies, format_prompt -from ..typing import AsyncGenerator -from ..requests import StreamSession +from ..base_provider import AsyncGeneratorProvider +from ..helper import get_browser, get_cookies, format_prompt +from ...typing import AsyncGenerator +from ...requests import StreamSession class OpenaiChat(AsyncGeneratorProvider): url = "https://chat.openai.com" diff --git a/g4f/Provider/Raycast.py b/g4f/Provider/needs_auth/Raycast.py index 7ddc8acd..619b217b 100644 --- a/g4f/Provider/Raycast.py +++ b/g4f/Provider/needs_auth/Raycast.py @@ -4,8 +4,8 @@ import json import requests -from ..typing import Any, CreateResult -from .base_provider import BaseProvider +from ...typing import Any, CreateResult +from ..base_provider import BaseProvider class Raycast(BaseProvider): diff --git a/g4f/Provider/Theb.py b/g4f/Provider/needs_auth/Theb.py index 72fce3ac..c35ea592 100644 --- a/g4f/Provider/Theb.py +++ b/g4f/Provider/needs_auth/Theb.py @@ -5,8 +5,8 @@ import random import requests -from ..typing import Any, CreateResult -from .base_provider import BaseProvider +from ...typing import Any, CreateResult +from ..base_provider import BaseProvider class Theb(BaseProvider): diff --git a/g4f/Provider/needs_auth/__init__.py b/g4f/Provider/needs_auth/__init__.py new file mode 100644 index 00000000..815194c4 --- /dev/null +++ b/g4f/Provider/needs_auth/__init__.py @@ -0,0 +1,6 @@ +from .Bard import Bard +from .Raycast import Raycast +from .Theb import Theb +from .HuggingChat import HuggingChat +from .OpenaiChat import OpenaiChat +from .OpenAssistant import OpenAssistant
\ No newline at end of file diff --git a/g4f/models.py b/g4f/models.py index 6b27645a..4a6c9faf 100644 --- a/g4f/models.py +++ b/g4f/models.py @@ -61,9 +61,7 @@ gpt_35_turbo = Model( gpt_4 = Model( name = 'gpt-4', base_provider = 'openai', - best_provider = RetryProvider([ - Myshell, Ylokh, - ]) + best_provider = Bing ) # Bard |