diff options
author | kqlio67 <kqlio67@users.noreply.github.com> | 2024-09-24 12:23:53 +0200 |
---|---|---|
committer | kqlio67 <kqlio67@users.noreply.github.com> | 2024-09-24 12:23:53 +0200 |
commit | f8e403a745c5caff31d7edb854dcba40eba3166d (patch) | |
tree | a75c6030a8054c56201fa2d41306a51b9052545c /g4f/Provider/GptTalkRu.py | |
parent | Added gpt-4o provider (diff) | |
download | gpt4free-f8e403a745c5caff31d7edb854dcba40eba3166d.tar gpt4free-f8e403a745c5caff31d7edb854dcba40eba3166d.tar.gz gpt4free-f8e403a745c5caff31d7edb854dcba40eba3166d.tar.bz2 gpt4free-f8e403a745c5caff31d7edb854dcba40eba3166d.tar.lz gpt4free-f8e403a745c5caff31d7edb854dcba40eba3166d.tar.xz gpt4free-f8e403a745c5caff31d7edb854dcba40eba3166d.tar.zst gpt4free-f8e403a745c5caff31d7edb854dcba40eba3166d.zip |
Diffstat (limited to 'g4f/Provider/GptTalkRu.py')
-rw-r--r-- | g4f/Provider/GptTalkRu.py | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/g4f/Provider/GptTalkRu.py b/g4f/Provider/GptTalkRu.py deleted file mode 100644 index 6a59484f..00000000 --- a/g4f/Provider/GptTalkRu.py +++ /dev/null @@ -1,59 +0,0 @@ -from __future__ import annotations - -from aiohttp import ClientSession, BaseConnector - -from ..typing import AsyncResult, Messages -from .base_provider import AsyncGeneratorProvider -from .helper import get_random_string, get_connector -from ..requests import raise_for_status, get_args_from_browser, WebDriver -from ..webdriver import has_seleniumwire -from ..errors import MissingRequirementsError - -class GptTalkRu(AsyncGeneratorProvider): - url = "https://gpttalk.ru" - working = True - supports_gpt_35_turbo = True - - @classmethod - async def create_async_generator( - cls, - model: str, - messages: Messages, - proxy: str = None, - connector: BaseConnector = None, - webdriver: WebDriver = None, - **kwargs - ) -> AsyncResult: - if not model: - model = "gpt-3.5-turbo" - if not has_seleniumwire: - raise MissingRequirementsError('Install "selenium-wire" package') - args = get_args_from_browser(f"{cls.url}", webdriver) - args["headers"]["accept"] = "application/json, text/plain, */*" - async with ClientSession(connector=get_connector(connector, proxy), **args) as session: - async with session.get("https://gpttalk.ru/getToken") as response: - await raise_for_status(response) - public_key = (await response.json())["response"]["key"]["publicKey"] - random_string = get_random_string(8) - data = { - "model": model, - "modelType": 1, - "prompt": messages, - "responseType": "stream", - "security": { - "randomMessage": random_string, - "shifrText": encrypt(public_key, random_string) - } - } - async with session.post(f"{cls.url}/gpt2", json=data, proxy=proxy) as response: - await raise_for_status(response) - async for chunk in response.content.iter_any(): - yield chunk.decode(errors="ignore") - -def encrypt(public_key: str, value: str) -> str: - from Crypto.Cipher import PKCS1_v1_5 - from Crypto.PublicKey import RSA - import base64 - rsa_key = RSA.importKey(public_key) - cipher = PKCS1_v1_5.new(rsa_key) - return base64.b64encode(cipher.encrypt(value.encode())).decode()
\ No newline at end of file |