返回提交历史
Added
g4f/Provider/Pizzagpt.py
+51
-0
Modified
g4f/Provider/__init__.py
+1
-0
XFEstudio/gpt4free
Add Pizzagpt Provider
43bf07ea
代码差异
2 个文件
+52
-0
@@ -0,0 +1,51 @@
1
import json
2
from aiohttp import ClientSession
3
4
from ..typing import Messages, AsyncResult
5
from .base_provider import AsyncGeneratorProvider
6
7
class Pizzagpt(AsyncGeneratorProvider):
8
url = "https://www.pizzagpt.it"
9
api_endpoint = "/api/chatx-completion"
10
supports_message_history = False
11
supports_gpt_35_turbo = False
12
working = True
13
14
@classmethod
15
async def create_async_generator(
16
cls,
17
model: str,
18
messages: Messages,
19
proxy: str = None,
20
**kwargs
21
) -> AsyncResult:
22
payload = {
23
"question": messages[-1]["content"]
24
}
25
headers = {
26
"Accept": "application/json",
27
"Accept-Encoding": "gzip, deflate, br, zstd",
28
"Accept-Language": "en-US,en;q=0.9",
29
"Content-Type": "application/json",
30
"Origin": cls.url,
31
"Referer": f"{cls.url}/en",
32
"Sec-Ch-Ua": "\"Not/A)Brand\";v=\"8\", \"Chromium\";v=\"126\", \"Google Chrome\";v=\"126\"",
33
"Sec-Ch-Ua-Mobile": "?0",
34
"Sec-Ch-Ua-Platform": "\"Windows\"",
35
"Sec-Fetch-Dest": "empty",
36
"Sec-Fetch-Mode": "cors",
37
"Sec-Fetch-Site": "same-origin",
38
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
39
"X-Secret": "Marinara"
40
}
41
42
async with ClientSession() as session:
43
async with session.post(
44
f"{cls.url}{cls.api_endpoint}",
45
json=payload,
46
proxy=proxy,
47
headers=headers
48
) as response:
49
response.raise_for_status()
50
response_json = await response.json()
51
yield response_json["answer"]["content"]
@@ -44,6 +44,7 @@ from .MetaAIAccount import MetaAIAccount
44
44
from .Ollama import Ollama
45
45
from .PerplexityLabs import PerplexityLabs
46
46
from .Pi import Pi
47
from .Pizzagpt import Pizzagpt
47
48
from .Replicate import Replicate
48
49
from .ReplicateImage import ReplicateImage
49
50
from .Vercel import Vercel