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

XFEstudio/gpt4free

Pass missing DeepSeekAPI import

ce7e9b03
hlohaus <983577+hlohaus@users.noreply.github.com>
提交于

代码差异

1 个文件 +29 -29
Modified g4f/Provider/needs_auth/DeepSeekAPI.py +29 -29
@@ -14,37 +14,37 @@ from ...typing import AsyncResult, Messages
14 14 try:
15 15 from curl_cffi import requests
16 16 from dsk.api import DeepSeekAPI, AuthenticationError, DeepSeekPOW
17 except ImportError:
18 pass
19 17
20 class DeepSeekAPIArgs(DeepSeekAPI):
21 def __init__(self, args: dict):
22 args.pop("headers")
23 self.auth_token = args.pop("api_key")
24 if not self.auth_token or not isinstance(self.auth_token, str):
25 raise AuthenticationError("Invalid auth token provided")
26 self.args = args
27 self.pow_solver = DeepSeekPOW()
18 class DeepSeekAPIArgs(DeepSeekAPI):
19 def __init__(self, args: dict):
20 args.pop("headers")
21 self.auth_token = args.pop("api_key")
22 if not self.auth_token or not isinstance(self.auth_token, str):
23 raise AuthenticationError("Invalid auth token provided")
24 self.args = args
25 self.pow_solver = DeepSeekPOW()
28 26
29 def _make_request(self, method: str, endpoint: str, json_data: dict, pow_required: bool = False):
30 url = f"{self.BASE_URL}{endpoint}"
31 headers = self._get_headers()
32 if pow_required:
33 challenge = self._get_pow_challenge()
34 pow_response = self.pow_solver.solve_challenge(challenge)
35 headers = self._get_headers(pow_response)
36
37 response = requests.request(
38 method=method,
39 url=url,
40 json=json_data, **{
41 "headers":headers,
42 "impersonate":'chrome',
43 "timeout":None,
44 **self.args
45 }
46 )
47 return response.json()
27 def _make_request(self, method: str, endpoint: str, json_data: dict, pow_required: bool = False):
28 url = f"{self.BASE_URL}{endpoint}"
29 headers = self._get_headers()
30 if pow_required:
31 challenge = self._get_pow_challenge()
32 pow_response = self.pow_solver.solve_challenge(challenge)
33 headers = self._get_headers(pow_response)
34
35 response = requests.request(
36 method=method,
37 url=url,
38 json=json_data, **{
39 "headers":headers,
40 "impersonate":'chrome',
41 "timeout":None,
42 **self.args
43 }
44 )
45 return response.json()
46 except ImportError:
47 pass
48 48
49 49 class DeepSeekAPI(AsyncAuthedProvider):
50 50 url = "https://chat.deepseek.com"