返回提交历史
Modified
README.md
+10
-10
Modified
g4f/Provider/AItianhu.py
+3
-4
Modified
g4f/Provider/AItianhuSpace.py
+22
-22
Modified
g4f/Provider/Aichat.py
+34
-25
Modified
g4f/Provider/ChatForAi.py
+1
-1
Modified
g4f/Provider/Chatgpt4Online.py
+2
-1
Modified
g4f/Provider/ChatgptDemo.py
+1
-1
Modified
g4f/Provider/ChatgptFree.py
+33
-20
Modified
g4f/Provider/ChatgptLogin.py
+1
-1
Modified
g4f/Provider/FreeGpt.py
+1
-2
Modified
g4f/Provider/GptChatly.py
+23
-23
Modified
g4f/Provider/GptGod.py
+5
-1
Modified
g4f/Provider/Liaobots.py
+1
-1
Modified
g4f/Provider/Opchatgpts.py
+3
-6
Modified
g4f/Provider/Vercel.py
+0
-2
Modified
g4f/Provider/Yqcloud.py
+1
-1
Modified
g4f/Provider/helper.py
+44
-12
Modified
g4f/__init__.py
+7
-5
Modified
g4f/models.py
+2
-1
Modified
setup.py
+1
-1
XFEstudio/gpt4free
~ | g4f `v-0.1.7.2`
patch / unpatch providers
ae8dae82
代码差异
20 个文件
+195
-140
@@ -2,7 +2,7 @@
2
2
3
3
By using this repository or any code related to it, you agree to the [legal notice](./LEGAL_NOTICE.md). The author is not responsible for any copies, forks, reuploads made by other users, or anything else related to gpt4free. This is the author's only account and repository. To prevent impersonation or irresponsible actions, please comply with the GNU GPL license this Repository uses.
4
4
5
- latest pypi version: [`0.1.7.1`](https://pypi.org/project/g4f/0.1.7.1)
5
- latest pypi version: [`0.1.7.2`](https://pypi.org/project/g4f/0.1.7.2)
6
6
```sh
7
7
pip install -U g4f
8
8
```
@@ -412,37 +412,34 @@ if __name__ == "__main__":
412
412
413
413
| Website| Provider| gpt-3.5 | Stream | Async | Status | Auth |
414
414
| ------ | ------- | ------- | --------- | --------- | ------ | ---- |
415
| [www.aitianhu.com](https://www.aitianhu.com) | `g4f.Provider.AItianhu` | ✔️ | ✔️ | ✔️ |  | ❌ |
415
416
| [chat3.aiyunos.top](https://chat3.aiyunos.top/) | `g4f.Provider.AItianhuSpace` | ✔️ | ✔️ | ✔️ |  | ❌ |
416
417
| [e.aiask.me](https://e.aiask.me) | `g4f.Provider.AiAsk` | ✔️ | ✔️ | ✔️ |  | ❌ |
417
418
| [chat-gpt.org](https://chat-gpt.org/chat) | `g4f.Provider.Aichat` | ✔️ | ❌ | ✔️ |  | ❌ |
418
419
| [www.chatbase.co](https://www.chatbase.co) | `g4f.Provider.ChatBase` | ✔️ | ✔️ | ✔️ |  | ❌ |
419
| [chatforai.store](https://chatforai.store) | `g4f.Provider.ChatForAi` | ✔️ | ✔️ | ✔️ |  | ❌ |
420
| [chatgpt4online.org](https://chatgpt4online.org) | `g4f.Provider.Chatgpt4Online` | ✔️ | ✔️ | ✔️ |  | ❌ |
421
420
| [chatgpt.ai](https://chatgpt.ai/) | `g4f.Provider.ChatgptAi` | ✔️ | ❌ | ✔️ |  | ❌ |
422
| [chat.chatgptdemo.net](https://chat.chatgptdemo.net) | `g4f.Provider.ChatgptDemo` | ✔️ | ✔️ | ✔️ |  | ❌ |
423
| [chatgptlogin.ai](https://chatgptlogin.ai) | `g4f.Provider.ChatgptLogin` | ✔️ | ✔️ | ✔️ |  | ❌ |
421
| [chatgptfree.ai](https://chatgptfree.ai) | `g4f.Provider.ChatgptFree` | ✔️ | ❌ | ✔️ |  | ❌ |
424
422
| [chatgptx.de](https://chatgptx.de) | `g4f.Provider.ChatgptX` | ✔️ | ✔️ | ✔️ |  | ❌ |
425
423
| [freegpts1.aifree.site](https://freegpts1.aifree.site/) | `g4f.Provider.FreeGpt` | ✔️ | ✔️ | ✔️ |  | ❌ |
426
424
| [gptalk.net](https://gptalk.net) | `g4f.Provider.GPTalk` | ✔️ | ✔️ | ✔️ |  | ❌ |
427
425
| [ai18.gptforlove.com](https://ai18.gptforlove.com) | `g4f.Provider.GptForLove` | ✔️ | ✔️ | ✔️ |  | ❌ |
428
426
| [gptgo.ai](https://gptgo.ai) | `g4f.Provider.GptGo` | ✔️ | ✔️ | ✔️ |  | ❌ |
429
| [gptgod.site](https://gptgod.site) | `g4f.Provider.GptGod` | ✔️ | ✔️ | ✔️ |  | ❌ |
430
427
| [www.llama2.ai](https://www.llama2.ai) | `g4f.Provider.Llama2` | ✔️ | ✔️ | ✔️ |  | ❌ |
431
428
| [noowai.com](https://noowai.com) | `g4f.Provider.NoowAi` | ✔️ | ✔️ | ✔️ |  | ❌ |
432
| [opchatgpts.net](https://opchatgpts.net) | `g4f.Provider.Opchatgpts` | ✔️ | ✔️ | ✔️ |  | ❌ |
433
429
| [chat.openai.com](https://chat.openai.com) | `g4f.Provider.OpenaiChat` | ✔️ | ✔️ | ✔️ |  | ✔️ |
434
430
| [theb.ai](https://theb.ai) | `g4f.Provider.Theb` | ✔️ | ✔️ | ❌ |  | ✔️ |
435
431
| [sdk.vercel.ai](https://sdk.vercel.ai) | `g4f.Provider.Vercel` | ✔️ | ✔️ | ❌ |  | ❌ |
436
432
| [you.com](https://you.com) | `g4f.Provider.You` | ✔️ | ✔️ | ✔️ |  | ❌ |
437
| [chat9.yqcloud.top](https://chat9.yqcloud.top/) | `g4f.Provider.Yqcloud` | ✔️ | ✔️ | ✔️ |  | ❌ |
438
| [www.aitianhu.com](https://www.aitianhu.com) | `g4f.Provider.AItianhu` | ✔️ | ✔️ | ✔️ |  | ❌ |
439
433
| [chat.acytoo.com](https://chat.acytoo.com) | `g4f.Provider.Acytoo` | ✔️ | ✔️ | ✔️ |  | ❌ |
440
434
| [aiservice.vercel.app](https://aiservice.vercel.app/) | `g4f.Provider.AiService` | ✔️ | ❌ | ❌ |  | ❌ |
441
435
| [aibn.cc](https://aibn.cc) | `g4f.Provider.Aibn` | ✔️ | ✔️ | ✔️ |  | ❌ |
442
436
| [ai.ls](https://ai.ls) | `g4f.Provider.Ails` | ✔️ | ✔️ | ✔️ |  | ❌ |
443
437
| [chataigpt.org](https://chataigpt.org) | `g4f.Provider.ChatAiGpt` | ✔️ | ✔️ | ✔️ |  | ❌ |
438
| [chatforai.store](https://chatforai.store) | `g4f.Provider.ChatForAi` | ✔️ | ✔️ | ✔️ |  | ❌ |
439
| [chatgpt4online.org](https://chatgpt4online.org) | `g4f.Provider.Chatgpt4Online` | ✔️ | ✔️ | ✔️ |  | ❌ |
440
| [chat.chatgptdemo.net](https://chat.chatgptdemo.net) | `g4f.Provider.ChatgptDemo` | ✔️ | ✔️ | ✔️ |  | ❌ |
444
441
| [chatgptduo.com](https://chatgptduo.com) | `g4f.Provider.ChatgptDuo` | ✔️ | ❌ | ✔️ |  | ❌ |
445
| [chatgptfree.ai](https://chatgptfree.ai) | `g4f.Provider.ChatgptFree` | ✔️ | ❌ | ✔️ |  | ❌ |
442
| [chatgptlogin.ai](https://chatgptlogin.ai) | `g4f.Provider.ChatgptLogin` | ✔️ | ✔️ | ✔️ |  | ❌ |
446
443
| [ava-ai-ef611.web.app](https://ava-ai-ef611.web.app) | `g4f.Provider.CodeLinkAva` | ✔️ | ✔️ | ✔️ |  | ❌ |
447
444
| [cromicle.top](https://cromicle.top) | `g4f.Provider.Cromicle` | ✔️ | ✔️ | ✔️ |  | ❌ |
448
445
| [chat.dfehub.com](https://chat.dfehub.com/) | `g4f.Provider.DfeHub` | ✔️ | ✔️ | ❌ |  | ❌ |
@@ -451,8 +448,10 @@ if __name__ == "__main__":
451
448
| [chat9.fastgpt.me](https://chat9.fastgpt.me/) | `g4f.Provider.FastGpt` | ✔️ | ✔️ | ❌ |  | ❌ |
452
449
| [forefront.com](https://forefront.com) | `g4f.Provider.Forefront` | ✔️ | ✔️ | ❌ |  | ❌ |
453
450
| [chat.getgpt.world](https://chat.getgpt.world/) | `g4f.Provider.GetGpt` | ✔️ | ✔️ | ❌ |  | ❌ |
451
| [gptgod.site](https://gptgod.site) | `g4f.Provider.GptGod` | ✔️ | ✔️ | ✔️ |  | ❌ |
454
452
| [komo.ai](https://komo.ai/api/ask) | `g4f.Provider.Komo` | ✔️ | ✔️ | ✔️ |  | ❌ |
455
453
| [ai.okmiku.com](https://ai.okmiku.com) | `g4f.Provider.MikuChat` | ✔️ | ✔️ | ✔️ |  | ❌ |
454
| [opchatgpts.net](https://opchatgpts.net) | `g4f.Provider.Opchatgpts` | ✔️ | ✔️ | ✔️ |  | ❌ |
456
455
| [www.perplexity.ai](https://www.perplexity.ai) | `g4f.Provider.PerplexityAi` | ✔️ | ❌ | ✔️ |  | ❌ |
457
456
| [talkai.info](https://talkai.info) | `g4f.Provider.TalkAi` | ✔️ | ✔️ | ✔️ |  | ❌ |
458
457
| [p5.v50.ltd](https://p5.v50.ltd) | `g4f.Provider.V50` | ✔️ | ❌ | ❌ |  | ❌ |
@@ -460,6 +459,7 @@ if __name__ == "__main__":
460
459
| [wewordle.org](https://wewordle.org) | `g4f.Provider.Wewordle` | ✔️ | ❌ | ✔️ |  | ❌ |
461
460
| [chat.wuguokai.xyz](https://chat.wuguokai.xyz) | `g4f.Provider.Wuguokai` | ✔️ | ❌ | ❌ |  | ❌ |
462
461
| [chat.ylokh.xyz](https://chat.ylokh.xyz) | `g4f.Provider.Ylokh` | ✔️ | ✔️ | ✔️ |  | ❌ |
462
| [chat9.yqcloud.top](https://chat9.yqcloud.top/) | `g4f.Provider.Yqcloud` | ✔️ | ✔️ | ✔️ |  | ❌ |
463
463
464
464
### Other Models
465
465
@@ -10,7 +10,7 @@ from .base_provider import AsyncGeneratorProvider, format_prompt, get_cookies
10
10
11
11
class AItianhu(AsyncGeneratorProvider):
12
12
url = "https://www.aitianhu.com"
13
working = False
13
working = True
14
14
supports_gpt_35_turbo = True
15
15
16
16
@classmethod
@@ -23,9 +23,9 @@ class AItianhu(AsyncGeneratorProvider):
23
23
timeout: int = 120, **kwargs) -> AsyncResult:
24
24
25
25
if not cookies:
26
cookies = browser_cookie3.chrome(domain_name='www.aitianhu.com')
26
cookies = get_cookies(domain_name='www.aitianhu.com')
27
27
if not cookies:
28
raise RuntimeError(f"g4f.provider.{cls.__name__} requires cookies")
28
raise RuntimeError(f"g4f.provider.{cls.__name__} requires cookies [refresh https://www.aitianhu.com on chrome]")
29
29
30
30
data = {
31
31
"prompt": format_prompt(messages),
@@ -68,7 +68,6 @@ class AItianhu(AsyncGeneratorProvider):
68
68
if b"platform's risk control" in line:
69
69
raise RuntimeError("Platform's Risk Control")
70
70
71
print(line)
72
71
line = json.loads(line)
73
72
74
73
if "detail" in line:
@@ -1,9 +1,9 @@
1
1
from __future__ import annotations
2
2
3
3
import random, json
4
5
from ..typing import AsyncResult, Messages
6
from ..requests import StreamSession
4
from ..debug import logging
5
from ..typing import AsyncResult, Messages
6
from ..requests import StreamSession
7
7
from .base_provider import AsyncGeneratorProvider, format_prompt, get_cookies
8
8
9
9
domains = {
@@ -17,37 +17,37 @@ class AItianhuSpace(AsyncGeneratorProvider):
17
17
supports_gpt_35_turbo = True
18
18
19
19
@classmethod
20
async def create_async_generator(
21
cls,
22
model: str,
23
messages: Messages,
24
proxy: str = None,
25
domain: str = None,
26
cookies: dict = None,
27
timeout: int = 120,
28
**kwargs
29
) -> AsyncResult:
20
async def create_async_generator(cls,
21
model: str,
22
messages: Messages,
23
proxy: str = None,
24
domain: str = None,
25
cookies: dict = None,
26
timeout: int = 10, **kwargs) -> AsyncResult:
27
30
28
if not model:
31
29
model = "gpt-3.5-turbo"
30
32
31
elif not model in domains:
33
32
raise ValueError(f"Model are not supported: {model}")
33
34
34
if not domain:
35
35
chars = 'abcdefghijklmnopqrstuvwxyz0123456789'
36
36
rand = ''.join(random.choice(chars) for _ in range(6))
37
37
domain = f"{rand}.{domains[model]}"
38
39
if logging:
40
print(f"AItianhuSpace | using domain: {domain}")
41
38
42
if not cookies:
39
cookies = get_cookies(domain)
43
cookies = get_cookies('.aitianhu.space')
40
44
if not cookies:
41
raise RuntimeError(f"g4f.provider.{cls.__name__} requires cookies")
45
raise RuntimeError(f"g4f.provider.{cls.__name__} requires cookies [refresh https://{domain} on chrome]")
42
46
43
47
url = f'https://{domain}'
44
async with StreamSession(
45
proxies={"https": proxy},
46
cookies=cookies,
47
timeout=timeout,
48
impersonate="chrome110",
49
verify=False
50
) as session:
48
async with StreamSession(proxies={"https": proxy},
49
cookies=cookies, timeout=timeout, impersonate="chrome110", verify=False) as session:
50
51
51
data = {
52
52
"prompt": format_prompt(messages),
53
53
"options": {},
@@ -4,7 +4,8 @@ from aiohttp import ClientSession
4
4
5
5
from ..typing import Messages
6
6
from .base_provider import AsyncProvider, format_prompt
7
7
from .helper import get_cookies
8
from ..requests import StreamSession
8
9
9
10
class Aichat(AsyncProvider):
10
11
url = "https://chat-gpt.org/chat"
@@ -15,27 +16,34 @@ class Aichat(AsyncProvider):
15
16
async def create_async(
16
17
model: str,
17
18
messages: Messages,
18
proxy: str = None,
19
**kwargs
20
) -> str:
19
proxy: str = None, **kwargs) -> str:
20
21
cookies = get_cookies('chat-gpt.org') if not kwargs.get('cookies') else kwargs.get('cookies')
22
if not cookies:
23
raise RuntimeError(f"g4f.provider.Aichat requires cookies, [refresh https://chat-gpt.org on chrome]")
24
21
25
headers = {
22
"authority": "chat-gpt.org",
23
"accept": "*/*",
24
"cache-control": "no-cache",
25
"content-type": "application/json",
26
"origin": "https://chat-gpt.org",
27
"pragma": "no-cache",
28
"referer": "https://chat-gpt.org/chat",
29
"sec-ch-ua-mobile": "?0",
30
"sec-ch-ua-platform": '"macOS"',
31
"sec-fetch-dest": "empty",
32
"sec-fetch-mode": "cors",
33
"sec-fetch-site": "same-origin",
34
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36",
26
'authority': 'chat-gpt.org',
27
'accept': '*/*',
28
'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',
29
'content-type': 'application/json',
30
'origin': 'https://chat-gpt.org',
31
'referer': 'https://chat-gpt.org/chat',
32
'sec-ch-ua': '"Chromium";v="118", "Google Chrome";v="118", "Not=A?Brand";v="99"',
33
'sec-ch-ua-mobile': '?0',
34
'sec-ch-ua-platform': '"macOS"',
35
'sec-fetch-dest': 'empty',
36
'sec-fetch-mode': 'cors',
37
'sec-fetch-site': 'same-origin',
38
'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',
35
39
}
36
async with ClientSession(
37
headers=headers
38
) as session:
40
41
async with StreamSession(headers=headers,
42
cookies=cookies,
43
timeout=6,
44
proxies={"https": proxy} if proxy else None,
45
impersonate="chrome110", verify=False) as session:
46
39
47
json_data = {
40
48
"message": format_prompt(messages),
41
49
"temperature": kwargs.get('temperature', 0.5),
@@ -43,13 +51,14 @@ class Aichat(AsyncProvider):
43
51
"top_p": kwargs.get('top_p', 1),
44
52
"frequency_penalty": 0,
45
53
}
46
async with session.post(
47
"https://chat-gpt.org/api/text",
48
proxy=proxy,
49
json=json_data
50
) as response:
54
55
async with session.post("https://chat-gpt.org/api/text",
56
json=json_data) as response:
57
51
58
response.raise_for_status()
52
59
result = await response.json()
60
53
61
if not result['response']:
54
62
raise Exception(f"Error Response: {result}")
63
55
64
return result["message"]
@@ -10,7 +10,7 @@ from .base_provider import AsyncGeneratorProvider
10
10
11
11
class ChatForAi(AsyncGeneratorProvider):
12
12
url = "https://chatforai.store"
13
working = True
13
working = False
14
14
supports_gpt_35_turbo = True
15
15
16
16
@classmethod
@@ -10,7 +10,7 @@ from .base_provider import AsyncGeneratorProvider
10
10
class Chatgpt4Online(AsyncGeneratorProvider):
11
11
url = "https://chatgpt4online.org"
12
12
supports_gpt_35_turbo = True
13
working = True
13
working = False
14
14
15
15
@classmethod
16
16
async def create_async_generator(
@@ -31,6 +31,7 @@ class Chatgpt4Online(AsyncGeneratorProvider):
31
31
"newMessage": messages[-1]["content"],
32
32
"stream": True
33
33
}
34
34
35
async with session.post(cls.url + "/wp-json/mwai-ui/v1/chats/submit", json=data, proxy=proxy) as response:
35
36
response.raise_for_status()
36
37
async for line in response.content:
@@ -10,7 +10,7 @@ from .helper import format_prompt
10
10
class ChatgptDemo(AsyncGeneratorProvider):
11
11
url = "https://chat.chatgptdemo.net"
12
12
supports_gpt_35_turbo = True
13
working = True
13
working = False
14
14
15
15
@classmethod
16
16
async def create_async_generator(
@@ -5,6 +5,7 @@ from __future__ import annotations
5
5
import re
6
6
from aiohttp import ClientSession
7
7
8
from ..requests import StreamSession
8
9
from ..typing import Messages
9
10
from .base_provider import AsyncProvider
10
11
from .helper import format_prompt, get_cookies
@@ -13,7 +14,7 @@ from .helper import format_prompt, get_cookies
13
14
class ChatgptFree(AsyncProvider):
14
15
url = "https://chatgptfree.ai"
15
16
supports_gpt_35_turbo = True
16
working = False
17
working = True
17
18
_post_id = None
18
19
_nonce = None
19
20
@@ -23,40 +24,50 @@ class ChatgptFree(AsyncProvider):
23
24
model: str,
24
25
messages: Messages,
25
26
proxy: str = None,
27
cookies: dict = None,
26
28
**kwargs
27
29
) -> str:
28
cookies = get_cookies('chatgptfree.ai')
29
30
31
if not cookies:
32
cookies = get_cookies('chatgptfree.ai')
33
if not cookies:
34
raise RuntimeError(f"g4f.provider.{cls.__name__} requires cookies [refresh https://chatgptfree.ai on chrome]")
35
30
36
headers = {
31
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/118.0",
32
"Accept": "*/*",
33
"Accept-Language": "de,en-US;q=0.7,en;q=0.3",
34
"Accept-Encoding": "gzip, deflate, br",
35
"Origin": cls.url,
36
"Alt-Used": "chatgptfree.ai",
37
"Connection": "keep-alive",
38
"Referer": f"{cls.url}/",
39
"Sec-Fetch-Dest": "empty",
40
"Sec-Fetch-Mode": "cors",
41
"Sec-Fetch-Site": "same-origin",
42
"Pragma": "no-cache",
43
"Cache-Control": "no-cache",
44
"TE": "trailers"
37
'authority': 'chatgptfree.ai',
38
'accept': '*/*',
39
'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',
40
'origin': 'https://chatgptfree.ai',
41
'referer': 'https://chatgptfree.ai/chat/',
42
'sec-ch-ua': '"Chromium";v="118", "Google Chrome";v="118", "Not=A?Brand";v="99"',
43
'sec-ch-ua-mobile': '?0',
44
'sec-ch-ua-platform': '"macOS"',
45
'sec-fetch-dest': 'empty',
46
'sec-fetch-mode': 'cors',
47
'sec-fetch-site': 'same-origin',
48
'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',
45
49
}
46
async with ClientSession(headers=headers) as session:
50
51
async with StreamSession(headers=headers,
52
impersonate="chrome107", proxies={"https": proxy}, timeout=10) as session:
53
47
54
if not cls._nonce:
48
async with session.get(f"{cls.url}/",
49
proxy=proxy, cookies=cookies) as response:
55
async with session.get(f"{cls.url}/", cookies=cookies) as response:
56
50
57
response.raise_for_status()
51
58
response = await response.text()
59
52
60
result = re.search(r'data-post-id="([0-9]+)"', response)
53
61
if not result:
54
62
raise RuntimeError("No post id found")
55
63
cls._post_id = result.group(1)
64
56
65
result = re.search(r'data-nonce="(.*?)"', response)
57
66
if not result:
58
67
raise RuntimeError("No nonce found")
68
59
69
cls._nonce = result.group(1)
70
60
71
prompt = format_prompt(messages)
61
72
data = {
62
73
"_wpnonce": cls._nonce,
@@ -66,6 +77,8 @@ class ChatgptFree(AsyncProvider):
66
77
"message": prompt,
67
78
"bot_id": "0"
68
79
}
69
async with session.post(cls.url + "/wp-admin/admin-ajax.php", data=data, proxy=proxy) as response:
80
async with session.post(cls.url + "/wp-admin/admin-ajax.php",
81
data=data, cookies=cookies) as response:
82
70
83
response.raise_for_status()
71
84
return (await response.json())["data"]
@@ -13,7 +13,7 @@ from .helper import format_prompt
13
13
class ChatgptLogin(AsyncGeneratorProvider):
14
14
url = "https://chatgptlogin.ai"
15
15
supports_gpt_35_turbo = True
16
working = True
16
working = False
17
17
_user_id = None
18
18
19
19
@classmethod
@@ -7,8 +7,7 @@ from ..requests import StreamSession
7
7
from .base_provider import AsyncGeneratorProvider
8
8
9
9
domains = [
10
'https://k.aifree.site',
11
'https://p.aifree.site'
10
'https://r.aifree.site'
12
11
]
13
12
14
13
class FreeGpt(AsyncGeneratorProvider):
@@ -2,18 +2,17 @@
2
2
3
3
from __future__ import annotations
4
4
5
from aiohttp import ClientSession
6
7
from ..typing import Messages
5
from ..requests import StreamSession
6
from ..typing import Messages
8
7
from .base_provider import AsyncProvider
9
from .helper import get_cookies
8
from .helper import get_cookies
10
9
11
10
12
11
class GptChatly(AsyncProvider):
13
12
url = "https://gptchatly.com"
14
13
supports_gpt_35_turbo = True
15
14
supports_gpt_4 = True
16
working = False
15
working = True
17
16
18
17
@classmethod
19
18
async def create_async(
@@ -22,9 +21,9 @@ class GptChatly(AsyncProvider):
22
21
messages: Messages,
23
22
proxy: str = None, cookies: dict = None, **kwargs) -> str:
24
23
24
cookies = get_cookies('gptchatly.com') if not cookies else cookies
25
25
if not cookies:
26
cookies = get_cookies('gptchatly.com')
27
26
raise RuntimeError(f"g4f.provider.GptChatly requires cookies, [refresh https://gptchatly.com on chrome]")
28
27
29
28
if model.startswith("gpt-4"):
30
29
chat_url = f"{cls.url}/fetch-gpt4-response"
@@ -32,25 +31,26 @@ class GptChatly(AsyncProvider):
32
31
chat_url = f"{cls.url}/fetch-response"
33
32
34
33
headers = {
35
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/118.0",
36
"Accept": "*/*",
37
"Accept-Language": "de,en-US;q=0.7,en;q=0.3",
38
"Accept-Encoding": "gzip, deflate, br",
39
"Referer": f"{cls.url}/",
40
"Content-Type": "application/json",
41
"Origin": cls.url,
42
"Connection": "keep-alive",
43
"Sec-Fetch-Dest": "empty",
44
"Sec-Fetch-Mode": "cors",
45
"Sec-Fetch-Site": "same-origin",
46
"Pragma": "no-cache",
47
"Cache-Control": "no-cache",
48
"TE": "trailers",
34
'authority': 'gptchatly.com',
35
'accept': '*/*',
36
'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',
37
'content-type': 'application/json',
38
'origin': 'https://gptchatly.com',
39
'referer': 'https://gptchatly.com/',
40
'sec-ch-ua': '"Chromium";v="118", "Google Chrome";v="118", "Not=A?Brand";v="99"',
41
'sec-ch-ua-mobile': '?0',
42
'sec-ch-ua-platform': '"macOS"',
43
'sec-fetch-dest': 'empty',
44
'sec-fetch-mode': 'cors',
45
'sec-fetch-site': 'same-origin',
46
'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',
49
47
}
50
async with ClientSession(headers=headers) as session:
48
49
async with StreamSession(headers=headers,
50
proxies={"https": proxy}, cookies=cookies, impersonate='chrome110') as session:
51
51
data = {
52
52
"past_conversations": messages
53
53
}
54
async with session.post(chat_url, json=data, proxy=proxy) as response:
54
async with session.post(chat_url, json=data) as response:
55
55
response.raise_for_status()
56
56
return (await response.json())["chatGPTResponse"]
@@ -8,7 +8,7 @@ from .helper import format_prompt
8
8
class GptGod(AsyncGeneratorProvider):
9
9
url = "https://gptgod.site"
10
10
supports_gpt_35_turbo = True
11
working = True
11
working = False
12
12
13
13
@classmethod
14
14
async def create_async_generator(
@@ -18,6 +18,7 @@ class GptGod(AsyncGeneratorProvider):
18
18
proxy: str = None,
19
19
**kwargs
20
20
) -> AsyncResult:
21
21
22
headers = {
22
23
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/118.0",
23
24
"Accept": "text/event-stream",
@@ -32,6 +33,7 @@ class GptGod(AsyncGeneratorProvider):
32
33
"Pragma": "no-cache",
33
34
"Cache-Control": "no-cache",
34
35
}
36
35
37
async with ClientSession(headers=headers) as session:
36
38
prompt = format_prompt(messages)
37
39
data = {
@@ -42,6 +44,8 @@ class GptGod(AsyncGeneratorProvider):
42
44
response.raise_for_status()
43
45
event = None
44
46
async for line in response.content:
47
print(line)
48
45
49
if line.startswith(b'event: '):
46
50
event = line[7:-1]
47
51
elif event == b"data" and line.startswith(b"data: "):