summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2023-11-15 18:25:28 +0100
committerGitHub <noreply@github.com>2023-11-15 18:25:28 +0100
commitf04e415becbf45b1ef5a250e39f838be7608c59a (patch)
treee6712e4ed552a98d60ef8a4a6bd9d48d85a04bd7
parentMerge pull request #1251 from guspan-tanadi/READMENotesection (diff)
parentFix Chatgpt4Online Provider (diff)
downloadgpt4free-f04e415becbf45b1ef5a250e39f838be7608c59a.tar
gpt4free-f04e415becbf45b1ef5a250e39f838be7608c59a.tar.gz
gpt4free-f04e415becbf45b1ef5a250e39f838be7608c59a.tar.bz2
gpt4free-f04e415becbf45b1ef5a250e39f838be7608c59a.tar.lz
gpt4free-f04e415becbf45b1ef5a250e39f838be7608c59a.tar.xz
gpt4free-f04e415becbf45b1ef5a250e39f838be7608c59a.tar.zst
gpt4free-f04e415becbf45b1ef5a250e39f838be7608c59a.zip
-rw-r--r--g4f/Provider/AiAsk.py2
-rw-r--r--g4f/Provider/Aichat.py4
-rw-r--r--g4f/Provider/Chatgpt4Online.py48
-rw-r--r--g4f/Provider/FreeGpt.py2
-rw-r--r--g4f/Provider/__init__.py5
-rw-r--r--g4f/Provider/deprecated/Acytoo.py (renamed from g4f/Provider/Acytoo.py)4
-rw-r--r--g4f/Provider/deprecated/Aibn.py (renamed from g4f/Provider/Aibn.py)6
-rw-r--r--g4f/Provider/deprecated/Ails.py (renamed from g4f/Provider/Ails.py)4
-rw-r--r--g4f/Provider/deprecated/ChatgptDuo.py (renamed from g4f/Provider/ChatgptDuo.py)4
-rw-r--r--g4f/Provider/deprecated/Cromicle.py (renamed from g4f/Provider/Cromicle.py)6
-rw-r--r--g4f/Provider/deprecated/__init__.py7
-rw-r--r--g4f/models.py4
12 files changed, 48 insertions, 48 deletions
diff --git a/g4f/Provider/AiAsk.py b/g4f/Provider/AiAsk.py
index ac123fc9..094ef076 100644
--- a/g4f/Provider/AiAsk.py
+++ b/g4f/Provider/AiAsk.py
@@ -8,7 +8,7 @@ class AiAsk(AsyncGeneratorProvider):
url = "https://e.aiask.me"
supports_message_history = True
supports_gpt_35_turbo = True
- working = True
+ working = False
@classmethod
async def create_async_generator(
diff --git a/g4f/Provider/Aichat.py b/g4f/Provider/Aichat.py
index 77ae4429..41ea9a96 100644
--- a/g4f/Provider/Aichat.py
+++ b/g4f/Provider/Aichat.py
@@ -8,8 +8,8 @@ from .helper import get_cookies
from ..requests import StreamSession
class Aichat(AsyncProvider):
- url = "https://chat-gpt.org/chat"
- working = True
+ url = "https://chat-gpt.org/chat"
+ working = False
supports_gpt_35_turbo = True
@staticmethod
diff --git a/g4f/Provider/Chatgpt4Online.py b/g4f/Provider/Chatgpt4Online.py
index d7509639..57ab9482 100644
--- a/g4f/Provider/Chatgpt4Online.py
+++ b/g4f/Provider/Chatgpt4Online.py
@@ -1,42 +1,44 @@
from __future__ import annotations
-import json
+import re
from aiohttp import ClientSession
-from ..typing import AsyncResult, Messages
-from .base_provider import AsyncGeneratorProvider
+from ..typing import Messages
+from .base_provider import AsyncProvider
+from .helper import format_prompt
-
-class Chatgpt4Online(AsyncGeneratorProvider):
+class Chatgpt4Online(AsyncProvider):
url = "https://chatgpt4online.org"
supports_message_history = True
supports_gpt_35_turbo = True
- working = False
+ working = True
+ _wpnonce = None
@classmethod
- async def create_async_generator(
+ async def create_async(
cls,
model: str,
messages: Messages,
proxy: str = None,
**kwargs
- ) -> AsyncResult:
+ ) -> str:
async with ClientSession() as session:
+ if not cls._wpnonce:
+ async with session.get(f"{cls.url}/", proxy=proxy) as response:
+ response.raise_for_status()
+ response = await response.text()
+ if result := re.search(r'data-nonce="(.*?)"', response):
+ cls._wpnonce = result.group(1)
+ else:
+ raise RuntimeError("No nonce found")
data = {
- "botId": "default",
- "customId": None,
- "session": "N/A",
- "chatId": "",
- "contextId": 58,
- "messages": messages,
- "newMessage": messages[-1]["content"],
- "stream": True
+ "_wpnonce": cls._wpnonce,
+ "post_id": 58,
+ "url": "https://chatgpt4online.org",
+ "action": "wpaicg_chat_shortcode_message",
+ "message": format_prompt(messages),
+ "bot_id": 3405
}
-
- async with session.post(f"{cls.url}/wp-json/mwai-ui/v1/chats/submit", json=data, proxy=proxy) as response:
+ async with session.post(f"{cls.url}/rizq", data=data, proxy=proxy) as response:
response.raise_for_status()
- async for line in response.content:
- if line.startswith(b"data: "):
- line = json.loads(line[6:])
- if line["type"] == "live":
- yield line["data"] \ No newline at end of file
+ return (await response.json())["data"] \ No newline at end of file
diff --git a/g4f/Provider/FreeGpt.py b/g4f/Provider/FreeGpt.py
index a3a26fe6..22c6c9aa 100644
--- a/g4f/Provider/FreeGpt.py
+++ b/g4f/Provider/FreeGpt.py
@@ -12,7 +12,7 @@ domains = [
class FreeGpt(AsyncGeneratorProvider):
url = "https://freegpts1.aifree.site/"
- working = True
+ working = False
supports_message_history = True
supports_gpt_35_turbo = True
diff --git a/g4f/Provider/__init__.py b/g4f/Provider/__init__.py
index a72db45c..70ad9de7 100644
--- a/g4f/Provider/__init__.py
+++ b/g4f/Provider/__init__.py
@@ -1,9 +1,6 @@
from __future__ import annotations
-from .Acytoo import Acytoo
from .AiAsk import AiAsk
-from .Aibn import Aibn
from .Aichat import Aichat
-from .Ails import Ails
from .AItianhu import AItianhu
from .AItianhuSpace import AItianhuSpace
from .Berlin import Berlin
@@ -13,11 +10,9 @@ from .ChatForAi import ChatForAi
from .Chatgpt4Online import Chatgpt4Online
from .ChatgptAi import ChatgptAi
from .ChatgptDemo import ChatgptDemo
-from .ChatgptDuo import ChatgptDuo
from .ChatgptFree import ChatgptFree
from .ChatgptLogin import ChatgptLogin
from .ChatgptX import ChatgptX
-from .Cromicle import Cromicle
from .DeepInfra import DeepInfra
from .FakeGpt import FakeGpt
from .FreeGpt import FreeGpt
diff --git a/g4f/Provider/Acytoo.py b/g4f/Provider/deprecated/Acytoo.py
index 4dee176a..0379fdd6 100644
--- a/g4f/Provider/Acytoo.py
+++ b/g4f/Provider/deprecated/Acytoo.py
@@ -2,8 +2,8 @@ from __future__ import annotations
from aiohttp import ClientSession
-from ..typing import AsyncResult, Messages
-from .base_provider import AsyncGeneratorProvider
+from ...typing import AsyncResult, Messages
+from ..base_provider import AsyncGeneratorProvider
class Acytoo(AsyncGeneratorProvider):
diff --git a/g4f/Provider/Aibn.py b/g4f/Provider/deprecated/Aibn.py
index 1f81a61e..60cef1e4 100644
--- a/g4f/Provider/Aibn.py
+++ b/g4f/Provider/deprecated/Aibn.py
@@ -3,9 +3,9 @@ from __future__ import annotations
import time
import hashlib
-from ..typing import AsyncResult, Messages
-from ..requests import StreamSession
-from .base_provider import AsyncGeneratorProvider
+from ...typing import AsyncResult, Messages
+from ...requests import StreamSession
+from ..base_provider import AsyncGeneratorProvider
class Aibn(AsyncGeneratorProvider):
diff --git a/g4f/Provider/Ails.py b/g4f/Provider/deprecated/Ails.py
index 58010756..93c63a69 100644
--- a/g4f/Provider/Ails.py
+++ b/g4f/Provider/deprecated/Ails.py
@@ -7,8 +7,8 @@ import json
from datetime import datetime
from aiohttp import ClientSession
-from ..typing import SHA256, AsyncResult, Messages
-from .base_provider import AsyncGeneratorProvider
+from ...typing import SHA256, AsyncResult, Messages
+from ..base_provider import AsyncGeneratorProvider
class Ails(AsyncGeneratorProvider):
diff --git a/g4f/Provider/ChatgptDuo.py b/g4f/Provider/deprecated/ChatgptDuo.py
index fef3f856..c77c6a1c 100644
--- a/g4f/Provider/ChatgptDuo.py
+++ b/g4f/Provider/deprecated/ChatgptDuo.py
@@ -1,8 +1,8 @@
from __future__ import annotations
-from ..typing import Messages
+from ...typing import Messages
from curl_cffi.requests import AsyncSession
-from .base_provider import AsyncProvider, format_prompt
+from ..base_provider import AsyncProvider, format_prompt
class ChatgptDuo(AsyncProvider):
diff --git a/g4f/Provider/Cromicle.py b/g4f/Provider/deprecated/Cromicle.py
index 8deb79c1..9f986cb5 100644
--- a/g4f/Provider/Cromicle.py
+++ b/g4f/Provider/deprecated/Cromicle.py
@@ -2,10 +2,10 @@ from __future__ import annotations
from aiohttp import ClientSession
from hashlib import sha256
-from ..typing import AsyncResult, Messages, Dict
+from ...typing import AsyncResult, Messages, Dict
-from .base_provider import AsyncGeneratorProvider
-from .helper import format_prompt
+from ..base_provider import AsyncGeneratorProvider
+from ..helper import format_prompt
class Cromicle(AsyncGeneratorProvider):
diff --git a/g4f/Provider/deprecated/__init__.py b/g4f/Provider/deprecated/__init__.py
index f8e35b37..ca5ac83e 100644
--- a/g4f/Provider/deprecated/__init__.py
+++ b/g4f/Provider/deprecated/__init__.py
@@ -13,4 +13,9 @@ from .FastGpt import FastGpt
from .Aivvm import Aivvm
from .Vitalentum import Vitalentum
from .H2o import H2o
-from .Myshell import Myshell \ No newline at end of file
+from .Myshell import Myshell
+from .Acytoo import Acytoo
+from .Aibn import Aibn
+from .Ails import Ails
+from .ChatgptDuo import ChatgptDuo
+from .Cromicle import Cromicle \ No newline at end of file
diff --git a/g4f/models.py b/g4f/models.py
index 0ce7b886..cdca0e3f 100644
--- a/g4f/models.py
+++ b/g4f/models.py
@@ -15,10 +15,8 @@ from .Provider import (
Berlin,
Llama2,
Vercel,
- Aichat,
GPTalk,
Koala,
- AiAsk,
GptGo,
Phind,
Bard,
@@ -42,7 +40,7 @@ default = Model(
base_provider = "",
best_provider = RetryProvider([
Bing, # Not fully GPT 3 or 4
- AiAsk, Aichat, ChatgptAi, FreeGpt, GptGo, GeekGpt,
+ ChatgptAi, GptGo, GeekGpt,
Phind, You
])
)