~ | remove non-working providers

pull/1086/head
abc 9 months ago
parent 46398e8ac6
commit 4a3b663ccd

@ -1,6 +1,7 @@
from __future__ import annotations
import json
import browser_cookie3
from ..typing import AsyncResult, Messages
from ..requests import StreamSession
@ -9,7 +10,7 @@ from .base_provider import AsyncGeneratorProvider, format_prompt, get_cookies
class AItianhu(AsyncGeneratorProvider):
url = "https://www.aitianhu.com"
working = True
working = False
supports_gpt_35_turbo = True
@classmethod
@ -19,11 +20,13 @@ class AItianhu(AsyncGeneratorProvider):
messages: Messages,
proxy: str = None,
cookies: dict = None,
timeout: int = 120,
**kwargs
) -> AsyncResult:
timeout: int = 120, **kwargs) -> AsyncResult:
if not cookies:
cookies = get_cookies("www.aitianhu.com")
cookies = browser_cookie3.chrome(domain_name='www.aitianhu.com')
if not cookies:
raise RuntimeError(f"g4f.provider.{cls.__name__} requires cookies")
data = {
"prompt": format_prompt(messages),
"options": {},
@ -32,28 +35,42 @@ class AItianhu(AsyncGeneratorProvider):
"top_p": 1,
**kwargs
}
headers = {
"Authority": cls.url,
"Accept": "application/json, text/plain, */*",
"Origin": cls.url,
"Referer": f"{cls.url}/"
'authority': 'www.aitianhu.com',
'accept': 'application/json, text/plain, */*',
'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',
'content-type': 'application/json',
'origin': 'https://www.aitianhu.com',
'referer': 'https://www.aitianhu.com/',
'sec-ch-ua': '"Chromium";v="118", "Google Chrome";v="118", "Not=A?Brand";v="99"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-origin',
'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',
}
async with StreamSession(
headers=headers,
cookies=cookies,
timeout=timeout,
proxies={"https": proxy},
impersonate="chrome107",
verify=False
) as session:
async with StreamSession(headers=headers,
cookies=cookies,
timeout=timeout,
proxies={"https": proxy},
impersonate="chrome107", verify=False) as session:
async with session.post(f"{cls.url}/api/chat-process", json=data) as response:
response.raise_for_status()
async for line in response.iter_lines():
if line == b"<script>":
raise RuntimeError("Solve challenge and pass cookies")
if b"platform's risk control" in line:
raise RuntimeError("Platform's Risk Control")
print(line)
line = json.loads(line)
if "detail" in line:
content = line["detail"]["choices"][0]["delta"].get("content")
if content:

