返回提交历史
Deleted
g4f/Provider/Cnote.py
+0
-58
XFEstudio/gpt4free
Delete g4f/Provider/Cnote.py
f140d4a3
代码差异
1 个文件
+0
-58
@@ -1,58 +0,0 @@
1
from __future__ import annotations
2
3
import json
4
from aiohttp import ClientSession
5
6
from ..typing import AsyncResult, Messages
7
from .base_provider import AsyncGeneratorProvider
8
from .helper import format_prompt
9
10
11
class Cnote(AsyncGeneratorProvider):
12
url = "https://f1.cnote.top"
13
api_url = "https://p1api.xjai.pro/freeapi/chat-process"
14
working = True
15
supports_gpt_35_turbo = True
16
17
@classmethod
18
async def create_async_generator(
19
cls,
20
model: str,
21
messages: Messages,
22
proxy: str = None,
23
**kwargs
24
) -> AsyncResult:
25
headers = {
26
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36",
27
"Accept": "application/json, text/plain, */*",
28
"Accept-Language": "en-US,en;q=0.5",
29
"Accept-Encoding": "gzip, deflate, br",
30
"Content-Type": "application/json",
31
"Origin": cls.url,
32
"DNT": "1",
33
"Sec-GPC": "1",
34
"Connection": "keep-alive",
35
"Sec-Fetch-Dest": "empty",
36
"Sec-Fetch-Mode": "cors",
37
"Sec-Fetch-Site": "cross-site",
38
"TE": "trailers",
39
}
40
async with ClientSession(headers=headers) as session:
41
prompt = format_prompt(messages)
42
system_message: str = "",
43
data = {
44
"prompt": prompt,
45
"systemMessage": system_message,
46
"temperature": 0.8,
47
"top_p": 1,
48
}
49
async with session.post(cls.api_url, json=data, proxy=proxy) as response:
50
response.raise_for_status()
51
async for chunk in response.content:
52
if chunk:
53
try:
54
data = json.loads(chunk.decode().split("&KFw6loC9Qvy&")[-1])
55
text = data.get("text", "")
56
yield text
57
except (json.JSONDecodeError, IndexError):
58
pass