Beckjiang / chatgpt-api

chatgpt-api is a tool that converts the functionality of the ChatGPT website into OpenAI Chat API protocol.
8 stars 0 forks source link

error when my first run #2

Closed tocer closed 1 year ago

tocer commented 1 year ago

Hi: my box is manjaro linux, I followed the guide and run:

curl http://127.0.0.1:8082/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer sk-test" \ -d '{ "model": "gpt-3.5-turbo", "messages": [{"role": "user", "content": "Hello!"}] }'

error happen:

chatgpt_api | Traceback (most recent call last): chatgpt_api | File "/usr/local/lib/python3.11/site-packages/revChatGPT/V1.py", line 668, in check_response chatgpt_api | response.raise_for_status() chatgpt_api | File "/usr/local/lib/python3.11/site-packages/requests/models.py", line 1021, in raise_for_status chatgpt_api | raise HTTPError(http_error_msg, response=self) chatgpt_api | requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://ai.fakeopen.com/api/conversation chatgpt_api | chatgpt_api | The above exception was the direct cause of the following exception: chatgpt_api | chatgpt_api | Traceback (most recent call last): chatgpt_api | File "/usr/local/lib/python3.11/site-packages/gevent/pywsgi.py", line 999, in handle_one_response chatgpt_api | self.run_application() chatgpt_api | File "/usr/local/lib/python3.11/site-packages/gevent/pywsgi.py", line 946, in run_application chatgpt_api | self.process_result() chatgpt_api | File "/usr/local/lib/python3.11/site-packages/gevent/pywsgi.py", line 930, in process_result chatgpt_api | for data in self.result: chatgpt_api | File "/usr/local/lib/python3.11/site-packages/werkzeug/wsgi.py", line 281, in next chatgpt_api | return self._next() chatgpt_api | ^^^^^^^^^^^^ chatgpt_api | File "/usr/local/lib/python3.11/site-packages/werkzeug/wrappers/response.py", line 31, in _iter_encoded chatgpt_api | for item in iterable: chatgpt_api | File "/app/ChatGPTServer.py", line 135, in send_chunked_response chatgpt_api | raise e chatgpt_api | File "/app/ChatGPTServer.py", line 131, in send_chunked_response chatgpt_api | yield from self.execute_chat_response(chatbot, scene_id, email, stream, message, conversation_id, parent_id, model) chatgpt_api | File "/app/ChatGPTServer.py", line 91, in execute_chat_response chatgpt_api | for data in chatbot.ask(prompt=message, conversation_id=conversation_id, parent_id=parent_id, model=model): chatgpt_api | File "/usr/local/lib/python3.11/site-packages/revChatGPT/V1.py", line 556, in ask chatgpt_api | yield from self.post_messages( chatgpt_api | File "/usr/local/lib/python3.11/site-packages/revChatGPT/V1.py", line 510, in post_messages chatgpt_api | yield from self.send_request( chatgpt_api | File "/usr/local/lib/python3.11/site-packages/revChatGPT/V1.py", line 365, in send_request chatgpt_api | self.check_response(response) chatgpt_api | File "/usr/local/lib/python3.11/site-packages/revChatGPT/V1.py", line 66, in wrapper chatgpt_api | out = func(*args, **kwargs) chatgpt_api | ^^^^^^^^^^^^^^^^^^^^^ chatgpt_api | File "/usr/local/lib/python3.11/site-packages/revChatGPT/V1.py", line 675, in __check_response chatgpt_api | raise error from ex chatgpt_api | revChatGPT.typings.Error: OpenAI: {"detail":{"message":"Unauthorized - Invalid access token"}} (code: 401) chatgpt_api | Please check that the input is correct, or you can resolve this issue by filing an issue chatgpt_api | Project URL: https://github.com/acheong08/ChatGPT chatgpt_api | 2023-05-09T12:51:26Z {'REMOTE_ADDR': '::ffff:172.18.0.1', 'REMOTE_PORT': '50496', 'HTTP_HOST': '127.0.0.1:8082', (hidden keys: 23)} failed with Error chatgpt_api | chatgpt_api | ::ffff:172.18.0.1 - - [2023-05-09 12:51:26] "POST /v1/chat/completions HTTP/1.1" 500 161 1.040661

