summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/V50.py
diff options
context:
space:
mode:
authorBagus Indrayana <bagusindrayanaindo@gmail.com>2023-08-17 15:42:00 +0200
committerBagus Indrayana <bagusindrayanaindo@gmail.com>2023-08-17 15:42:00 +0200
commit64e8381c32b8dd9517f5f83d6535471c77c67e17 (patch)
tree9cbdb062f15c3b2360c4d8c2b7b742c434db1a75 /g4f/Provider/V50.py
parentmerge and refactor (diff)
downloadgpt4free-64e8381c32b8dd9517f5f83d6535471c77c67e17.tar
gpt4free-64e8381c32b8dd9517f5f83d6535471c77c67e17.tar.gz
gpt4free-64e8381c32b8dd9517f5f83d6535471c77c67e17.tar.bz2
gpt4free-64e8381c32b8dd9517f5f83d6535471c77c67e17.tar.lz
gpt4free-64e8381c32b8dd9517f5f83d6535471c77c67e17.tar.xz
gpt4free-64e8381c32b8dd9517f5f83d6535471c77c67e17.tar.zst
gpt4free-64e8381c32b8dd9517f5f83d6535471c77c67e17.zip
Diffstat (limited to '')
-rw-r--r--g4f/Provider/V50.py101
1 files changed, 60 insertions, 41 deletions
diff --git a/g4f/Provider/V50.py b/g4f/Provider/V50.py
index 02ae18d6..125dd7c5 100644
--- a/g4f/Provider/V50.py
+++ b/g4f/Provider/V50.py
@@ -1,43 +1,62 @@
-import os, uuid, requests
-from ..typing import get_type_hints
-url = 'https://p5.v50.ltd'
-model = ['gpt-3.5-turbo','gpt-3.5-turbo-16k']
-supports_stream = False
-needs_auth = False
-working = True
+import uuid, requests
+from ..typing import Any, CreateResult
+from .base_provider import BaseProvider
-def _create_completion(model: str, messages: list, stream: bool, temperature: float = 0.7, **kwargs):
- conversation = ''
- for message in messages:
- conversation += '%s: %s\n' % (message['role'], message['content'])
-
- conversation += 'assistant: '
- payload = {
- "prompt": conversation,
- "options": {},
- "systemMessage": ".",
- "temperature": temperature,
- "top_p": 1,
- "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
-
-params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
- '(%s)' % ', '.join([f"{name}: {get_type_hints(_create_completion)[name].__name__}" for name in _create_completion.__code__.co_varnames[:_create_completion.__code__.co_argcount]]) \ No newline at end of file
+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