diff options
author | Tekky <98614666+xtekky@users.noreply.github.com> | 2023-08-20 05:49:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-20 05:49:53 +0200 |
commit | f55b24a9145d46ed207c120f27212af244223c13 (patch) | |
tree | 4ab04db3724741f1bb7688883fbb4dd9e1385f9a /g4f/Provider/V50.py | |
parent | ~ | Merge pull request #808 (diff) | |
parent | provider to Provider in testing (diff) | |
download | gpt4free-f55b24a9145d46ed207c120f27212af244223c13.tar gpt4free-f55b24a9145d46ed207c120f27212af244223c13.tar.gz gpt4free-f55b24a9145d46ed207c120f27212af244223c13.tar.bz2 gpt4free-f55b24a9145d46ed207c120f27212af244223c13.tar.lz gpt4free-f55b24a9145d46ed207c120f27212af244223c13.tar.xz gpt4free-f55b24a9145d46ed207c120f27212af244223c13.tar.zst gpt4free-f55b24a9145d46ed207c120f27212af244223c13.zip |
Diffstat (limited to 'g4f/Provider/V50.py')
-rw-r--r-- | g4f/Provider/V50.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/g4f/Provider/V50.py b/g4f/Provider/V50.py new file mode 100644 index 00000000..125dd7c5 --- /dev/null +++ b/g4f/Provider/V50.py @@ -0,0 +1,62 @@ +import uuid, requests +from ..typing import Any, CreateResult +from .base_provider import BaseProvider + + +class V50(BaseProvider): + url = 'https://p5.v50.ltd' + supports_gpt_35_turbo = True + supports_stream = False + needs_auth = False + working = True + + @staticmethod + def create_completion( + model: str, + messages: list[dict[str, str]], + stream: bool, + **kwargs: Any, + ) -> CreateResult: + conversation = '' + for message in messages: + conversation += '%s: %s\n' % (message['role'], message['content']) + + conversation += 'assistant: ' + payload = { + "prompt": conversation, + "options": {}, + "systemMessage": ".", + "temperature": kwargs.get("temperature", 0.4), + "top_p": kwargs.get("top_p", 0.4), + "model": model, + "user": str(uuid.uuid4()) + } + headers = { + 'authority': 'p5.v50.ltd', + 'accept': 'application/json, text/plain, */*', + 'accept-language': 'id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7', + 'content-type': 'application/json', + 'origin': 'https://p5.v50.ltd', + 'referer': 'https://p5.v50.ltd/', + 'sec-ch-ua-platform': '"Windows"', + 'sec-fetch-dest': 'empty', + 'sec-fetch-mode': 'cors', + 'sec-fetch-site': 'same-origin', + 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36' + } + response = requests.post("https://p5.v50.ltd/api/chat-process", + json=payload, headers=headers, proxies=kwargs['proxy'] if 'proxy' in kwargs else {}) + yield response.text + + @classmethod + @property + def params(cls): + params = [ + ("model", "str"), + ("messages", "list[dict[str, str]]"), + ("stream", "bool"), + ("temperature", "float"), + ("top_p", "int"), + ] + param = ", ".join([": ".join(p) for p in params]) + return f"g4f.provider.{cls.__name__} supports: ({param})"
\ No newline at end of file |