-
-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1267 from hlohaus/any
Add AiChatOnline, ChatgptDemoAi, ChatgptNext Providers
- Loading branch information
Showing
202 changed files
with
453 additions
and
29,102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from __future__ import annotations | ||
|
||
import json | ||
from aiohttp import ClientSession | ||
|
||
from ..typing import AsyncResult, Messages | ||
from .base_provider import AsyncGeneratorProvider | ||
from .helper import get_random_string | ||
|
||
class AiChatOnline(AsyncGeneratorProvider): | ||
url = "https://aichatonline.org" | ||
working = True | ||
supports_gpt_35_turbo = True | ||
supports_message_history = False | ||
|
||
@classmethod | ||
async def create_async_generator( | ||
cls, | ||
model: str, | ||
messages: Messages, | ||
proxy: str = None, | ||
**kwargs | ||
) -> AsyncResult: | ||
headers = { | ||
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/119.0", | ||
"Accept": "text/event-stream", | ||
"Accept-Language": "de,en-US;q=0.7,en;q=0.3", | ||
"Accept-Encoding": "gzip, deflate, br", | ||
"Referer": f"{cls.url}/chatgpt/chat/", | ||
"Content-Type": "application/json", | ||
"Origin": cls.url, | ||
"Alt-Used": "aichatonline.org", | ||
"Connection": "keep-alive", | ||
"Sec-Fetch-Dest": "empty", | ||
"Sec-Fetch-Mode": "cors", | ||
"Sec-Fetch-Site": "same-origin", | ||
"TE": "trailers" | ||
} | ||
async with ClientSession(headers=headers) as session: | ||
data = { | ||
"botId": "default", | ||
"customId": None, | ||
"session": get_random_string(16), | ||
"chatId": get_random_string(), | ||
"contextId": 7, | ||
"messages": messages, | ||
"newMessage": messages[-1]["content"], | ||
"newImageId": None, | ||
"stream": True | ||
} | ||
async with session.post(f"{cls.url}/chatgpt/wp-json/mwai-ui/v1/chats/submit", json=data, proxy=proxy) as response: | ||
response.raise_for_status() | ||
async for chunk in response.content: | ||
if chunk.startswith(b"data: "): | ||
data = json.loads(chunk[6:]) | ||
if data["type"] == "live": | ||
yield data["data"] | ||
elif data["type"] == "end": | ||
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
from __future__ import annotations | ||
|
||
import json | ||
from aiohttp import ClientSession | ||
|
||
from ..typing import AsyncResult, Messages | ||
from .base_provider import AsyncGeneratorProvider | ||
from .helper import get_random_string | ||
|
||
class ChatgptDemoAi(AsyncGeneratorProvider): | ||
url = "https://chat.chatgptdemo.ai" | ||
working = True | ||
supports_gpt_35_turbo = True | ||
supports_message_history = True | ||
|
||
@classmethod | ||
async def create_async_generator( | ||
cls, | ||
model: str, | ||
messages: Messages, | ||
proxy: str = None, | ||
**kwargs | ||
) -> AsyncResult: | ||
headers = { | ||
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/119.0", | ||
"Accept": "*/*", | ||
"Accept-Language": "de,en-US;q=0.7,en;q=0.3", | ||
"Accept-Encoding": "gzip, deflate, br", | ||
"Referer": f"{cls.url}/", | ||
"Content-Type": "application/json", | ||
"Origin": cls.url, | ||
"Connection": "keep-alive", | ||
"Sec-Fetch-Dest": "empty", | ||
"Sec-Fetch-Mode": "cors", | ||
"Sec-Fetch-Site": "same-origin", | ||
"TE": "trailers" | ||
} | ||
async with ClientSession(headers=headers) as session: | ||
data = { | ||
"botId": "default", | ||
"customId": "8824fe9bdb323a5d585a3223aaa0cb6e", | ||
"session": "N/A", | ||
"chatId": get_random_string(12), | ||
"contextId": 2, | ||
"messages": messages, | ||
"newMessage": messages[-1]["content"], | ||
"stream": True | ||
} | ||
async with session.post(f"{cls.url}/wp-json/mwai-ui/v1/chats/submit", json=data, proxy=proxy) as response: | ||
response.raise_for_status() | ||
async for chunk in response.content: | ||
if chunk.startswith(b"data: "): | ||
data = json.loads(chunk[6:]) | ||
if data["type"] == "live": | ||
yield data["data"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
from __future__ import annotations | ||
|
||
import json | ||
from aiohttp import ClientSession | ||
|
||
from ..typing import AsyncResult, Messages | ||
from .base_provider import AsyncGeneratorProvider | ||
from .helper import format_prompt | ||
|
||
|
||
class ChatgptNext(AsyncGeneratorProvider): | ||
url = "https://www.chatgpt-free.cc" | ||
working = True | ||
supports_gpt_35_turbo = True | ||
|
||
@classmethod | ||
async def create_async_generator( | ||
cls, | ||
model: str, | ||
messages: Messages, | ||
proxy: str = None, | ||
**kwargs | ||
) -> AsyncResult: | ||
if not model: | ||
model = "gpt-3.5-turbo" | ||
headers = { | ||
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/119.0", | ||
"Accept": "text/event-stream", | ||
"Accept-Language": "de,en-US;q=0.7,en;q=0.3", | ||
"Accept-Encoding": "gzip, deflate, br", | ||
"Content-Type": "application/json", | ||
"Referer": "https://chat.fstha.com/", | ||
"x-requested-with": "XMLHttpRequest", | ||
"Origin": "https://chat.fstha.com", | ||
"Sec-Fetch-Dest": "empty", | ||
"Sec-Fetch-Mode": "cors", | ||
"Sec-Fetch-Site": "same-origin", | ||
"Authorization": "Bearer ak-chatgpt-nice", | ||
"Connection": "keep-alive", | ||
"Alt-Used": "chat.fstha.com", | ||
} | ||
async with ClientSession(headers=headers) as session: | ||
data = { | ||
"messages": messages, | ||
"stream": True, | ||
"model": model, | ||
"temperature": 0.5, | ||
"presence_penalty": 0, | ||
"frequency_penalty": 0, | ||
"top_p": 1, | ||
**kwargs | ||
} | ||
async with session.post(f"https://chat.fstha.com/api/openai/v1/chat/completions", json=data, proxy=proxy) as response: | ||
response.raise_for_status() | ||
async for chunk in response.content: | ||
if chunk.startswith(b"data: [DONE]"): | ||
break | ||
if chunk.startswith(b"data: "): | ||
content = json.loads(chunk[6:])["choices"][0]["delta"].get("content") | ||
if content: | ||
yield content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
# cloudflare block | ||
|
||
from __future__ import annotations | ||
|
||
from ..requests import StreamSession | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.