2023-08-27 18:37:44 +03:00
|
|
|
import json, random, string, time, requests
|
2023-07-28 13:07:17 +03:00
|
|
|
|
2023-08-27 18:37:44 +03:00
|
|
|
from ..typing import Any, CreateResult
|
2023-07-28 13:07:17 +03:00
|
|
|
from .base_provider import BaseProvider
|
|
|
|
|
|
|
|
|
|
|
|
class Wewordle(BaseProvider):
|
2023-08-27 18:37:44 +03:00
|
|
|
url = "https://wewordle.org/"
|
|
|
|
working = True
|
|
|
|
supports_gpt_35_turbo = True
|
2023-07-28 13:07:17 +03:00
|
|
|
|
2023-08-24 22:32:22 +03:00
|
|
|
@classmethod
|
2023-07-28 13:07:17 +03:00
|
|
|
def create_completion(
|
2023-08-24 22:32:22 +03:00
|
|
|
cls,
|
2023-07-28 13:07:17 +03:00
|
|
|
model: str,
|
|
|
|
messages: list[dict[str, str]],
|
2023-08-27 18:37:44 +03:00
|
|
|
stream: bool, **kwargs: Any) -> CreateResult:
|
|
|
|
|
2023-07-28 13:07:17 +03:00
|
|
|
# randomize user id and app id
|
|
|
|
_user_id = "".join(
|
2023-08-27 18:37:44 +03:00
|
|
|
random.choices(f"{string.ascii_lowercase}{string.digits}", k=16))
|
|
|
|
|
2023-07-28 13:07:17 +03:00
|
|
|
_app_id = "".join(
|
2023-08-27 18:37:44 +03:00
|
|
|
random.choices(f"{string.ascii_lowercase}{string.digits}", k=31))
|
|
|
|
|
2023-07-28 13:07:17 +03:00
|
|
|
# make current date with format utc
|
|
|
|
_request_date = time.strftime("%Y-%m-%dT%H:%M:%S.000Z", time.gmtime())
|
|
|
|
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 agent android client
|
|
|
|
# 'User-Agent': 'Dalvik/2.1.0 (Linux; U; Android 10; SM-G975F Build/QP1A.190711.020)',
|
|
|
|
}
|
2023-08-27 18:37:44 +03:00
|
|
|
|
2023-07-28 13:07:17 +03:00
|
|
|
data: dict[str, Any] = {
|
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
|
|
|
}
|
|
|
|
|
2023-08-27 18:37:44 +03:00
|
|
|
response = requests.post(f"{cls.url}gptapi/v1/android/turbo",
|
|
|
|
headers=headers, data=json.dumps(data))
|
|
|
|
|
2023-07-28 13:07:17 +03:00
|
|
|
response.raise_for_status()
|
|
|
|
_json = response.json()
|
|
|
|
if "message" in _json:
|
|
|
|
yield _json["message"]["content"]
|