gpt4free/g4f/Provider/deprecated/Wewordle.py

65 lines
2.4 KiB
Python
Raw Normal View History

from __future__ import annotations
2023-07-28 13:07:17 +03:00
import random, string, time
from aiohttp import ClientSession
2023-10-04 08:20:51 +03:00
from ..base_provider import AsyncProvider
2023-07-28 13:07:17 +03:00
class Wewordle(AsyncProvider):
url = "https://wewordle.org"
working = False
2023-08-27 18:37:44 +03:00
supports_gpt_35_turbo = True
2023-07-28 13:07:17 +03:00
2023-08-24 22:32:22 +03:00
@classmethod
async def create_async(
2023-08-24 22:32:22 +03:00
cls,
2023-07-28 13:07:17 +03:00
model: str,
messages: list[dict[str, str]],
proxy: str = None,
**kwargs
) -> str:
2023-08-27 18:37:44 +03:00
2023-07-28 13:07:17 +03:00
headers = {
2023-08-27 18:37:44 +03:00
"accept" : "*/*",
"pragma" : "no-cache",
"Content-Type" : "application/json",
"Connection" : "keep-alive"
2023-07-28 13:07:17 +03:00
}
_user_id = "".join(random.choices(f"{string.ascii_lowercase}{string.digits}", k=16))
_app_id = "".join(random.choices(f"{string.ascii_lowercase}{string.digits}", k=31))
_request_date = time.strftime("%Y-%m-%dT%H:%M:%S.000Z", time.gmtime())
data = {
2023-08-27 18:37:44 +03:00
"user" : _user_id,
"messages" : messages,
2023-07-28 13:07:17 +03:00
"subscriber": {
2023-08-27 18:37:44 +03:00
"originalPurchaseDate" : None,
"originalApplicationVersion" : None,
"allPurchaseDatesMillis" : {},
"entitlements" : {"active": {}, "all": {}},
"allPurchaseDates" : {},
"allExpirationDatesMillis" : {},
"allExpirationDates" : {},
"originalAppUserId" : f"$RCAnonymousID:{_app_id}",
"latestExpirationDate" : None,
"requestDate" : _request_date,
"latestExpirationDateMillis" : None,
"nonSubscriptionTransactions" : [],
"originalPurchaseDateMillis" : None,
"managementURL" : None,
2023-07-28 13:07:17 +03:00
"allPurchasedProductIdentifiers": [],
2023-08-27 18:37:44 +03:00
"firstSeen" : _request_date,
"activeSubscriptions" : [],
}
2023-07-28 13:07:17 +03:00
}
async with ClientSession(
headers=headers
) as session:
async with session.post(f"{cls.url}/gptapi/v1/android/turbo", proxy=proxy, json=data) as response:
response.raise_for_status()
content = (await response.json())["message"]["content"]
if content:
return content