返回提交历史
Modified
g4f/Provider/AItianhu.py
+34
-17
Modified
g4f/Provider/AItianhuSpace.py
+2
-0
Modified
g4f/Provider/Acytoo.py
+1
-1
Modified
g4f/Provider/Aibn.py
+1
-1
Modified
g4f/Provider/Ails.py
+1
-1
Modified
g4f/Provider/ChatgptDuo.py
+1
-1
Modified
g4f/Provider/ChatgptFree.py
+8
-3
Modified
g4f/Provider/Cromicle.py
+1
-1
Modified
g4f/Provider/GptChatly.py
+11
-4
Modified
g4f/Provider/Myshell.py
+46
-2
Modified
g4f/Provider/Ylokh.py
+1
-1
XFEstudio/gpt4free
~ | remove non-working providers
4a3b663c
代码差异
11 个文件
+107
-32
@@ -1,6 +1,7 @@
1
1
from __future__ import annotations
2
2
3
3
import json
4
import browser_cookie3
4
5
5
6
from ..typing import AsyncResult, Messages
6
7
from ..requests import StreamSession
@@ -9,7 +10,7 @@ from .base_provider import AsyncGeneratorProvider, format_prompt, get_cookies
9
10
10
11
class AItianhu(AsyncGeneratorProvider):
11
12
url = "https://www.aitianhu.com"
12
working = True
13
working = False
13
14
supports_gpt_35_turbo = True
14
15
15
16
@classmethod
@@ -19,11 +20,13 @@ class AItianhu(AsyncGeneratorProvider):
19
20
messages: Messages,
20
21
proxy: str = None,
21
22
cookies: dict = None,
22
timeout: int = 120,
23
**kwargs
24
) -> AsyncResult:
23
timeout: int = 120, **kwargs) -> AsyncResult:
24
25
25
if not cookies:
26
cookies = get_cookies("www.aitianhu.com")
26
cookies = browser_cookie3.chrome(domain_name='www.aitianhu.com')
27
if not cookies:
28
raise RuntimeError(f"g4f.provider.{cls.__name__} requires cookies")
29
27
30
data = {
28
31
"prompt": format_prompt(messages),
29
32
"options": {},
@@ -32,28 +35,42 @@ class AItianhu(AsyncGeneratorProvider):
32
35
"top_p": 1,
33
36
**kwargs
34
37
}
38
35
39
headers = {
36
"Authority": cls.url,
37
"Accept": "application/json, text/plain, */*",
38
"Origin": cls.url,
39
"Referer": f"{cls.url}/"
40
'authority': 'www.aitianhu.com',
41
'accept': 'application/json, text/plain, */*',
42
'accept-language': 'en,fr-FR;q=0.9,fr;q=0.8,es-ES;q=0.7,es;q=0.6,en-US;q=0.5,am;q=0.4,de;q=0.3',
43
'content-type': 'application/json',
44
'origin': 'https://www.aitianhu.com',
45
'referer': 'https://www.aitianhu.com/',
46
'sec-ch-ua': '"Chromium";v="118", "Google Chrome";v="118", "Not=A?Brand";v="99"',
47
'sec-ch-ua-mobile': '?0',
48
'sec-ch-ua-platform': '"macOS"',
49
'sec-fetch-dest': 'empty',
50
'sec-fetch-mode': 'cors',
51
'sec-fetch-site': 'same-origin',
52
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36',
40
53
}
41
async with StreamSession(
42
headers=headers,
43
cookies=cookies,
44
timeout=timeout,
45
proxies={"https": proxy},
46
impersonate="chrome107",
47
verify=False
48
) as session:
54
55
async with StreamSession(headers=headers,
56
cookies=cookies,
57
timeout=timeout,
58
proxies={"https": proxy},
59
impersonate="chrome107", verify=False) as session:
60
49
61
async with session.post(f"{cls.url}/api/chat-process", json=data) as response:
50
62
response.raise_for_status()
63
51
64
async for line in response.iter_lines():
52
65
if line == b"<script>":
53
66
raise RuntimeError("Solve challenge and pass cookies")
67
54
68
if b"platform's risk control" in line:
55
69
raise RuntimeError("Platform's Risk Control")
70
71
print(line)
56
72
line = json.loads(line)
73
57
74
if "detail" in line:
58
75
content = line["detail"]["choices"][0]["delta"].get("content")
59
76
if content:
@@ -37,6 +37,8 @@ class AItianhuSpace(AsyncGeneratorProvider):
37
37
domain = f"{rand}.{domains[model]}"
38
38
if not cookies:
39
39
cookies = get_cookies(domain)
40
if not cookies:
41
raise RuntimeError(f"g4f.provider.{cls.__name__} requires cookies")
40
42
41
43
url = f'https://{domain}'
42
44
async with StreamSession(
@@ -8,7 +8,7 @@ from .base_provider import AsyncGeneratorProvider
8
8
9
9
class Acytoo(AsyncGeneratorProvider):
10
10
url = 'https://chat.acytoo.com'
11
working = True
11
working = False
12
12
supports_gpt_35_turbo = True
13
13
14
14
@classmethod
@@ -11,7 +11,7 @@ from .base_provider import AsyncGeneratorProvider
11
11
class Aibn(AsyncGeneratorProvider):
12
12
url = "https://aibn.cc"
13
13
supports_gpt_35_turbo = True
14
working = True
14
working = False
15
15
16
16
@classmethod
17
17
async def create_async_generator(
@@ -13,7 +13,7 @@ from .base_provider import AsyncGeneratorProvider
13
13
14
14
class Ails(AsyncGeneratorProvider):
15
15
url: str = "https://ai.ls"
16
working = True
16
working = False
17
17
supports_gpt_35_turbo = True
18
18
19
19
@staticmethod
@@ -8,7 +8,7 @@ from .base_provider import AsyncProvider, format_prompt
8
8
class ChatgptDuo(AsyncProvider):
9
9
url = "https://chatgptduo.com"
10
10
supports_gpt_35_turbo = True
11
working = True
11
working = False
12
12
13
13
@classmethod
14
14
async def create_async(
@@ -1,3 +1,5 @@
1
#cloudflare block
2
1
3
from __future__ import annotations
2
4
3
5
import re
@@ -5,13 +7,13 @@ from aiohttp import ClientSession
5
7
6
8
from ..typing import Messages
7
9
from .base_provider import AsyncProvider
8
from .helper import format_prompt
10
from .helper import format_prompt, get_cookies
9
11
10
12
11
13
class ChatgptFree(AsyncProvider):
12
14
url = "https://chatgptfree.ai"
13
15
supports_gpt_35_turbo = True
14
working = True
16
working = False
15
17
_post_id = None
16
18
_nonce = None
17
19
@@ -23,6 +25,8 @@ class ChatgptFree(AsyncProvider):
23
25
proxy: str = None,
24
26
**kwargs
25
27
) -> str:
28
cookies = get_cookies('chatgptfree.ai')
29
26
30
headers = {
27
31
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/118.0",
28
32
"Accept": "*/*",
@@ -41,7 +45,8 @@ class ChatgptFree(AsyncProvider):
41
45
}
42
46
async with ClientSession(headers=headers) as session:
43
47
if not cls._nonce:
44
async with session.get(f"{cls.url}/", proxy=proxy) as response:
48
async with session.get(f"{cls.url}/",
49
proxy=proxy, cookies=cookies) as response:
45
50
response.raise_for_status()
46
51
response = await response.text()
47
52
result = re.search(r'data-post-id="([0-9]+)"', response)
@@ -10,7 +10,7 @@ from .helper import format_prompt
10
10
11
11
class Cromicle(AsyncGeneratorProvider):
12
12
url: str = 'https://cromicle.top'
13
working: bool = True
13
working: bool = False
14
14
supports_gpt_35_turbo: bool = True
15
15
16
16
@classmethod
@@ -1,29 +1,36 @@
1
# cloudflare block
2
1
3
from __future__ import annotations
2
4
3
5
from aiohttp import ClientSession
4
6
5
7
from ..typing import Messages
6
8
from .base_provider import AsyncProvider
9
from .helper import get_cookies
7
10
8
11
9
12
class GptChatly(AsyncProvider):
10
13
url = "https://gptchatly.com"
11
14
supports_gpt_35_turbo = True
12
15
supports_gpt_4 = True
13
working = True
16
working = False
14
17
15
18
@classmethod
16
19
async def create_async(
17
20
cls,
18
21
model: str,
19
22
messages: Messages,
20
proxy: str = None,
21
**kwargs
22
) -> str:
23
proxy: str = None, cookies: dict = None, **kwargs) -> str:
24
25
if not cookies:
26
cookies = get_cookies('gptchatly.com')
27
28
23
29
if model.startswith("gpt-4"):
24
30
chat_url = f"{cls.url}/fetch-gpt4-response"
25
31
else:
26
32
chat_url = f"{cls.url}/fetch-response"
33
27
34
headers = {
28
35
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/118.0",
29
36
"Accept": "*/*",
@@ -1,3 +1,5 @@
1
# not using WS anymore
2
1
3
from __future__ import annotations
2
4
3
5
import json, uuid, hashlib, time, random
@@ -19,7 +21,7 @@ models = {
19
21
20
22
class Myshell(AsyncGeneratorProvider):
21
23
url = "https://app.myshell.ai/chat"
22
working = True
24
working = False
23
25
supports_gpt_35_turbo = True
24
26
supports_gpt_4 = True
25
27
@@ -172,4 +174,46 @@ def generate_visitor_id(user_agent: str) -> str:
172
174
r = hex(int(random.random() * (16**16)))[2:-2]
173
175
d = xor_hash(user_agent)
174
176
e = hex(1080 * 1920)[2:]
175
return f"{f}-{r}-{d}-{e}-{f}"
177
return f"{f}-{r}-{d}-{e}-{f}"
178
179
180
181
# update
182
# from g4f.requests import StreamSession
183
184
# async def main():
185
# headers = {
186
# 'authority': 'api.myshell.ai',
187
# 'accept': 'application/json',
188
# 'accept-language': 'en,fr-FR;q=0.9,fr;q=0.8,es-ES;q=0.7,es;q=0.6,en-US;q=0.5,am;q=0.4,de;q=0.3',
189
# 'content-type': 'application/json',
190
# 'myshell-service-name': 'organics-api',
191
# 'origin': 'https://app.myshell.ai',
192
# 'referer': 'https://app.myshell.ai/',
193
# 'sec-ch-ua': '"Chromium";v="118", "Google Chrome";v="118", "Not=A?Brand";v="99"',
194
# 'sec-ch-ua-mobile': '?0',
195
# 'sec-ch-ua-platform': '"macOS"',
196
# 'sec-fetch-dest': 'empty',
197
# 'sec-fetch-mode': 'cors',
198
# 'sec-fetch-site': 'same-site',
199
# 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36',
200
# 'visitor-id': '18ae8fe5d916d3-0213f29594b17f-18525634-157188-18ae8fe5d916d3',
201
# }
202
203
# json_data = {
204
# 'conversation_scenario': 3,
205
# 'botId': '4738',
206
# 'message': 'hi',
207
# 'messageType': 1,
208
# }
209
210
# async with StreamSession(headers=headers, impersonate="chrome110") as session:
211
# async with session.post(f'https://api.myshell.ai/v1/bot/chat/send_message',
212
# json=json_data) as response:
213
214
# response.raise_for_status()
215
# async for chunk in response.iter_content():
216
# print(chunk.decode("utf-8"))
217
218
# import asyncio
219
# asyncio.run(main())
@@ -8,7 +8,7 @@ from ..typing import AsyncResult, Messages
8
8
9
9
class Ylokh(AsyncGeneratorProvider):
10
10
url = "https://chat.ylokh.xyz"
11
working = True
11
working = False
12
12
supports_gpt_35_turbo = True
13
13
14
14