@ -37,6 +37,8 @@ class AItianhuSpace(AsyncGeneratorProvider):
domain = f"{rand}.{domains[model]}"
if not cookies:
cookies = get_cookies(domain)
if not cookies:
raise RuntimeError(f"g4f.provider.{cls.__name__} requires cookies")
url = f'https://{domain}'
async with StreamSession(

@ -8,7 +8,7 @@ from .base_provider import AsyncGeneratorProvider
class Acytoo(AsyncGeneratorProvider):
url = 'https://chat.acytoo.com'
working = True
working = False
supports_gpt_35_turbo = True
@classmethod

@ -11,7 +11,7 @@ from .base_provider import AsyncGeneratorProvider
class Aibn(AsyncGeneratorProvider):
url = "https://aibn.cc"
supports_gpt_35_turbo = True
working = True
working = False
@classmethod
async def create_async_generator(

@ -13,7 +13,7 @@ from .base_provider import AsyncGeneratorProvider
class Ails(AsyncGeneratorProvider):
url: str = "https://ai.ls"
working = True
working = False
supports_gpt_35_turbo = True
@staticmethod

@ -8,7 +8,7 @@ from .base_provider import AsyncProvider, format_prompt
class ChatgptDuo(AsyncProvider):
url = "https://chatgptduo.com"
supports_gpt_35_turbo = True
working = True
working = False
@classmethod
async def create_async(

@ -1,3 +1,5 @@
#cloudflare block
from __future__ import annotations
import re
@ -5,13 +7,13 @@ from aiohttp import ClientSession
from ..typing import Messages
from .base_provider import AsyncProvider
from .helper import format_prompt
from .helper import format_prompt, get_cookies
class ChatgptFree(AsyncProvider):
url = "https://chatgptfree.ai"
supports_gpt_35_turbo = True
working = True
working = False
_post_id = None
_nonce = None
@ -23,6 +25,8 @@ class ChatgptFree(AsyncProvider):
proxy: str = None,
**kwargs
) -> str:
cookies = get_cookies('chatgptfree.ai')
headers = {
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/118.0",
"Accept": "*/*",
@ -41,7 +45,8 @@ class ChatgptFree(AsyncProvider):
}
async with ClientSession(headers=headers) as session:
if not cls._nonce:
async with session.get(f"{cls.url}/", proxy=proxy) as response:
async with session.get(f"{cls.url}/",
proxy=proxy, cookies=cookies) as response:
response.raise_for_status()
response = await response.text()
result = re.search(r'data-post-id="([0-9]+)"', response)

@ -10,7 +10,7 @@ from .helper import format_prompt
class Cromicle(AsyncGeneratorProvider):
url: str = 'https://cromicle.top'
working: bool = True
working: bool = False
supports_gpt_35_turbo: bool = True
@classmethod

@ -1,29 +1,36 @@
# cloudflare block
from __future__ import annotations
from aiohttp import ClientSession
from ..typing import Messages
from .base_provider import AsyncProvider
from .helper import get_cookies
class GptChatly(AsyncProvider):
url = "https://gptchatly.com"
supports_gpt_35_turbo = True
supports_gpt_4 = True
working = True
working = False
@classmethod
async def create_async(
cls,
model: str,
messages: Messages,
proxy: str = None,
**kwargs
) -> str:
proxy: str = None, cookies: dict = None, **kwargs) -> str:
if not cookies:
cookies = get_cookies('gptchatly.com')
if model.startswith("gpt-4"):
chat_url = f"{cls.url}/fetch-gpt4-response"
else:
chat_url = f"{cls.url}/fetch-response"
headers = {
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/118.0",
"Accept": "*/*",

@ -1,3 +1,5 @@
# not using WS anymore
from __future__ import annotations
import json, uuid, hashlib, time, random
@ -19,7 +21,7 @@ models = {
class Myshell(AsyncGeneratorProvider):
url = "https://app.myshell.ai/chat"
working = True
working = False
supports_gpt_35_turbo = True
supports_gpt_4 = True
@ -172,4 +174,46 @@ def generate_visitor_id(user_agent: str) -> str:
r = hex(int(random.random() * (16**16)))[2:-2]
d = xor_hash(user_agent)
e = hex(1080 * 1920)[2:]
return f"{f}-{r}-{d}-{e}-{f}"
return f"{f}-{r}-{d}-{e}-{f}"
# update
# from g4f.requests import StreamSession
# async def main():
# headers = {
# 'authority': 'api.myshell.ai',
# 'accept': 'application/json',
# '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',
# 'content-type': 'application/json',
# 'myshell-service-name': 'organics-api',
# 'origin': 'https://app.myshell.ai',
# 'referer': 'https://app.myshell.ai/',
# 'sec-ch-ua': '"Chromium";v="118", "Google Chrome";v="118", "Not=A?Brand";v="99"',
# 'sec-ch-ua-mobile': '?0',
# 'sec-ch-ua-platform': '"macOS"',
# 'sec-fetch-dest': 'empty',
# 'sec-fetch-mode': 'cors',
# 'sec-fetch-site': 'same-site',
# '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',
# 'visitor-id': '18ae8fe5d916d3-0213f29594b17f-18525634-157188-18ae8fe5d916d3',
# }
# json_data = {
# 'conversation_scenario': 3,
# 'botId': '4738',
# 'message': 'hi',
# 'messageType': 1,
# }
# async with StreamSession(headers=headers, impersonate="chrome110") as session:
# async with session.post(f'https://api.myshell.ai/v1/bot/chat/send_message',
# json=json_data) as response:
# response.raise_for_status()
# async for chunk in response.iter_content():
# print(chunk.decode("utf-8"))
# import asyncio
# asyncio.run(main())

@ -8,7 +8,7 @@ from ..typing import AsyncResult, Messages
class Ylokh(AsyncGeneratorProvider):
url = "https://chat.ylokh.xyz"
working = True
working = False
supports_gpt_35_turbo = True

Loading…
Cancel
Save