thanks for your any response.

Beckjiang commented 1 year ago

Have you configured your access_token?

Beckjiang commented 1 year ago

I found that my English README is not the latest version. I will update it later, or you can try the Chinese documentation first.

Beckjiang commented 1 year ago

README_en updated @tocer

tocer commented 1 year ago

Have you configured your access_token?

yes, it's a free acount but not a plus account. account.ini

[chatgpt_1]
email=tocer.deng@gmail.com
access_token=sk-qNog77FnOeFBesY0PPQmT3BlbkFJRsFQkKtwEthHqYaXXXXX

config.ini

[redis]
host=redis
port=6379
db=0

[api_key]
api_keys=[
        "sk-test",
        "sk-2"
    ]
Beckjiang commented 1 year ago

the access_token is not the API key. Open the url https://chat.openai.com/api/auth/session and login, then you can see the access_token.

tocer commented 1 year ago

Good, I have fixed the access_token error and test it, then seems to be blocked :(

$curl http://127.0.0.1:8082/v1/chat/completions -H "Content-Type: application/json" -H "Authorization: Bearer sk-test" -d '{ "model": "gpt-3.5-turbo", "messages": [{"role": "user", "content": "Hello!"}] }'

2023-05-13T08:58:06.804526272Z Traceback (most recent call last): 2023-05-13T08:58:06.804986879Z File "/usr/local/lib/python3.11/site-packages/revChatGPT/V1.py", line 668, in check_response 2023-05-13T08:58:06.805027285Z response.raise_for_status() 2023-05-13T08:58:06.805044934Z File "/usr/local/lib/python3.11/site-packages/requests/models.py", line 1021, in raise_for_status 2023-05-13T08:58:06.805060941Z raise HTTPError(http_error_msg, response=self) 2023-05-13T08:58:06.805076297Z requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://ai.fakeopen.com/api/conversation 2023-05-13T08:58:06.805631198Z 2023-05-13T08:58:06.805764993Z The above exception was the direct cause of the following exception: 2023-05-13T08:58:06.805791900Z 2023-05-13T08:58:06.805805463Z Traceback (most recent call last): 2023-05-13T08:58:06.807514508Z File "/usr/local/lib/python3.11/site-packages/gevent/pywsgi.py", line 999, in handle_one_response 2023-05-13T08:58:06.807553656Z self.run_application() 2023-05-13T08:58:06.807606677Z File "/usr/local/lib/python3.11/site-packages/gevent/pywsgi.py", line 946, in run_application 2023-05-13T08:58:06.807624423Z self.process_result() 2023-05-13T08:58:06.807637219Z File "/usr/local/lib/python3.11/site-packages/gevent/pywsgi.py", line 930, in process_result 2023-05-13T08:58:06.807650559Z for data in self.result: 2023-05-13T08:58:06.807663208Z File "/usr/local/lib/python3.11/site-packages/werkzeug/wsgi.py", line 281, in next 2023-05-13T08:58:06.807676933Z return self._next() 2023-05-13T08:58:06.807689364Z ^^^^^^^^^^^^ 2023-05-13T08:58:06.807701842Z File "/usr/local/lib/python3.11/site-packages/werkzeug/wrappers/response.py", line 31, in _iter_encoded 2023-05-13T08:58:06.807715645Z for item in iterable: 2023-05-13T08:58:06.807741928Z File "/app/ChatGPTServer.py", line 135, in send_chunked_response 2023-05-13T08:58:06.807751601Z raise e 2023-05-13T08:58:06.807761284Z File "/app/ChatGPTServer.py", line 131, in send_chunked_response 2023-05-13T08:58:06.807773845Z yield from self.execute_chat_response(chatbot, scene_id, email, stream, message, conversation_id, parent_id, model) 2023-05-13T08:58:06.807786126Z File "/app/ChatGPTServer.py", line 91, in execute_chat_response 2023-05-13T08:58:06.807797456Z for data in chatbot.ask(prompt=message, conversation_id=conversation_id, parent_id=parent_id, model=model): 2023-05-13T08:58:06.807810431Z File "/usr/local/lib/python3.11/site-packages/revChatGPT/V1.py", line 556, in ask 2023-05-13T08:58:06.807821315Z yield from self.post_messages( 2023-05-13T08:58:06.807831832Z File "/usr/local/lib/python3.11/site-packages/revChatGPT/V1.py", line 510, in post_messages 2023-05-13T08:58:06.807842975Z yield from self.__send_request( 2023-05-13T08:58:06.807852609Z File "/usr/local/lib/python3.11/site-packages/revChatGPT/V1.py", line 365, in send_request 2023-05-13T08:58:06.807880825Z self.__check_response(response) 2023-05-13T08:58:06.807895999Z File "/usr/local/lib/python3.11/site-packages/revChatGPT/V1.py", line 66, in wrapper 2023-05-13T08:58:06.807907776Z out = func(*args, **kwargs) 2023-05-13T08:58:06.807917662Z ^^^^^^^^^^^^^^^^^^^^^ 2023-05-13T08:58:06.807928471Z File "/usr/local/lib/python3.11/site-packages/revChatGPT/V1.py", line 675, in check_response 2023-05-13T08:58:06.807938736Z raise error from ex 2023-05-13T08:58:06.808658085Z revChatGPT.typings.Error: OpenAI: <!DOCTYPE html> 2023-05-13T08:58:06.808695023Z 2023-05-13T08:58:06.808709182Z 2023-05-13T08:58:06.808722832Z 2023-05-13T08:58:06.808734741Z 2023-05-13T08:58:06.808747589Z 2023-05-13T08:58:06.808758807Z Attention Required! | Cloudflare 2023-05-13T08:58:06.808771383Z 2023-05-13T08:58:06.808782680Z 2023-05-13T08:58:06.808794386Z 2023-05-13T08:58:06.808806012Z 2023-05-13T08:58:06.808817298Z 2023-05-13T08:58:06.808828591Z 2023-05-13T08:58:06.808840479Z 2023-05-13T08:58:06.808853210Z 2023-05-13T08:58:06.808865622Z 2023-05-13T08:58:06.808876841Z 2023-05-13T08:58:06.808887392Z 2023-05-13T08:58:06.808899098Z 2023-05-13T08:58:06.808998573Z 2023-05-13T08:58:06.809009080Z 2023-05-13T08:58:06.809018962Z 2023-05-13T08:58:06.809027921Z 2023-05-13T08:58:06.809036932Z 2023-05-13T08:58:06.809046077Z

2023-05-13T08:58:06.809055874Z 2023-05-13T08:58:06.809068051Z
2023-05-13T08:58:06.809079031Z
2023-05-13T08:58:06.809090641Z

Sorry, you have been blocked

2023-05-13T08:58:06.809102398Z

You are unable to access fakeopen.com

2023-05-13T08:58:06.809113676Z
2023-05-13T08:58:06.809124567Z 2023-05-13T08:58:06.809134844Z
2023-05-13T08:58:06.809144847Z
2023-05-13T08:58:06.809154794Z
2023-05-13T08:58:06.809165826Z 2023-05-13T08:58:06.809176319Z 2023-05-13T08:58:06.809187443Z 2023-05-13T08:58:06.809198365Z
2023-05-13T08:58:06.809209338Z
2023-05-13T08:58:06.809220149Z
2023-05-13T08:58:06.809230569Z 2023-05-13T08:58:06.809242549Z
2023-05-13T08:58:06.809253421Z
2023-05-13T08:58:06.809264947Z
2023-05-13T08:58:06.809275613Z

Why have I been blocked?

2023-05-13T08:58:06.809288094Z 2023-05-13T08:58:06.809301715Z

This website is using a security service to protect itself from online attacks. The action you just performed triggered the security solution. There are several actions that could trigger this block including submitting a certain word or phrase, a SQL command or malformed data.

2023-05-13T08:58:06.809316519Z
2023-05-13T08:58:06.809327008Z 2023-05-13T08:58:06.809337450Z
2023-05-13T08:58:06.809360004Z

What can I do to resolve this?

2023-05-13T08:58:06.809372442Z 2023-05-13T08:58:06.809382697Z

You can email the site owner to let them know you were blocked. Please include what you were doing when this page came up and the Cloudflare Ray ID found at the bottom of this page.

2023-05-13T08:58:06.809394993Z
2023-05-13T08:58:06.809406183Z
2023-05-13T08:58:06.809417393Z
2023-05-13T08:58:06.809428178Z 2023-05-13T08:58:06.809440028Z 2023-05-13T08:58:06.809619406Z 2023-05-13T08:58:06.809628953Z 2023-05-13T08:58:06.809638987Z
2023-05-13T08:58:06.809658873Z
2023-05-13T08:58:06.809670783Z 2023-05-13T08:58:06.809680636Z 2023-05-13T08:58:06.809733924Z 2023-05-13T08:58:06.809743725Z 2023-05-13T08:58:06.809753745Z 2023-05-13T08:58:06.809763844Z (code: 403) 2023-05-13T08:58:06.809773840Z Please check that the input is correct, or you can resolve this issue by filing an issue 2023-05-13T08:58:06.809784527Z Project URL: https://github.com/acheong08/ChatGPT 2023-05-13T08:58:06.809794906Z 2023-05-13T08:58:06Z {'REMOTE_ADDR': '::ffff:172.18.0.1', 'REMOTE_PORT': '51006', 'HTTP_HOST': '127.0.0.1:8082', (hidden keys: 23)} failed with Error 2023-05-13T08:58:06.809805219Z 2023-05-13T08:58:06.809814926Z ::ffff:172.18.0.1 - - [2023-05-13 08:58:06] "POST /v1/chat/completions HTTP/1.1" 500 161 0.595314 ^C2023-05-13T09:18:45.270879826Z Traceback (most recent call last): 2023-05-13T09:18:45.271115462Z File "/usr/local/lib/python3.11/site-packages/revChatGPT/V1.py", line 668, in check_response 2023-05-13T09:18:45.271134281Z response.raise_for_status() 2023-05-13T09:18:45.271148635Z File "/usr/local/lib/python3.11/site-packages/requests/models.py", line 1021, in raise_for_status 2023-05-13T09:18:45.271156731Z raise HTTPError(http_error_msg, response=self) 2023-05-13T09:18:45.271163933Z requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://ai.fakeopen.com/api/conversation 2023-05-13T09:18:45.271247169Z 2023-05-13T09:18:45.271266217Z The above exception was the direct cause of the following exception: 2023-05-13T09:18:45.271274285Z 2023-05-13T09:18:45.271280817Z Traceback (most recent call last): 2023-05-13T09:18:45.271828972Z File "/usr/local/lib/python3.11/site-packages/gevent/pywsgi.py", line 999, in handle_one_response 2023-05-13T09:18:45.271854943Z self.run_application() 2023-05-13T09:18:45.271864101Z File "/usr/local/lib/python3.11/site-packages/gevent/pywsgi.py", line 946, in run_application 2023-05-13T09:18:45.271871459Z self.process_result() 2023-05-13T09:18:45.271878430Z File "/usr/local/lib/python3.11/site-packages/gevent/pywsgi.py", line 930, in process_result 2023-05-13T09:18:45.271886530Z for data in self.result: 2023-05-13T09:18:45.271892107Z File "/usr/local/lib/python3.11/site-packages/werkzeug/wsgi.py", line 281, in next 2023-05-13T09:18:45.271897730Z return self._next() 2023-05-13T09:18:45.271904488Z ^^^^^^^^^^^^ 2023-05-13T09:18:45.271910820Z File "/usr/local/lib/python3.11/site-packages/werkzeug/wrappers/response.py", line 31, in _iter_encoded 2023-05-13T09:18:45.271918330Z for item in iterable: 2023-05-13T09:18:45.271925726Z File "/app/ChatGPTServer.py", line 135, in send_chunked_response 2023-05-13T09:18:45.271932053Z raise e 2023-05-13T09:18:45.271938340Z File "/app/ChatGPTServer.py", line 131, in send_chunked_response 2023-05-13T09:18:45.271944327Z yield from self.execute_chat_response(chatbot, scene_id, email, stream, message, conversation_id, parent_id, model) 2023-05-13T09:18:45.271953687Z File "/app/ChatGPTServer.py", line 91, in execute_chat_response 2023-05-13T09:18:45.271960350Z for data in chatbot.ask(prompt=message, conversation_id=conversation_id, parent_id=parent_id, model=model): 2023-05-13T09:18:45.271966620Z File "/usr/local/lib/python3.11/site-packages/revChatGPT/V1.py", line 556, in ask 2023-05-13T09:18:45.271972737Z yield from self.post_messages( 2023-05-13T09:18:45.271979171Z File "/usr/local/lib/python3.11/site-packages/revChatGPT/V1.py", line 510, in post_messages 2023-05-13T09:18:45.271985442Z yield from self.send_request( 2023-05-13T09:18:45.271991183Z File "/usr/local/lib/python3.11/site-packages/revChatGPT/V1.py", line 365, in __send_request 2023-05-13T09:18:45.272008668Z self.check_response(response) 2023-05-13T09:18:45.272014968Z File "/usr/local/lib/python3.11/site-packages/revChatGPT/V1.py", line 66, in wrapper 2023-05-13T09:18:45.272021065Z out = func(*args, **kwargs) 2023-05-13T09:18:45.272026826Z ^^^^^^^^^^^^^^^^^^^^^ 2023-05-13T09:18:45.272032615Z File "/usr/local/lib/python3.11/site-packages/revChatGPT/V1.py", line 675, in __check_response 2023-05-13T09:18:45.272123789Z raise error from ex 2023-05-13T09:18:45.272268172Z revChatGPT.typings.Error: OpenAI: <!DOCTYPE html> 2023-05-13T09:18:45.272280549Z 2023-05-13T09:18:45.272287613Z 2023-05-13T09:18:45.272295151Z 2023-05-13T09:18:45.272302609Z 2023-05-13T09:18:45.272310317Z 2023-05-13T09:18:45.272316916Z Attention Required! | Cloudflare 2023-05-13T09:18:45.272324251Z 2023-05-13T09:18:45.272330876Z 2023-05-13T09:18:45.272337453Z 2023-05-13T09:18:45.272346672Z 2023-05-13T09:18:45.272354624Z 2023-05-13T09:18:45.272362092Z 2023-05-13T09:18:45.272369206Z 2023-05-13T09:18:45.272376551Z 2023-05-13T09:18:45.272383790Z 2023-05-13T09:18:45.272389354Z 2023-05-13T09:18:45.272395286Z 2023-05-13T09:18:45.272402437Z 2023-05-13T09:18:45.272460246Z 2023-05-13T09:18:45.272466141Z 2023-05-13T09:18:45.272471928Z 2023-05-13T09:18:45.272478197Z 2023-05-13T09:18:45.272483984Z 2023-05-13T09:18:45.272489859Z
2023-05-13T09:18:45.272496336Z 2023-05-13T09:18:45.272503428Z
2023-05-13T09:18:45.272509793Z
2023-05-13T09:18:45.272515824Z

Sorry, you have been blocked

2023-05-13T09:18:45.272522378Z

You are unable to access fakeopen.com

2023-05-13T09:18:45.272529456Z
2023-05-13T09:18:45.272535448Z 2023-05-13T09:18:45.272541135Z
2023-05-13T09:18:45.272547603Z
2023-05-13T09:18:45.272553628Z
2023-05-13T09:18:45.272559776Z 2023-05-13T09:18:45.272565546Z 2023-05-13T09:18:45.272571995Z 2023-05-13T09:18:45.272577776Z
2023-05-13T09:18:45.272583782Z
2023-05-13T09:18:45.272589698Z
2023-05-13T09:18:45.272595898Z 2023-05-13T09:18:45.272602820Z
2023-05-13T09:18:45.272609449Z
2023-05-13T09:18:45.272616386Z
2023-05-13T09:18:45.272622505Z

Why have I been blocked?

2023-05-13T09:18:45.272629003Z 2023-05-13T09:18:45.272635538Z

This website is using a security service to protect itself from online attacks. The action you just performed triggered the security solution. There are several actions that could trigger this block including submitting a certain word or phrase, a SQL command or malformed data.

2023-05-13T09:18:45.272644012Z
2023-05-13T09:18:45.272650735Z 2023-05-13T09:18:45.272656691Z
2023-05-13T09:18:45.272668465Z

What can I do to resolve this?

2023-05-13T09:18:45.272675059Z 2023-05-13T09:18:45.272680834Z

You can email the site owner to let them know you were blocked. Please include what you were doing when this page came up and the Cloudflare Ray ID found at the bottom of this page.

2023-05-13T09:18:45.272688016Z
2023-05-13T09:18:45.272693803Z
2023-05-13T09:18:45.272699598Z
2023-05-13T09:18:45.272705529Z 2023-05-13T09:18:45.272711213Z 2023-05-13T09:18:45.272818595Z 2023-05-13T09:18:45.272824004Z 2023-05-13T09:18:45.272829800Z
2023-05-13T09:18:45.272841654Z
2023-05-13T09:18:45.272847991Z 2023-05-13T09:18:45.272853687Z 2023-05-13T09:18:45.272882792Z 2023-05-13T09:18:45.272888450Z 2023-05-13T09:18:45.272895005Z 2023-05-13T09:18:45.272900888Z (code: 403) 2023-05-13T09:18:45.272906932Z Please check that the input is correct, or you can resolve this issue by filing an issue 2023-05-13T09:18:45.272913132Z Project URL: https://github.com/acheong08/ChatGPT 2023-05-13T09:18:45.272919242Z 2023-05-13T09:18:45Z {'REMOTE_ADDR': '::ffff:172.18.0.1', 'REMOTE_PORT': '54370', 'HTTP_HOST': '127.0.0.1:8082', (hidden keys: 23)} failed with Error 2023-05-13T09:18:45.272925585Z 2023-05-13T09:18:45.273318426Z ::ffff:172.18.0.1 - - [2023-05-13 09:18:45] "POST /v1/chat/completions HTTP/1.1" 500 161 1.285197

tocer commented 1 year ago

my chatgpt works well, and is not blocked.

Beckjiang commented 1 year ago

@tocer I just tested it locally and didn't encounter this issue. If you're still experiencing problems, you can try to run the proxy by yourself. Please refer to the following docker-compose.yml file:

version: '3'

services:
  app:
    image: beckjiang/chatgpt-api
    container_name: chatgpt_api
    restart: unless-stopped
    ports:
      - '8082:8082'
    volumes:
      - ./config:/app/config
    environment:
      CHATGPT_BASE_URL: http://go-chatgpt-api:8080/
    depends_on:
      redis:
        condition: service_healthy

  redis:
    image: redis
    ports:
      - "6379"
    healthcheck:
      test: [ "CMD", "redis-cli", "ping" ]
      interval: 10s
      retries: 5

  go-chatgpt-api:
    container_name: go-chatgpt-api
    image: linweiyuan/go-chatgpt-api
    environment:
      - GIN_MODE=release
      - GO_CHATGPT_API_PROXY=socks5://192.168.3.5:1086
      # - GO_CHATGPT_API_PROXY=socks5://chatgpt-proxy-server-warp:65535
    # depends_on:
      # - chatgpt-proxy-server-warp
    restart: unless-stopped

  # chatgpt-proxy-server-warp:
  #   container_name: chatgpt-proxy-server-warp
  #   image: linweiyuan/chatgpt-proxy-server-warp
  #   environment:
  #     - LOG_LEVEL=INFO
  #   restart: unless-stopped

If your operating environment requires a VPN to access ChatGPT, you need to modify the GO_CHATGPT_API_PROXY environment variable. For detailed configuration of go-chatgpt-api, please refer to: https://github.com/linweiyuan/go-chatgpt-api . socks5://192.168.3.5:1086 is my local proxy config, you should change to yours.