18870 / chatgpt-proxy

A ChatGPT unofficial API proxy written in Python.
GNU Affero General Public License v3.0
15 stars 4 forks source link

这个怎么用 #1

Open mfkps opened 1 year ago

mfkps commented 1 year ago

我部署成功了,但不懂怎么运用

2023-04-14 12:04:00,458 - chatgpt_proxy.proxy - ERROR - Response: {"models":[{"slug":"text-davinci-002-render-sha","max_tokens":4097,"title":"Turbo (Default for free users)","description":"The standard ChatGPT model","tags":[],"qualitative_properties":{}}]} INFO: 127.0.0.1:7369 - "GET / HTTP/1.1" 404 Not Found INFO: 127.0.0.1:7459 - "GET /backend-api HTTP/1.1" 307 Temporary Redirect INFO: 127.0.0.1:7459 - "GET /backend-api/ HTTP/1.1" 404 Not Found INFO: 127.0.0.1:7550 - "GET /api/auth/session HTTP/1.1" 404 Not Found INFO: 127.0.0.1:7584 - "GET /backend-api/api/auth/session HTTP/1.1" 404 Not Found

18870 commented 1 year ago

这只是一个代理 https://chat.openai.com/backend-api 的程序,不具备任何高级功能。

你需要使用其他调用这个非官方api的程序。例如 acheong08/revChatGPT,在环境变量或者配置中 https://github.com/acheong08/ChatGPT/pull/1277 中设置 base_url 到这个代理上。 或者其他在底层使用这些api的程序,例如 moeakwak/chatgpt-web-share

mfkps commented 1 year ago

请问在 moeakwak/chatgpt-web-share 中是怎么样调用?

18870 commented 1 year ago

在它的配置文件里将 chatgpt_base_url 指向 http://ip:port/backend-api/

mfkps commented 1 year ago

好的,谢谢! 注意!如果你是 plus 用户,请取消下面的注释,并根据后文说明填写 reverse_proxy_puid chatgpt_base_url: http://ip:port/backend-api/ run_reverse_proxy: true reverse_proxy_port: 6060

reverse_proxy_binary_path: /app/backend/ChatGPT-Proxy-V4

reverse_proxy_puid: "_puid value from cookie" auto_refresh_reverse_proxy_puid: true # 是否自动更新 puid

是这样不? reverse_proxy_binary_path: /app/backend/ChatGPT-Proxy-V4 这个不用配置对吗?

18870 commented 1 year ago

这个的docker版本内置了ChatGPT-Proxy-V4,基本上等同于这个仓库提供的功能。实际上这个仓库就是它的python替代品。

所以目前来说是二选一,把chatgpt_base_url改成你部署的地址,不用开启run_reverse_proxy和下面的东西; 或者用它的默认值,打开run_reverse_proxy,按照说明填写下面的东西。

mfkps commented 1 year ago

好的明白,谢谢

mfkps commented 1 year ago

root@USGPT:/home/chatgpt-proxy# python -m chatgpt_proxy INFO: Started server process [54872] INFO: Waiting for application startup. INFO: Application startup complete. INFO: Uvicorn running on http://127.0.0.1:7800 (Press CTRL+C to quit) 2023-04-16 23:30:51,631 - chatgpt_proxy.proxy - ERROR - Failed to get puid 2023-04-16 23:30:51,631 - chatgpt_proxy.proxy - ERROR - Cookies: <Cookies[]> 2023-04-16 23:30:51,631 - chatgpt_proxy.proxy - ERROR - Response:

------------------------------------------------------------------------------------------------------- 这样算是正常吗? ![image](https://user-images.githubusercontent.com/10321631/232349946-c59b8272-662c-4798-a09d-be2b42ad5709.png)
benngai123 commented 1 year ago

我也是這樣, 請問是哪裏配置得不對嗎?

18870 commented 1 year ago

openai风控升级了,取消了puid不用cloudflare验证的特权。 现在如果要用这个项目,只能是去点验证码拿cf_clearance。

隔壁有用浏览器模拟的项目:https://github.com/linweiyuan/go-chatgpt-api ,据说能用,但是不稳定。 这个可能更稳定,但是目测没有打字机效果 https://github.com/dreamhunter2333/chatgpt_reverse_proxy 如果你只在乎能不能用,可以使用公共代理 https://github.com/acheong08/ChatGPT/issues/1336#issuecomment-1510398790

yayaQAQ commented 1 year ago

可以这样直接使用,我这个是为了用gpt4:

from revChatGPT.V1 import Chatbot

chatbot = Chatbot(config={
    "access_token": "your access token",
    "paid": True,
    "model": "gpt-4"
}, base_url="http://127.0.0.1:7800/backend-api/")

prompt = "hello"
response = ""

for data in chatbot.ask(
        prompt
):
    response = data["message"]

print(response)