mirror of
https://github.com/xtekky/gpt4free.git
synced 2024-11-19 03:25:32 +00:00
Disable Wewordle Provider
Update Ylokh Provider Improve StreamRequest
This commit is contained in:
parent
261fac86dc
commit
bb481a03ab
@ -8,7 +8,7 @@ from .base_provider import AsyncProvider
|
|||||||
|
|
||||||
class Wewordle(AsyncProvider):
|
class Wewordle(AsyncProvider):
|
||||||
url = "https://wewordle.org"
|
url = "https://wewordle.org"
|
||||||
working = True
|
working = False
|
||||||
supports_gpt_35_turbo = True
|
supports_gpt_35_turbo = True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from aiohttp import ClientSession
|
|
||||||
|
|
||||||
|
from ..requests import AsyncSession
|
||||||
from .base_provider import AsyncGeneratorProvider
|
from .base_provider import AsyncGeneratorProvider
|
||||||
from ..typing import AsyncGenerator
|
from ..typing import AsyncGenerator
|
||||||
|
|
||||||
@ -23,14 +23,8 @@ class Ylokh(AsyncGeneratorProvider):
|
|||||||
) -> AsyncGenerator:
|
) -> AsyncGenerator:
|
||||||
model = model if model else "gpt-3.5-turbo"
|
model = model if model else "gpt-3.5-turbo"
|
||||||
headers = {
|
headers = {
|
||||||
"User-Agent" : "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/116.0",
|
|
||||||
"Accept" : "*/*",
|
|
||||||
"Accept-language" : "de,en-US;q=0.7,en;q=0.3",
|
|
||||||
"Origin" : cls.url,
|
"Origin" : cls.url,
|
||||||
"Referer" : cls.url + "/",
|
"Referer" : cls.url + "/",
|
||||||
"Sec-Fetch-Dest" : "empty",
|
|
||||||
"Sec-Fetch-Mode" : "cors",
|
|
||||||
"Sec-Fetch-Site" : "same-origin",
|
|
||||||
}
|
}
|
||||||
data = {
|
data = {
|
||||||
"messages": messages,
|
"messages": messages,
|
||||||
@ -43,7 +37,7 @@ class Ylokh(AsyncGeneratorProvider):
|
|||||||
"stream": stream,
|
"stream": stream,
|
||||||
**kwargs
|
**kwargs
|
||||||
}
|
}
|
||||||
async with ClientSession(
|
async with AsyncSession(
|
||||||
headers=headers
|
headers=headers
|
||||||
) as session:
|
) as session:
|
||||||
async with session.post("https://chatapi.ylokh.xyz/v1/chat/completions", json=data, proxy=proxy) as response:
|
async with session.post("https://chatapi.ylokh.xyz/v1/chat/completions", json=data, proxy=proxy) as response:
|
||||||
|
@ -11,7 +11,7 @@ from curl_cffi.requests import Response
|
|||||||
from curl_cffi import AsyncCurl
|
from curl_cffi import AsyncCurl
|
||||||
|
|
||||||
is_newer_0_5_9 = hasattr(AsyncCurl, "remove_handle")
|
is_newer_0_5_9 = hasattr(AsyncCurl, "remove_handle")
|
||||||
|
is_newer_0_5_8 = hasattr(BaseSession, "_set_cookies")
|
||||||
|
|
||||||
class StreamResponse:
|
class StreamResponse:
|
||||||
def __init__(self, inner: Response, content: StreamReader, request):
|
def __init__(self, inner: Response, content: StreamReader, request):
|
||||||
@ -46,6 +46,10 @@ class StreamRequest:
|
|||||||
)
|
)
|
||||||
self.method = method
|
self.method = method
|
||||||
self.url = url
|
self.url = url
|
||||||
|
if "proxy" in kwargs:
|
||||||
|
proxy = kwargs.pop("proxy")
|
||||||
|
if proxy:
|
||||||
|
kwargs["proxies"] = {"http": proxy, "https": proxy}
|
||||||
self.options = kwargs
|
self.options = kwargs
|
||||||
|
|
||||||
def on_content(self, data):
|
def on_content(self, data):
|
||||||
@ -75,7 +79,7 @@ class StreamRequest:
|
|||||||
self.handle = self.session.acurl._curl2future[self.curl]
|
self.handle = self.session.acurl._curl2future[self.curl]
|
||||||
self.handle.add_done_callback(self.on_done)
|
self.handle.add_done_callback(self.on_done)
|
||||||
await self.enter
|
await self.enter
|
||||||
if is_newer_0_5_9:
|
if is_newer_0_5_8:
|
||||||
response = self.session._parse_response(self.curl, _, header_buffer)
|
response = self.session._parse_response(self.curl, _, header_buffer)
|
||||||
response.request = request
|
response.request = request
|
||||||
else:
|
else:
|
||||||
@ -91,7 +95,7 @@ class StreamRequest:
|
|||||||
self.session.acurl.set_result(self.curl)
|
self.session.acurl.set_result(self.curl)
|
||||||
self.curl.clean_after_perform()
|
self.curl.clean_after_perform()
|
||||||
self.curl.reset()
|
self.curl.reset()
|
||||||
self.session.push_curl(self.curl)
|
self.session.push_curl(self.curl)
|
||||||
|
|
||||||
class AsyncSession(BaseSession):
|
class AsyncSession(BaseSession):
|
||||||
def request(
|
def request(
|
||||||
|
@ -36,6 +36,7 @@ def get_providers() -> list[type[BaseProvider]]:
|
|||||||
provider_names = dir(Provider)
|
provider_names = dir(Provider)
|
||||||
ignore_names = [
|
ignore_names = [
|
||||||
"annotations",
|
"annotations",
|
||||||
|
"helper",
|
||||||
"base_provider",
|
"base_provider",
|
||||||
"retry_provider",
|
"retry_provider",
|
||||||
"BaseProvider",
|
"BaseProvider",
|
||||||
|
Loading…
Reference in New Issue
Block a user