2023-09-03 08:26:26 +00:00
|
|
|
from __future__ import annotations
|
2023-08-17 13:09:35 +00:00
|
|
|
|
2023-09-03 08:26:26 +00:00
|
|
|
import uuid
|
|
|
|
|
|
|
|
import requests
|
|
|
|
|
2023-10-04 05:20:51 +00:00
|
|
|
from ...typing import Any, CreateResult
|
2024-01-01 16:48:57 +00:00
|
|
|
from ..base_provider import AbstractProvider
|
2023-08-17 13:09:35 +00:00
|
|
|
|
2023-09-03 08:26:26 +00:00
|
|
|
|
2024-01-01 16:48:57 +00:00
|
|
|
class V50(AbstractProvider):
|
2023-08-27 15:37:44 +00:00
|
|
|
url = 'https://p5.v50.ltd'
|
|
|
|
supports_gpt_35_turbo = True
|
|
|
|
supports_stream = False
|
|
|
|
needs_auth = False
|
|
|
|
working = False
|
2023-08-17 13:42:00 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def create_completion(
|
|
|
|
model: str,
|
|
|
|
messages: list[dict[str, str]],
|
2023-08-27 15:37:44 +00:00
|
|
|
stream: bool, **kwargs: Any) -> CreateResult:
|
|
|
|
|
2023-10-23 07:46:25 +00:00
|
|
|
conversation = (
|
|
|
|
"\n".join(
|
|
|
|
f"{message['role']}: {message['content']}" for message in messages
|
|
|
|
)
|
|
|
|
+ "\nassistant: "
|
|
|
|
)
|
2023-08-17 13:42:00 +00:00
|
|
|
payload = {
|
2023-08-27 15:37:44 +00:00
|
|
|
"prompt" : conversation,
|
|
|
|
"options" : {},
|
|
|
|
"systemMessage" : ".",
|
|
|
|
"temperature" : kwargs.get("temperature", 0.4),
|
|
|
|
"top_p" : kwargs.get("top_p", 0.4),
|
|
|
|
"model" : model,
|
|
|
|
"user" : str(uuid.uuid4())
|
2023-08-17 13:42:00 +00:00
|
|
|
}
|
2023-10-23 07:46:25 +00:00
|
|
|
|
2023-08-17 13:42:00 +00:00
|
|
|
headers = {
|
2023-08-27 15:37:44 +00:00
|
|
|
'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/',
|
2023-08-17 13:42:00 +00:00
|
|
|
'sec-ch-ua-platform': '"Windows"',
|
2023-08-27 15:37:44 +00:00
|
|
|
'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'
|
2023-08-17 13:42:00 +00:00
|
|
|
}
|
2023-10-23 07:46:25 +00:00
|
|
|
response = requests.post(
|
|
|
|
"https://p5.v50.ltd/api/chat-process",
|
|
|
|
json=payload,
|
|
|
|
headers=headers,
|
|
|
|
proxies=kwargs.get('proxy', {}),
|
|
|
|
)
|
|
|
|
|
2023-08-22 21:27:34 +00:00
|
|
|
if "https://fk1.v50.ltd" not in response.text:
|
2023-11-20 12:59:14 +00:00
|
|
|
yield response.text
|