binary-husky / gpt_academic

为GPT/GLM等LLM大语言模型提供实用化交互接口,特别优化论文阅读/润色/写作体验,模块化设计,支持自定义快捷按钮&函数插件,支持Python和C++等项目剖析&自译解功能,PDF/LaTex论文翻译&总结功能,支持并行问询多种LLM模型,支持chatglm3等本地模型。接入通义千问, deepseekcoder, 讯飞星火, 文心一言, llama2, rwkv, claude2, moss等。
https://github.com/binary-husky/gpt_academic/wiki/online
GNU General Public License v3.0
63.51k stars 7.87k forks source link

config.py 重新定向无效 API_URL_REDIRECT设置 #723

Closed zhoumaochao closed 7 months ago

zhoumaochao commented 1 year ago

Installation Method | 安装方法与平台

Pip Install (I used latest requirements.txt and python>=3.8)

Describe the bug & Screen Shot | 简述 与 有帮助的截图

config.py 配置

API_KEY = "sk-my key"

USE_PROXY = False if USE_PROXY:

proxies = {
    "http":  "socks5h://localhost:11284",  # 再例如  "http":  "http://127.0.0.1:7890",
    "https": "socks5h://localhost:11284",  # 再例如  "https": "http://127.0.0.1:7890",
}

else: proxies = None

API_URL_REDIRECT = {"https://api.openai.com/v1/chat/completions": "https://my_domain/v1/chat/completions"}

https://my_domain/v1/chat/completions返回:{ "error": { "message": "You didn't provide an API key. You need to provide your API key in an Authorization header using Bearer auth (i.e. Authorization: Bearer YOUR_KEY), or as the password field (with blank username) if you're accessing the API from your browser and are prompted for a username and password. You can obtain an API key from https://platform.openai.com/account/api-keys.", "type": "invalid_request_error", "param": null, "code": null } }

Terminal Traceback & Material to Help Reproduce Bugs | 终端traceback(如有) + 帮助我们复现的测试材料样本(如有)

To create a public link, set share=True in launch(). gpt-3.5-turbo : 0 : hello .......... Traceback (most recent call last): File "D:\Python安装\Lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen httplib_response = self._make_request( ^^^^^^^^^^^^^^^^^^^ File "D:\Python安装\Lib\site-packages\urllib3\connectionpool.py", line 386, in _make_request self._validate_conn(conn) File "D:\Python安装\Lib\site-packages\urllib3\connectionpool.py", line 1042, in _validate_conn conn.connect() File "D:\Python安装\Lib\site-packages\urllib3\connection.py", line 419, in connect self.sock = ssl_wrapsocket( ^^^^^^^^^^^^^^^^ File "D:\Python安装\Lib\site-packages\urllib3\util\ssl.py", line 449, in ssl_wrap_socket ssl_sock = _ssl_wrap_socketimpl( ^^^^^^^^^^^^^^^^^^^^^^ File "D:\Python安装\Lib\site-packages\urllib3\util\ssl.py", line 493, in _ssl_wrap_socket_impl return ssl_context.wrap_socket(sock, server_hostname=server_hostname) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Python安装\Lib\ssl.py", line 517, in wrap_socket return self.sslsocket_class._create( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Python安装\Lib\ssl.py", line 1075, in _create self.do_handshake() File "D:\Python安装\Lib\ssl.py", line 1346, in do_handshake self._sslobj.do_handshake() ConnectionResetError: [WinError 10054] 远程主机强迫关闭了一个现有的连接。

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "D:\Python安装\Lib\site-packages\requests\adapters.py", line 489, in send resp = conn.urlopen( ^^^^^^^^^^^^^ File "D:\Python安装\Lib\site-packages\urllib3\connectionpool.py", line 787, in urlopen retries = retries.increment( ^^^^^^^^^^^^^^^^^^ File "D:\Python安装\Lib\site-packages\urllib3\util\retry.py", line 550, in increment raise six.reraise(type(error), error, _stacktrace) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Python安装\Lib\site-packages\urllib3\packages\six.py", line 769, in reraise raise value.with_traceback(tb) File "D:\Python安装\Lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen httplib_response = self._make_request( ^^^^^^^^^^^^^^^^^^^ File "D:\Python安装\Lib\site-packages\urllib3\connectionpool.py", line 386, in _make_request self._validate_conn(conn) File "D:\Python安装\Lib\site-packages\urllib3\connectionpool.py", line 1042, in _validate_conn conn.connect() File "D:\Python安装\Lib\site-packages\urllib3\connection.py", line 419, in connect self.sock = ssl_wrapsocket( ^^^^^^^^^^^^^^^^ File "D:\Python安装\Lib\site-packages\urllib3\util\ssl.py", line 449, in ssl_wrap_socket ssl_sock = _ssl_wrap_socketimpl( ^^^^^^^^^^^^^^^^^^^^^^ File "D:\Python安装\Lib\site-packages\urllib3\util\ssl.py", line 493, in _ssl_wrap_socket_impl return ssl_context.wrap_socket(sock, server_hostname=server_hostname) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Python安装\Lib\ssl.py", line 517, in wrap_socket return self.sslsocket_class._create( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Python安装\Lib\ssl.py", line 1075, in _create self.do_handshake() File "D:\Python安装\Lib\ssl.py", line 1346, in do_handshake self._sslobj.do_handshake() urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(10054, '远程主机强迫关闭了一个现有的连接。', None, 10054, None))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "D:\zhougpt\chatgpt_academic\免翻版academic gpt\gpt_academic\request_llm\bridge_chatgpt.py", line 156, in predict response = requests.post(endpoint, headers=headers, proxies=proxies, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Python安装\Lib\site-packages\requests\api.py", line 115, in post return request("post", url, data=data, json=json, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Python安装\Lib\site-packages\requests\api.py", line 59, in request return session.request(method=method, url=url, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Python安装\Lib\site-packages\requests\sessions.py", line 587, in request resp = self.send(prep, send_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Python安装\Lib\site-packages\gradio\utils.py", line 491, in async_iteration return next(iterator) ^^^^^^^^^^^^^^ File "D:\zhougpt\chatgpt_academic\免翻版academic gpt\gpt_academic\toolbox.py", line 62, in decorated yield from f(txt_passon, llm_kwargs, plugin_kwargs, chatbot_with_cookie, history, system_prompt, args) File "D:\zhougpt\chatgpt_academic\免翻版academic gpt\gpt_academic\request_llm\bridge_all.py", line 296, in predict yield from method(inputs, llm_kwargs, args, kwargs) File "D:\zhougpt\chatgpt_academic\免翻版academic gpt\gpt_academic\request_llm\bridge_chatgpt.py", line 163, in predict if retry > MAX_RETRY: raise TimeoutError ^^^^^^^^^^^^^^^^^^ TimeoutError

binary-husky commented 1 year ago

盲猜是因为API_KEY格式不对?

binary-husky commented 1 year ago

是Openai官方的API格式吗?sk-48位密钥那种?

zhoumaochao commented 1 year ago

问题解决了一半,换手机热点网络是可以的。但是WiFi反而不行,是不是CLash导致本地网络配置出现问题。

Eternal130 commented 1 year ago

2.7之前我使用url重定向是可以用的,中间有段时间没更新,更新到3.3之后url重定向就用不了了,也是这种问题,但api key没问题

Etleventt commented 7 months ago

是Openai官方的API格式吗?sk-48位密钥那种?

请问必须是这种格式吗?我使用了https://github.com/lvguanjun/copilot_to_chatgpt4 转换为的GPT4本地接口,api是token,ghu开头的,这种不支持嘛