diff options
author | Meshwa428 <135232056+Meshwa428@users.noreply.github.com> | 2023-12-10 23:22:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-10 23:22:58 +0100 |
commit | 983d17cb7bafce93973cfe8c3f3c34532ef6815d (patch) | |
tree | d89d41286e2c72d073e18ca0684b8f6654ac0cb9 /g4f/Provider | |
parent | Fix llama2 provider, Update TOC in readme (#1325) (diff) | |
download | gpt4free-983d17cb7bafce93973cfe8c3f3c34532ef6815d.tar gpt4free-983d17cb7bafce93973cfe8c3f3c34532ef6815d.tar.gz gpt4free-983d17cb7bafce93973cfe8c3f3c34532ef6815d.tar.bz2 gpt4free-983d17cb7bafce93973cfe8c3f3c34532ef6815d.tar.lz gpt4free-983d17cb7bafce93973cfe8c3f3c34532ef6815d.tar.xz gpt4free-983d17cb7bafce93973cfe8c3f3c34532ef6815d.tar.zst gpt4free-983d17cb7bafce93973cfe8c3f3c34532ef6815d.zip |
Diffstat (limited to 'g4f/Provider')
-rw-r--r-- | g4f/Provider/needs_auth/VoiGpt.py | 79 | ||||
-rw-r--r-- | g4f/Provider/needs_auth/__init__.py | 3 |
2 files changed, 81 insertions, 1 deletions
diff --git a/g4f/Provider/needs_auth/VoiGpt.py b/g4f/Provider/needs_auth/VoiGpt.py new file mode 100644 index 00000000..a7443293 --- /dev/null +++ b/g4f/Provider/needs_auth/VoiGpt.py @@ -0,0 +1,79 @@ +from __future__ import annotations
+
+import json
+import requests
+from ..base_provider import BaseProvider
+from ...typing import Messages, CreateResult
+from ..helper import get_cookies
+
+
+
+class VoiGpt(BaseProvider):
+ """
+ VoiGpt - A provider for VoiGpt.com
+
+ **Note** : to use this provider you have to get your csrf token/cookie from the voigpt.com website
+
+ Args:
+ model: The model to use
+ messages: The messages to send
+ stream: Whether to stream the response
+ proxy: The proxy to use
+ access_token: The access token to use
+ **kwargs: Additional keyword arguments
+
+ Returns:
+ A CreateResult object
+ """
+ url = "https://voigpt.com"
+ working = True
+ supports_gpt_35_turbo = True
+ supports_message_history = True
+ supports_stream = False
+ needs_auth = True
+ _access_token: str = None
+
+ @classmethod
+ def create_completion(
+ cls,
+ model: str,
+ messages: Messages,
+ stream: bool,
+ proxy: str = None,
+ access_token: str = None,
+ **kwargs
+ ) -> CreateResult:
+
+ if not model:
+ model = "gpt-3.5-turbo"
+ if not access_token:
+ access_token = cls._access_token
+
+ headers = {
+ "Accept-Encoding": "gzip, deflate, br",
+ "Accept-Language": "en-IN,en-GB;q=0.9,en-US;q=0.8,en;q=0.7,hi;q=0.6",
+ "Content-Type": "application/json",
+ "Cookie": f"csrftoken={access_token};",
+ "Host": "voigpt.com",
+ "Origin": "https://voigpt.com",
+ "Referer": "https://voigpt.com/",
+ "Sec-Ch-Ua": "'Google Chrome';v='119', 'Chromium';v='119', 'Not?A_Brand';v='24'",
+ "Sec-Ch-Ua-Mobile": "?0",
+ "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/119.0.0.0 Safari/537.36",
+ "X-Csrftoken": f"{access_token}",
+ }
+
+ payload = {
+ "messages": messages,
+ }
+
+ request_url = cls.url + "/generate_response/"
+ req_response = requests.post(request_url, headers=headers, json=payload)
+
+ response = json.loads(req_response.text)
+ return response["response"]
+
diff --git a/g4f/Provider/needs_auth/__init__.py b/g4f/Provider/needs_auth/__init__.py index b85cd36a..e80b0f74 100644 --- a/g4f/Provider/needs_auth/__init__.py +++ b/g4f/Provider/needs_auth/__init__.py @@ -5,4 +5,5 @@ from .ThebApi import ThebApi from .HuggingChat import HuggingChat from .OpenaiChat import OpenaiChat from .OpenAssistant import OpenAssistant -from .Poe import Poe
\ No newline at end of file +from .Poe import Poe +from .VoiGpt import VoiGpt
\ No newline at end of file |