-
-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Aichatos and Blackbox Provider (#1822)
Providers added: - Feedough - Added a new provider with GPT-3 model - Cnote - Added a new provider with GPT-3.5 model
- Loading branch information
Showing
6 changed files
with
229 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from __future__ import annotations | ||
|
||
from aiohttp import ClientSession | ||
|
||
from ..typing import AsyncResult, Messages | ||
from .base_provider import AsyncGeneratorProvider | ||
from .helper import format_prompt | ||
|
||
import random | ||
|
||
|
||
class Aichatos(AsyncGeneratorProvider): | ||
url = "https://chat10.aichatos.xyz" | ||
api = "https://api.binjie.fun" | ||
working = True | ||
supports_gpt_35_turbo = True | ||
|
||
@classmethod | ||
async def create_async_generator( | ||
cls, | ||
model: str, | ||
messages: Messages, | ||
proxy: str = None, | ||
**kwargs | ||
) -> AsyncResult: | ||
headers = { | ||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36", | ||
"Accept": "application/json, text/plain, */*", | ||
"Accept-Language": "en-US,en;q=0.5", | ||
"Accept-Encoding": "gzip, deflate, br", | ||
"Content-Type": "application/json", | ||
"Origin": "https://chat10.aichatos.xyz", | ||
"DNT": "1", | ||
"Sec-GPC": "1", | ||
"Connection": "keep-alive", | ||
"Sec-Fetch-Dest": "empty", | ||
"Sec-Fetch-Mode": "cors", | ||
"Sec-Fetch-Site": "cross-site", | ||
"TE": "trailers", | ||
} | ||
async with ClientSession(headers=headers) as session: | ||
prompt = format_prompt(messages) | ||
userId = random.randint(1000000000000, 9999999999999) | ||
system_message: str = "", | ||
data = { | ||
"prompt": prompt, | ||
"userId": "#/chat/{userId}", | ||
"network": True, | ||
"system": system_message, | ||
"withoutContext": False, | ||
"stream": True, | ||
} | ||
async with session.post(f"{cls.api}/api/generateStream", json=data, proxy=proxy) as response: | ||
response.raise_for_status() | ||
async for chunk in response.content: | ||
if chunk: | ||
yield chunk.decode() |
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,56 @@ | ||
from __future__ import annotations | ||
|
||
import uuid | ||
import secrets | ||
from aiohttp import ClientSession | ||
|
||
from ..typing import AsyncResult, Messages | ||
from .base_provider import AsyncGeneratorProvider | ||
|
||
class Blackbox(AsyncGeneratorProvider): | ||
url = "https://www.blackbox.ai" | ||
working = True | ||
|
||
@classmethod | ||
async def create_async_generator( | ||
cls, | ||
model: str, | ||
messages: Messages, | ||
proxy: str = None, | ||
**kwargs | ||
) -> AsyncResult: | ||
headers = { | ||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36", | ||
"Accept": "*/*", | ||
"Accept-Language": "en-US,en;q=0.5", | ||
"Accept-Encoding": "gzip, deflate, br", | ||
"Referer": cls.url, | ||
"Content-Type": "application/json", | ||
"Origin": cls.url, | ||
"DNT": "1", | ||
"Sec-GPC": "1", | ||
"Alt-Used": "www.blackbox.ai", | ||
"Connection": "keep-alive", | ||
} | ||
async with ClientSession(headers=headers) as session: | ||
random_id = secrets.token_hex(16) | ||
random_user_id = str(uuid.uuid4()) | ||
data = { | ||
"messages": messages, | ||
"id": random_id, | ||
"userId": random_user_id, | ||
"codeModelMode": True, | ||
"agentMode": {}, | ||
"trendingAgentMode": {}, | ||
"isMicMode": False, | ||
"isChromeExt": False, | ||
"playgroundMode": False, | ||
"webSearchMode": False, | ||
"userSystemPrompt": "", | ||
"githubToken": None | ||
} | ||
async with session.post(f"{cls.url}/api/chat", json=data, proxy=proxy) as response: | ||
response.raise_for_status() | ||
async for chunk in response.content: | ||
if chunk: | ||
yield chunk.decode() |
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,58 @@ | ||
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 Cnote(AsyncGeneratorProvider): | ||
url = "https://f1.cnote.top" | ||
api_url = "https://p1api.xjai.pro/freeapi/chat-process" | ||
working = True | ||
supports_gpt_35_turbo = True | ||
|
||
@classmethod | ||
async def create_async_generator( | ||
cls, | ||
model: str, | ||
messages: Messages, | ||
proxy: str = None, | ||
**kwargs | ||
) -> AsyncResult: | ||
headers = { | ||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36", | ||
"Accept": "application/json, text/plain, */*", | ||
"Accept-Language": "en-US,en;q=0.5", | ||
"Accept-Encoding": "gzip, deflate, br", | ||
"Content-Type": "application/json", | ||
"Origin": cls.url, | ||
"DNT": "1", | ||
"Sec-GPC": "1", | ||
"Connection": "keep-alive", | ||
"Sec-Fetch-Dest": "empty", | ||
"Sec-Fetch-Mode": "cors", | ||
"Sec-Fetch-Site": "cross-site", | ||
"TE": "trailers", | ||
} | ||
async with ClientSession(headers=headers) as session: | ||
prompt = format_prompt(messages) | ||
system_message: str = "", | ||
data = { | ||
"prompt": prompt, | ||
"systemMessage": system_message, | ||
"temperature": 0.8, | ||
"top_p": 1, | ||
} | ||
async with session.post(cls.api_url, json=data, proxy=proxy) as response: | ||
response.raise_for_status() | ||
async for chunk in response.content: | ||
if chunk: | ||
try: | ||
data = json.loads(chunk.decode().split("&KFw6loC9Qvy&")[-1]) | ||
text = data.get("text", "") | ||
yield text | ||
except (json.JSONDecodeError, IndexError): | ||
pass |
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,52 @@ | ||
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 Feedough(AsyncGeneratorProvider): | ||
url = "https://www.feedough.com" | ||
working = True | ||
supports_gpt_35_turbo = True | ||
|
||
@classmethod | ||
async def create_async_generator( | ||
cls, | ||
model: str, | ||
messages: Messages, | ||
proxy: str = None, | ||
**kwargs | ||
) -> AsyncResult: | ||
headers = { | ||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36", | ||
"Accept": "*/*", | ||
"Accept-Language": "en-US,en;q=0.5", | ||
"Accept-Encoding": "gzip, deflate, br", | ||
"Referer": "https://www.feedough.com/ai-prompt-generator/", | ||
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8", | ||
"Origin": "https://www.feedough.com", | ||
"DNT": "1", | ||
"Sec-GPC": "1", | ||
"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: | ||
prompt = format_prompt(messages) | ||
data = { | ||
"action": "aixg_generate", | ||
"prompt": prompt, | ||
} | ||
async with session.post(f"{cls.url}/wp-admin/admin-ajax.php", data=data, proxy=proxy) as response: | ||
response.raise_for_status() | ||
response_text = await response.text() | ||
response_json = json.loads(response_text) | ||
if response_json["success"]: | ||
message = response_json["data"]["message"] | ||
yield message |
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