V50.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. from __future__ import annotations
  2. import uuid
  3. import requests
  4. from ...typing import Any, CreateResult
  5. from ..base_provider import BaseProvider
  6. class V50(BaseProvider):
  7. url = 'https://p5.v50.ltd'
  8. supports_gpt_35_turbo = True
  9. supports_stream = False
  10. needs_auth = False
  11. working = False
  12. @staticmethod
  13. def create_completion(
  14. model: str,
  15. messages: list[dict[str, str]],
  16. stream: bool, **kwargs: Any) -> CreateResult:
  17. conversation = (
  18. "\n".join(
  19. f"{message['role']}: {message['content']}" for message in messages
  20. )
  21. + "\nassistant: "
  22. )
  23. payload = {
  24. "prompt" : conversation,
  25. "options" : {},
  26. "systemMessage" : ".",
  27. "temperature" : kwargs.get("temperature", 0.4),
  28. "top_p" : kwargs.get("top_p", 0.4),
  29. "model" : model,
  30. "user" : str(uuid.uuid4())
  31. }
  32. headers = {
  33. 'authority' : 'p5.v50.ltd',
  34. 'accept' : 'application/json, text/plain, */*',
  35. 'accept-language' : 'id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7',
  36. 'content-type' : 'application/json',
  37. 'origin' : 'https://p5.v50.ltd',
  38. 'referer' : 'https://p5.v50.ltd/',
  39. 'sec-ch-ua-platform': '"Windows"',
  40. 'sec-fetch-dest' : 'empty',
  41. 'sec-fetch-mode' : 'cors',
  42. 'sec-fetch-site' : 'same-origin',
  43. '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'
  44. }
  45. response = requests.post(
  46. "https://p5.v50.ltd/api/chat-process",
  47. json=payload,
  48. headers=headers,
  49. proxies=kwargs.get('proxy', {}),
  50. )
  51. if "https://fk1.v50.ltd" not in response.text:
  52. yield response.text