返回提交历史
Added
g4f/Provider/needs_auth/VoiGpt.py
+79
-0
Modified
g4f/Provider/needs_auth/__init__.py
+2
-1
Modified
g4f/models.py
+4
-0
XFEstudio/gpt4free
Added a new provider voigpt.com (#1328)
* added the new VoiGpt provider * fixed the voigpt and moved it to needs_auth * added auth detail and doc to voiGpt provider
983d17cb
代码差异
3 个文件
+85
-1
@@ -0,0 +1,79 @@
1
from __future__ import annotations
2
3
import json
4
import requests
5
from ..base_provider import BaseProvider
6
from ...typing import Messages, CreateResult
7
from ..helper import get_cookies
8
9
10
11
class VoiGpt(BaseProvider):
12
"""
13
VoiGpt - A provider for VoiGpt.com
14
15
**Note** : to use this provider you have to get your csrf token/cookie from the voigpt.com website
16
17
Args:
18
model: The model to use
19
messages: The messages to send
20
stream: Whether to stream the response
21
proxy: The proxy to use
22
access_token: The access token to use
23
**kwargs: Additional keyword arguments
24
25
Returns:
26
A CreateResult object
27
"""
28
url = "https://voigpt.com"
29
working = True
30
supports_gpt_35_turbo = True
31
supports_message_history = True
32
supports_stream = False
33
needs_auth = True
34
_access_token: str = None
35
36
@classmethod
37
def create_completion(
38
cls,
39
model: str,
40
messages: Messages,
41
stream: bool,
42
proxy: str = None,
43
access_token: str = None,
44
**kwargs
45
) -> CreateResult:
46
47
if not model:
48
model = "gpt-3.5-turbo"
49
if not access_token:
50
access_token = cls._access_token
51
52
headers = {
53
"Accept-Encoding": "gzip, deflate, br",
54
"Accept-Language": "en-IN,en-GB;q=0.9,en-US;q=0.8,en;q=0.7,hi;q=0.6",
55
"Content-Type": "application/json",
56
"Cookie": f"csrftoken={access_token};",
57
"Host": "voigpt.com",
58
"Origin": "https://voigpt.com",
59
"Referer": "https://voigpt.com/",
60
"Sec-Ch-Ua": "'Google Chrome';v='119', 'Chromium';v='119', 'Not?A_Brand';v='24'",
61
"Sec-Ch-Ua-Mobile": "?0",
62
"Sec-Ch-Ua-Platform": "'Windows'",
63
"Sec-Fetch-Dest": "empty",
64
"Sec-Fetch-Mode": "cors",
65
"Sec-Fetch-Site": "same-origin",
66
"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",
67
"X-Csrftoken": f"{access_token}",
68
}
69
70
payload = {
71
"messages": messages,
72
}
73
74
request_url = cls.url + "/generate_response/"
75
req_response = requests.post(request_url, headers=headers, json=payload)
76
77
response = json.loads(req_response.text)
78
return response["response"]
79
@@ -5,4 +5,5 @@ from .ThebApi import ThebApi
5
5
from .HuggingChat import HuggingChat
6
6
from .OpenaiChat import OpenaiChat
7
7
from .OpenAssistant import OpenAssistant
8
from .Poe import Poe
8
from .Poe import Poe
9
from .VoiGpt import VoiGpt
@@ -28,6 +28,7 @@ from .Provider import (
28
28
You,
29
29
H2o,
30
30
Pi,
31
VoiGpt,
31
32
)
32
33
33
34
@dataclass(unsafe_hash=True)
@@ -49,6 +50,7 @@ default = Model(
49
50
You,
50
51
Chatgpt4Online,
51
52
ChatAnywhere,
53
VoiGpt
52
54
])
53
55
)
54
56
@@ -65,6 +67,7 @@ gpt_35_long = Model(
65
67
ChatgptDemoAi,
66
68
OnlineGpt,
67
69
ChatgptNext,
70
VoiGpt
68
71
])
69
72
)
70
73
@@ -77,6 +80,7 @@ gpt_35_turbo = Model(
77
80
GptForLove, ChatBase,
78
81
Chatgpt4Online,
79
82
ChatAnywhere,
83
VoiGpt,
80
84
])
81
85
)
82
86