XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 1
返回提交历史

XFEstudio/gpt4free

refactor(g4f/Provider/Bixin123.py): remove Bixin123 provider

410b46d3
kqlio67 <kqlio67@users.noreply.github.com>
提交于

代码差异

1 个文件 +0 -94
Deleted g4f/Provider/Bixin123.py +0 -94
@@ -1,94 +0,0 @@
1 from __future__ import annotations
2
3 from aiohttp import ClientSession
4 import json
5 import random
6 from .base_provider import AsyncGeneratorProvider, ProviderModelMixin
7 from ..typing import AsyncResult, Messages
8 from .helper import format_prompt
9
10 class Bixin123(AsyncGeneratorProvider, ProviderModelMixin):
11 url = "https://chat.bixin123.com"
12 api_endpoint = "https://chat.bixin123.com/api/chatgpt/chat-process"
13 working = True
14 supports_gpt_35_turbo = True
15 supports_gpt_4 = True
16
17 default_model = 'gpt-3.5-turbo-0125'
18 models = ['gpt-3.5-turbo', 'gpt-3.5-turbo-0125', 'gpt-3.5-turbo-16k-0613', 'gpt-4-turbo', 'qwen-turbo']
19
20 model_aliases = {
21 "gpt-3.5-turbo": "gpt-3.5-turbo-0125",
22 "gpt-3.5-turbo": "gpt-3.5-turbo-16k-0613",
23 }
24
25 @classmethod
26 def get_model(cls, model: str) -> str:
27 if model in cls.models:
28 return model
29 elif model in cls.model_aliases:
30 return cls.model_aliases[model]
31 else:
32 return cls.default_model
33
34 @classmethod
35 def generate_fingerprint(cls) -> str:
36 return str(random.randint(100000000, 999999999))
37
38 @classmethod
39 async def create_async_generator(
40 cls,
41 model: str,
42 messages: Messages,
43 proxy: str = None,
44 **kwargs
45 ) -> AsyncResult:
46 model = cls.get_model(model)
47
48 headers = {
49 "accept": "application/json, text/plain, */*",
50 "accept-language": "en-US,en;q=0.9",
51 "cache-control": "no-cache",
52 "content-type": "application/json",
53 "fingerprint": cls.generate_fingerprint(),
54 "origin": cls.url,
55 "pragma": "no-cache",
56 "priority": "u=1, i",
57 "referer": f"{cls.url}/chat",
58 "sec-ch-ua": '"Chromium";v="127", "Not)A;Brand";v="99"',
59 "sec-ch-ua-mobile": "?0",
60 "sec-ch-ua-platform": '"Linux"',
61 "sec-fetch-dest": "empty",
62 "sec-fetch-mode": "cors",
63 "sec-fetch-site": "same-origin",
64 "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36",
65 "x-website-domain": "chat.bixin123.com",
66 }
67
68 async with ClientSession(headers=headers) as session:
69 prompt = format_prompt(messages)
70 data = {
71 "prompt": prompt,
72 "options": {
73 "usingNetwork": False,
74 "file": ""
75 }
76 }
77 async with session.post(cls.api_endpoint, json=data, proxy=proxy) as response:
78 response.raise_for_status()
79 response_text = await response.text()
80
81 lines = response_text.strip().split("\n")
82 last_json = None
83 for line in reversed(lines):
84 try:
85 last_json = json.loads(line)
86 break
87 except json.JSONDecodeError:
88 pass
89
90 if last_json:
91 text = last_json.get("text", "")
92 yield text
93 else:
94 yield ""